rajpurkar/squad
Viewer • Updated • 98.2k • 171k • 882
How to use HariomSahu/distilbert-squad-qa 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="HariomSahu/distilbert-squad-qa") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("HariomSahu/distilbert-squad-qa")
model = AutoModelForQuestionAnswering.from_pretrained("HariomSahu/distilbert-squad-qa", device_map="auto")# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("HariomSahu/distilbert-squad-qa")
model = AutoModelForQuestionAnswering.from_pretrained("HariomSahu/distilbert-squad-qa", device_map="auto")This model is a fine-tuned version of distilbert-base-uncased on the SQuAD dataset.
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("HariomSahu/distilbert-squad-qa")
model = AutoModelForQuestionAnswering.from_pretrained("HariomSahu/distilbert-squad-qa")
# Example usage
question = "What is the capital of France?"
context = "France is a country in Europe. Its capital city is Paris."
inputs = tokenizer(question, context, return_tensors="pt")
outputs = model(**inputs)
# Get answer
start_scores, end_scores = outputs.start_logits, outputs.end_logits
start_index = start_scores.argmax()
end_index = end_scores.argmax()
answer = tokenizer.decode(inputs["input_ids"][0][start_index:end_index+1])
print(f"Answer: {answer}")
The model achieved the following results on the evaluation set:
Config Hash: fe08f7bd
This hash can be used to reproduce the exact training configuration.
# 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="HariomSahu/distilbert-squad-qa")