Complete the code to extract the answer from the model's output.
answer = model.predict(question, context).[1]()The decode() method converts the model's output tokens into a readable string answer.
Complete the code to tokenize the input question for the QA system.
inputs = tokenizer.[1](question, return_tensors='pt')
The encode() method converts the question text into tokens the model can understand.
Fix the error in the code to get the start position of the answer.
start_pos = outputs.start_logits.[1](dim=1).argmax()
The softmax() function converts logits to probabilities before finding the max index.
Fill both blanks to extract the answer text from tokens.
answer_tokens = inputs.input_ids[0][[1]:[2]] answer = tokenizer.decode(answer_tokens)
We slice tokens from start_pos to end_pos to get the answer span.
Fill all three blanks to prepare inputs and get the answer from the QA model.
inputs = tokenizer.[1](question, context, return_tensors='pt') outputs = model(**inputs) start_pos = outputs.start_logits.[2](dim=1).argmax() end_pos = outputs.end_logits.[3](dim=1).argmax()
We encode inputs, then apply softmax to logits before argmax to find answer positions.
