rajpurkar/squad_v2
Viewer • Updated • 142k • 45.1k • 266
How to use peeyush01/bert-qa-finetuned 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="peeyush01/bert-qa-finetuned") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("peeyush01/bert-qa-finetuned")
model = AutoModelForQuestionAnswering.from_pretrained("peeyush01/bert-qa-finetuned", device_map="auto")This model is a fine-tuned version of BERT-base uncased on the SQuAD v2 dataset for extractive question answering.
It was trained for 3 epochs and can answer questions given a context passage, while also handling unanswerable questions (a key feature of SQuAD v2).
You can try the model with the following code:
from transformers import pipeline
qa_pipeline = pipeline("question-answering", model="peeyush01/bert-squad-v2")
result = qa_pipeline({
"context": "Hugging Face is creating a tool that democratizes AI.",
"question": "What is Hugging Face creating?"
})
print(result)
Base model
google-bert/bert-base-uncased