Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a pre-trained question answering model using Hugging Face Transformers.
NLP
from transformers import pipeline qa_pipeline = pipeline('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text-generation' instead of 'question-answering'.
Confusing sentiment analysis with question answering.
✗ Incorrect
The pipeline type for open-domain question answering is 'question-answering'.
2fill in blank
mediumComplete the code to get the answer from the QA pipeline given a question and context.
NLP
result = qa_pipeline({'question': '[1]', 'context': 'The Eiffel Tower is in Paris.'}) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Asking about the builder or date which is not in the context.
Using a question unrelated to the context.
✗ Incorrect
The question 'Where is the Eiffel Tower?' matches the context about the Eiffel Tower's location.
3fill in blank
hardFix the error in the code to extract the answer text from the result dictionary.
NLP
answer_text = result['[1]']
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text' or 'response' which are not keys in the result.
Trying to access 'result' key inside the result dictionary.
✗ Incorrect
The key 'answer' contains the predicted answer text in the result dictionary.
4fill in blank
hardFill both blanks to create a dictionary with question and context for the QA pipeline.
NLP
input_data = {'[1]': 'What is AI?', '[2]': 'AI stands for Artificial Intelligence.'} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'answer' or 'response' as keys instead of 'question' and 'context'.
Mixing up the order of keys.
✗ Incorrect
The QA pipeline expects keys 'question' and 'context' in the input dictionary.
5fill in blank
hardFill all three blanks to run the QA pipeline and print the answer.
NLP
result = qa_pipeline({'[1]': '[2]', '[3]': 'Python is a programming language.'})
print(result['answer']) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'answer' as a key in the input dictionary.
Putting the question in the 'context' key.
✗ Incorrect
The input dictionary keys are 'question' and 'context', and the question is 'What is Python?'.