Update pipeline examples to doctest syntax (#5030)
This commit is contained in:
21
README.md
21
README.md
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user