0
0
NLPml~10 mins

Answer span extraction 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 extract the start index of the answer span from model outputs.

NLP
start_index = outputs.start_logits.[1]()
Drag options to blanks, or click blank then click option'
Amax
Bargmax
Csum
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Using max() returns the value, not the index.
Using sum() or mean() does not give the position.
2fill in blank
medium

Complete the code to extract the answer text from the context using predicted start and end indices.

NLP
answer = context[[1]:end_index + 1]
Drag options to blanks, or click blank then click option'
Astart_index
Boutputs.start_logits
Cend_index
Doutputs.end_logits
Attempts:
3 left
💡 Hint
Common Mistakes
Using logits instead of indices.
Using end_index as the start of the slice.
3fill in blank
hard

Fix the error in the code to correctly compute the end index of the answer span.

NLP
end_index = outputs.end_logits.[1]()
Drag options to blanks, or click blank then click option'
Aargmax
Bmax
Cmin
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using max() returns the value, not the index.
Using min() or sum() is incorrect for this purpose.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps tokens to their indices for tokens longer than 3 characters.

NLP
{ [2]: [1] for [1], [2] in enumerate(tokens) if len([2]) > 3 }
Drag options to blanks, or click blank then click option'
Aindex
Btoken
Ci
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'i' instead of 'index' for the value.
Using 'word' instead of 'token' in the loop.
5fill in blank
hard

Fill all three blanks to create a dictionary of token lengths for tokens starting with a vowel.

NLP
{ [1]: len([2]) for [3] in tokens if [2][0].lower() in 'aeiou' }
Drag options to blanks, or click blank then click option'
Atoken
Bword
Cw
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing variable names in keys and values.
Using different variable names inconsistently.