0
0
NLPml~20 mins

Answer span extraction in NLP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Answer Span Extraction Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the main goal of answer span extraction in NLP?

In simple terms, what does answer span extraction try to do when given a question and a paragraph?

AFind the exact part of the paragraph that answers the question
BGenerate a new answer unrelated to the paragraph
CSummarize the entire paragraph without focusing on the question
DTranslate the paragraph into another language
Attempts:
2 left
💡 Hint

Think about pointing to a specific piece of text that answers the question.

Predict Output
intermediate
2:00remaining
What is the output of this answer span extraction code snippet?

Given the paragraph and question, what answer span does the model predict?

NLP
paragraph = 'The Eiffel Tower is located in Paris and is one of the most famous landmarks.'
question = 'Where is the Eiffel Tower located?'

# Simulated model output (start and end indices)
start_index = 5
end_index = 6

answer_tokens = paragraph.split()[start_index:end_index+1]
answer = ' '.join(answer_tokens)
print(answer)
Ain Paris
Blocated in Paris
CParis and is
DThe Eiffel Tower
Attempts:
2 left
💡 Hint

Look at the words between indices 5 and 6 in the paragraph split by spaces.

Model Choice
advanced
2:00remaining
Which model architecture is best suited for answer span extraction tasks?

Choose the model type that is designed to predict start and end positions of answers in a paragraph.

ASequence-to-sequence model generating answers word by word
BTransformer-based model with token classification heads for start and end positions
CUnsupervised clustering model grouping similar sentences
DGenerative adversarial network creating new paragraphs
Attempts:
2 left
💡 Hint

Think about models that output positions rather than generating text.

Metrics
advanced
1:30remaining
Which metric best evaluates answer span extraction accuracy?

When checking if the predicted answer span matches the true answer span, which metric is most appropriate?

ABLEU score measuring n-gram overlap
BMean Squared Error between token embeddings
CExact Match (EM) score checking exact span equality
DPerplexity measuring language model uncertainty
Attempts:
2 left
💡 Hint

Think about a metric that checks if the predicted answer is exactly the same as the true answer.

🔧 Debug
expert
2:00remaining
Why does this answer span extraction code produce an empty answer?

Consider this code snippet that tries to extract an answer span but returns an empty string. What is the most likely cause?

NLP
paragraph = 'Machine learning helps computers learn from data.'
start_index = 7
end_index = 5

answer_tokens = paragraph.split()[start_index:end_index+1]
answer = ' '.join(answer_tokens)
print(answer)
AThe split method is called incorrectly without parentheses
BThe paragraph string is empty, so no tokens exist
CThe join method is used on a string instead of a list
Dstart_index is greater than end_index, so the slice is empty
Attempts:
2 left
💡 Hint

Check the order of start and end indices in the slice.