0
0
Prompt Engineering / GenAIml~20 mins

Question answering in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Question Answering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
What is the main purpose of a question answering system?

Choose the best description of what a question answering system does.

AIt predicts numerical values based on historical data.
BIt generates answers to questions by understanding and processing natural language input.
CIt translates text from one language to another without understanding the meaning.
DIt classifies images into categories based on their content.
Attempts:
2 left
💡 Hint

Think about what happens when you ask a smart assistant a question.

Predict Output
intermediate
1:30remaining
Output of a simple QA model prediction

Given the following code snippet using a pretrained QA model, what will be the printed answer?

Prompt Engineering / GenAI
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'])
A"located"
B"Eiffel Tower"
C"The Eiffel Tower"
D"Paris"
Attempts:
2 left
💡 Hint

The model extracts the answer from the context that best fits the question.

Model Choice
advanced
2:00remaining
Choosing the best model type for open-domain QA

You want to build a system that answers questions about any topic using a large collection of documents. Which model type is best suited?

AA retrieval-augmented generation model that first finds relevant documents then generates answers.
BA simple text classification model that labels questions into categories.
CA convolutional neural network trained on images.
DA clustering algorithm that groups similar questions.
Attempts:
2 left
💡 Hint

Think about how to handle large knowledge bases and generate answers.

Metrics
advanced
2:00remaining
Evaluating a QA model with Exact Match and F1 score

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?

AExact Match: 0, F1: 0.67
BExact Match: 1, F1: 1
CExact Match: 0, F1: 0
DExact Match: 1, F1: 0.5
Attempts:
2 left
💡 Hint

Exact Match requires exact string equality; F1 measures overlap of tokens.

🔧 Debug
expert
2:00remaining
Why does this QA model code raise an error?

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?

ABecause the pipeline is not initialized, it raises an ImportError.
BBecause the question is missing, the model raises a ValueError.
CBecause the context is None, the model cannot process it and raises a TypeError.
DBecause the print statement is incorrect syntax, it raises a SyntaxError.
Attempts:
2 left
💡 Hint

Check the type and value of the context variable passed to the model.