0
0
NLPml~10 mins

Open-domain QA basics in NLP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Aquestion-answering
Btext-generation
Csentiment-analysis
Dtranslation
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text-generation' instead of 'question-answering'.
Confusing sentiment analysis with question answering.
2fill in blank
medium

Complete 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'
AWhen was the Eiffel Tower built?
BWhat is the capital of France?
CWhere is the Eiffel Tower?
DWho built the Eiffel Tower?
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.
3fill in blank
hard

Fix 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'
Atext
Banswer
Cresponse
Dresult
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.
4fill in blank
hard

Fill 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'
Aquestion
Banswer
Ccontext
Dresponse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'answer' or 'response' as keys instead of 'question' and 'context'.
Mixing up the order of keys.
5fill in blank
hard

Fill 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'
Aquestion
BWhat is Python?
Ccontext
Danswer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'answer' as a key in the input dictionary.
Putting the question in the 'context' key.