"...git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "d5363df46f13054ad327ffb761debdec6a058fa0"
Unverified Commit e4aaa458 authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Update pipeline examples to doctest syntax (#5030)

parent 011cc0be
...@@ -538,20 +538,21 @@ You can create `Pipeline` objects for the following down-stream tasks: ...@@ -538,20 +538,21 @@ You can create `Pipeline` objects for the following down-stream tasks:
- `translation_xx_to_yy` - `translation_xx_to_yy`
```python ```python
from transformers import pipeline >>> from transformers import pipeline
# Allocate a pipeline for sentiment-analysis # Allocate a pipeline for sentiment-analysis
nlp = pipeline('sentiment-analysis') >>> nlp = pipeline('sentiment-analysis')
nlp('We are very happy to include pipeline into the transformers repository.') >>> nlp('We are very happy to include pipeline into the transformers repository.')
>>> {'label': 'POSITIVE', 'score': 0.99893874} [{'label': 'POSITIVE', 'score': 0.9978193640708923}]
# Allocate a pipeline for question-answering # Allocate a pipeline for question-answering
nlp = pipeline('question-answering') >>> nlp = pipeline('question-answering')
nlp({ >>> nlp({
'question': 'What is the name of the repository ?', ... 'question': 'What is the name of the repository ?',
'context': 'Pipeline have been included in the huggingface/transformers repository' ... 'context': 'Pipeline have been included in the huggingface/transformers repository'
}) ... })
>>> {'score': 0.28756016668193496, 'start': 35, 'end': 59, 'answer': 'huggingface/transformers'} {'score': 0.5135612454720828, 'start': 35, 'end': 59, 'answer': 'huggingface/transformers'}
``` ```
## Migrating from pytorch-transformers to transformers ## Migrating from pytorch-transformers to transformers
......
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