Model Pipeline - Open-domain QA basics
This pipeline answers questions by searching a large collection of documents and then selecting the best answer. It first finds relevant text pieces, then reads them carefully to find the exact answer.
This pipeline answers questions by searching a large collection of documents and then selecting the best answer. It first finds relevant text pieces, then reads them carefully to find the exact answer.
Loss
1.2 |****
1.0 |***
0.8 |**
0.6 |*
0.4 |
+----
1 2 3 4 5 Epochs
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 1.2 | 0.45 | Model starts learning to locate answers in text. |
| 2 | 0.9 | 0.60 | Model improves understanding of question and context. |
| 3 | 0.7 | 0.72 | Model better identifies correct answer spans. |
| 4 | 0.5 | 0.80 | Model converges with good answer extraction ability. |
| 5 | 0.4 | 0.85 | Final fine-tuning improves accuracy slightly. |
from transformers import pipeline
qa = pipeline('question-answering')
context = "The Eiffel Tower is in Paris."
question = "Where is the Eiffel Tower located?"
result = qa(question=question, context=context)
print(result['answer'])
What will be printed?from transformers import pipeline
qa = pipeline('question-answering')
context = "Mount Everest is the highest mountain."
question = "What is the highest mountain?"
result = qa(question=question, context=context)
print(result['answer'])
But it raises a KeyError: 'answer'. What is the likely cause?Pass the test and this pattern moves unknown