From dcc9c6429947e6994384908a6abd4bb5e2780a98 Mon Sep 17 00:00:00 2001 From: cronoik Date: Thu, 19 Nov 2020 00:56:47 +0100 Subject: [PATCH] Updated the Extractive Question Answering code snippets (#8636) * Updated the Extractive Question Answering code snippets The Extractive Question Answering code snippets do not work anymore since the models return task-specific output objects. This commit fixes the pytorch and tensorflow examples but adding `.values()` to the model call. * Update task_summary.rst --- docs/source/task_summary.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/source/task_summary.rst b/docs/source/task_summary.rst index 2f0f8336c3..0ee7609bee 100644 --- a/docs/source/task_summary.rst +++ b/docs/source/task_summary.rst @@ -231,7 +231,9 @@ Here is an example of question answering using a model and a tokenizer. The proc ... input_ids = inputs["input_ids"].tolist()[0] ... ... text_tokens = tokenizer.convert_ids_to_tokens(input_ids) - ... answer_start_scores, answer_end_scores = model(**inputs) + ... outputs = model(**inputs) + ... answer_start_scores = outputs.start_logits + ... answer_end_scores = outputs.end_logits ... ... answer_start = torch.argmax( ... answer_start_scores @@ -273,7 +275,9 @@ Here is an example of question answering using a model and a tokenizer. The proc ... input_ids = inputs["input_ids"].numpy()[0] ... ... text_tokens = tokenizer.convert_ids_to_tokens(input_ids) - ... answer_start_scores, answer_end_scores = model(inputs) + ... outputs = model(inputs) + ... answer_start_scores = outputs.start_logits + ... answer_end_scores = outputs.end_logits ... ... answer_start = tf.argmax( ... answer_start_scores, axis=1