Challenge - 5 Problems
QA Pipeline Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple QA pipeline
What is the output of this code snippet using Hugging Face's QA pipeline?
NLP
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'])
Attempts:
2 left
💡 Hint
The pipeline extracts the answer span from the context that best answers the question.
✗ Incorrect
The QA pipeline finds the answer span in the context. Since the question asks where the Eiffel Tower is located, the answer is "Paris".
❓ Model Choice
intermediate2:00remaining
Choosing the right model for QA pipeline
Which model is best suited for a question-answering pipeline that requires understanding context and providing precise answers?
Attempts:
2 left
💡 Hint
Look for a model fine-tuned specifically on a QA dataset like SQuAD.
✗ Incorrect
The 'distilbert-base-uncased-distilled-squad' model is fine-tuned on the SQuAD dataset, making it suitable for QA tasks.
❓ Hyperparameter
advanced2:00remaining
Effect of changing top_k in QA pipeline
In the Hugging Face QA pipeline, what happens if you set the parameter top_k=3 when calling the pipeline?
Attempts:
2 left
💡 Hint
top_k controls how many answers the model returns.
✗ Incorrect
Setting top_k=3 makes the pipeline return the three best answers ranked by confidence.
❓ Metrics
advanced2:00remaining
Evaluating QA model performance
Which metric is commonly used to evaluate the accuracy of a question-answering model on datasets like SQuAD?
Attempts:
2 left
💡 Hint
This metric measures if the predicted answer exactly matches the ground truth.
✗ Incorrect
Exact Match (EM) measures the percentage of predictions that exactly match the correct answers.
🔧 Debug
expert2:00remaining
Debugging a QA pipeline error
You run this code but get a TypeError: 'NoneType' object is not subscriptable. What is the cause?
from transformers import pipeline
qa = pipeline('question-answering')
context = None
question = "What is AI?"
result = qa(question=question, context=context)
print(result['answer'])
Attempts:
2 left
💡 Hint
Check the input types passed to the pipeline.
✗ Incorrect
The context is None, so the pipeline returns None, causing the TypeError when trying to access ['answer'].