Advanced level · Module 9: Text Summarization and Question Answering · Lesson 2 of 3
Extractive Question Answering
Learners use a pretrained extractive QA model that finds the answer span in a passage, evaluate it with exact match and F1 and handle questions that have no answer.
In this lesson you will
- Run extractive QA on passages
- Evaluate QA with exact match and F1
Key concepts
span predictionpipeline('question-answering')SQuADexact match and F1unanswerable questions and score thresholds
The lesson
An extractive QA model reads a question and a passage and predicts the start and end of the answer span in the passage. Models fine-tuned on SQuAD (CC BY-SA 4.0) are widely available: transformers.pipeline('question-answering', model=...) returns the answer text and a score.
Evaluate with exact match (the answer equals the reference) and token-level F1 (partial overlap), using a small set of questions written about local public documents.
Some questions have no answer in the passage. Set a minimum score threshold below which the system replies 'not found in this document' rather than returning a weak guess.
Step by step
- Write 30 questions with answers about five public documents.
- Run the QA pipeline on the relevant passages.
- Compute exact match and F1.
- Choose a score threshold using unanswerable questions.
Practice activity
Evaluate an extractive QA model on a hand-made local question set and choose a threshold.
Expected result: Reported exact match and F1, and a threshold that avoids most weak guesses.
Check your understanding
-
What does an extractive QA model predict?
Show answer
The start and end of the answer span in the passage.
-
Why set a score threshold?
Show answer
So that the system says 'not found' instead of guessing when the answer is not in the passage.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.