Complete the code to extract the start index of the answer span from model outputs.
start_index = outputs.start_logits.[1]()The argmax function returns the index of the highest value, which corresponds to the predicted start position of the answer span.
Complete the code to extract the answer text from the context using predicted start and end indices.
answer = context[[1]:end_index + 1]
The answer span is extracted from the context starting at start_index up to end_index inclusive.
Fix the error in the code to correctly compute the end index of the answer span.
end_index = outputs.end_logits.[1]()Using argmax returns the index of the highest end logit, which is the predicted end position of the answer span.
Fill both blanks to create a dictionary comprehension that maps tokens to their indices for tokens longer than 3 characters.
{ [2]: [1] for [1], [2] in enumerate(tokens) if len([2]) > 3 }The dictionary comprehension maps each token to its index. The loop variable is token from enumerate(tokens).
Fill all three blanks to create a dictionary of token lengths for tokens starting with a vowel.
{ [1]: len([2]) for [3] in tokens if [2][0].lower() in 'aeiou' }The dictionary comprehension uses token as the key and calculates the length of token. The loop variable is also token.