Unverified Commit dcc9c642 authored by cronoik's avatar cronoik Committed by GitHub
Browse files

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
parent 28d16e7a
...@@ -231,7 +231,9 @@ Here is an example of question answering using a model and a tokenizer. The proc ...@@ -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] ... input_ids = inputs["input_ids"].tolist()[0]
... ...
... text_tokens = tokenizer.convert_ids_to_tokens(input_ids) ... 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 = torch.argmax(
... answer_start_scores ... answer_start_scores
...@@ -273,7 +275,9 @@ Here is an example of question answering using a model and a tokenizer. The proc ...@@ -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] ... input_ids = inputs["input_ids"].numpy()[0]
... ...
... text_tokens = tokenizer.convert_ids_to_tokens(input_ids) ... 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 = tf.argmax(
... answer_start_scores, axis=1 ... answer_start_scores, axis=1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment