rajpurkar/squad
Viewer • Updated • 98.2k • 158k • 892
How to use echarlaix/distilbert-base-uncased-distilled-squad-openvino with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "question-answering" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# pip install "transformers<5.0.0"
from transformers import pipeline
pipe = pipeline("question-answering", model="echarlaix/distilbert-base-uncased-distilled-squad-openvino") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("echarlaix/distilbert-base-uncased-distilled-squad-openvino")
model = AutoModelForQuestionAnswering.from_pretrained("echarlaix/distilbert-base-uncased-distilled-squad-openvino", device_map="auto")This model was converted to OpenVINO from distilbert/distilbert-base-uncased-distilled-squad using optimum-intel
via the export space.
First make sure you have optimum-intel installed:
pip install optimum[openvino]
To load your model you can do as follows:
from optimum.intel import OVModelForQuestionAnswering
model_id = "echarlaix/distilbert-base-uncased-distilled-squad-openvino"
model = OVModelForQuestionAnswering.from_pretrained(model_id)