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
This commit is contained in:
@@ -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
|
|||||||
... 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
|
||||||
|
|||||||
Reference in New Issue
Block a user