In simple terms, what does answer span extraction try to do when given a question and a paragraph?
Think about pointing to a specific piece of text that answers the question.
Answer span extraction means locating the exact text segment in the paragraph that answers the question, not creating new text or unrelated tasks.
Given the paragraph and question, what answer span does the model predict?
paragraph = 'The Eiffel Tower is located in Paris and is one of the most famous landmarks.' question = 'Where is the Eiffel Tower located?' # Simulated model output (start and end indices) start_index = 5 end_index = 6 answer_tokens = paragraph.split()[start_index:end_index+1] answer = ' '.join(answer_tokens) print(answer)
Look at the words between indices 5 and 6 in the paragraph split by spaces.
The paragraph split by spaces is ['The', 'Eiffel', 'Tower', 'is', 'located', 'in', 'Paris', ...]. Indices 5 and 6 correspond to 'in' and 'Paris', so the answer is 'in Paris'. But the code prints from index 5 to 6 inclusive, so 'located in Paris' is from indices 4 to 6. Since start_index=5, end_index=6, the answer is 'in Paris'. So option A is correct.
Choose the model type that is designed to predict start and end positions of answers in a paragraph.
Think about models that output positions rather than generating text.
Answer span extraction models typically use transformers with two output heads predicting start and end token positions in the input text.
When checking if the predicted answer span matches the true answer span, which metric is most appropriate?
Think about a metric that checks if the predicted answer is exactly the same as the true answer.
Exact Match (EM) score is used to check if the predicted answer span exactly matches the ground truth span, which is crucial for span extraction tasks.
Consider this code snippet that tries to extract an answer span but returns an empty string. What is the most likely cause?
paragraph = 'Machine learning helps computers learn from data.' start_index = 7 end_index = 5 answer_tokens = paragraph.split()[start_index:end_index+1] answer = ' '.join(answer_tokens) print(answer)
Check the order of start and end indices in the slice.
In Python, slicing with a start index greater than the end index returns an empty list, so no tokens are joined and the answer is empty.