Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
e4aaa458
"...git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "d5363df46f13054ad327ffb761debdec6a058fa0"
Unverified
Commit
e4aaa458
authored
Jun 16, 2020
by
Sylvain Gugger
Committed by
GitHub
Jun 16, 2020
Browse files
Update pipeline examples to doctest syntax (#5030)
parent
011cc0be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
README.md
README.md
+11
-10
No files found.
README.md
View file @
e4aaa458
...
@@ -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.99
893874
}
[
{
'label'
:
'POSITIVE'
,
'score'
:
0.99
78193640708923
}]
# 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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment