Skip to content

Commit dcc9c64

Browse files
authored
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
1 parent 28d16e7 commit dcc9c64

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

docs/source/task_summary.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ Here is an example of question answering using a model and a tokenizer. The proc
231231
... input_ids = inputs["input_ids"].tolist()[0]
232232
...
233233
... text_tokens = tokenizer.convert_ids_to_tokens(input_ids)
234-
... answer_start_scores, answer_end_scores = model(**inputs)
234+
... outputs = model(**inputs)
235+
... answer_start_scores = outputs.start_logits
236+
... answer_end_scores = outputs.end_logits
235237
...
236238
... answer_start = torch.argmax(
237239
... answer_start_scores
@@ -273,7 +275,9 @@ Here is an example of question answering using a model and a tokenizer. The proc
273275
... input_ids = inputs["input_ids"].numpy()[0]
274276
...
275277
... text_tokens = tokenizer.convert_ids_to_tokens(input_ids)
276-
... answer_start_scores, answer_end_scores = model(inputs)
278+
... outputs = model(inputs)
279+
... answer_start_scores = outputs.start_logits
280+
... answer_end_scores = outputs.end_logits
277281
...
278282
... answer_start = tf.argmax(
279283
... answer_start_scores, axis=1

0 commit comments

Comments
 (0)