Adding doctest for question-answering pipeline. (#20259)

* Adding doctest for `question-answering` pipeline.

* Remove nested simplify.
This commit is contained in:
Nicolas Patry 2022-11-16 17:16:19 +01:00 committed by GitHub
parent d9efb36cf6
commit 9accbe531e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -226,6 +226,18 @@ class QuestionAnsweringPipeline(ChunkPipeline):
Question Answering pipeline using any `ModelForQuestionAnswering`. See the [question answering Question Answering pipeline using any `ModelForQuestionAnswering`. See the [question answering
examples](../task_summary#question-answering) for more information. examples](../task_summary#question-answering) for more information.
Example:
```python
>>> from transformers import pipeline
>>> oracle = pipeline(model="deepset/roberta-base-squad2")
>>> oracle(question="Where do I live?", context="My name is Wolfgang and I live in Berlin")
{'score': 0.9191, 'start': 34, 'end': 40, 'answer': 'Berlin'}
```
[Learn more about the basics of using a pipeline in the [pipeline tutorial]](../pipeline_tutorial)
This question answering pipeline can currently be loaded from [`pipeline`] using the following task identifier: This question answering pipeline can currently be loaded from [`pipeline`] using the following task identifier:
`"question-answering"`. `"question-answering"`.