Choose the best description of what a question answering system does.
Think about what happens when you ask a smart assistant a question.
Question answering systems are designed to understand questions and provide relevant answers by processing natural language.
Given the following code snippet using a pretrained QA model, what will be the printed answer?
from transformers import pipeline qa = pipeline('question-answering') context = "The Eiffel Tower is located in Paris." question = "Where is the Eiffel Tower located?" result = qa(question=question, context=context) print(result['answer'])
The model extracts the answer from the context that best fits the question.
The model finds the phrase in the context that answers the question, which is "Paris".
You want to build a system that answers questions about any topic using a large collection of documents. Which model type is best suited?
Think about how to handle large knowledge bases and generate answers.
Retrieval-augmented generation models combine document search with answer generation, ideal for open-domain QA.
A QA model predicted the answer "Paris" for the question "Where is the Eiffel Tower?" The true answer is "Paris, France". What are the Exact Match and F1 scores?
Exact Match requires exact string equality; F1 measures overlap of tokens.
Exact Match is 0 because "Paris" != "Paris, France" exactly. F1 is calculated based on token overlap: tokens in common are "Paris" (1), total tokens predicted (1), total tokens true (2), so F1 = 2*1/(1+2) = 0.67.
Consider this code snippet:
from transformers import pipeline
qa = pipeline('question-answering')
context = None
question = "What is AI?"
result = qa(question=question, context=context)
print(result['answer'])Why does it raise an error?
Check the type and value of the context variable passed to the model.
The context must be a string. Passing None causes the model to fail with a TypeError because it cannot process a NoneType input.