Model Pipeline - QA with Hugging Face pipeline
This pipeline uses a pre-trained Hugging Face model to answer questions based on a given text. It reads the question and context, then predicts the answer span from the context.
Jump into concepts and practice - no test required
This pipeline uses a pre-trained Hugging Face model to answer questions based on a given text. It reads the question and context, then predicts the answer span from the context.
Loss
1.2 |*
0.9 | *
0.7 | *
0.5 | *
0.4 | *
+--------
1 2 3 4 5 Epochs
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 1.2 | 0.45 | Model starts learning basic patterns |
| 2 | 0.9 | 0.60 | Loss decreases, accuracy improves |
| 3 | 0.7 | 0.72 | Model better at locating answers |
| 4 | 0.5 | 0.80 | Good convergence, stable learning |
| 5 | 0.4 | 0.85 | Model fine-tuned for QA task |
from transformers import pipeline
qa = pipeline('question-answering')
result = qa(question='Where is the Eiffel Tower?', context='The Eiffel Tower is in Paris.')
print(result['answer'])from transformers import pipeline
qa = pipeline('question-answering')
result = qa(question='Who wrote Hamlet?', text='Hamlet was written by Shakespeare.')
print(result['answer'])