From e4aaa4580515446cd5a2972ab42fec0b95819c84 Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Tue, 16 Jun 2020 18:14:58 -0400 Subject: [PATCH] Update pipeline examples to doctest syntax (#5030) --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8dfe0c86ac..74e329679f 100644 --- a/README.md +++ b/README.md @@ -538,20 +538,21 @@ You can create `Pipeline` objects for the following down-stream tasks: - `translation_xx_to_yy` ```python -from transformers import pipeline +>>> from transformers import pipeline # Allocate a pipeline for sentiment-analysis -nlp = pipeline('sentiment-analysis') -nlp('We are very happy to include pipeline into the transformers repository.') ->>> {'label': 'POSITIVE', 'score': 0.99893874} +>>> nlp = pipeline('sentiment-analysis') +>>> nlp('We are very happy to include pipeline into the transformers repository.') +[{'label': 'POSITIVE', 'score': 0.9978193640708923}] # Allocate a pipeline for question-answering -nlp = pipeline('question-answering') -nlp({ - 'question': 'What is the name of the repository ?', - 'context': 'Pipeline have been included in the huggingface/transformers repository' -}) ->>> {'score': 0.28756016668193496, 'start': 35, 'end': 59, 'answer': 'huggingface/transformers'} +>>> nlp = pipeline('question-answering') +>>> nlp({ +... 'question': 'What is the name of the repository ?', +... 'context': 'Pipeline have been included in the huggingface/transformers repository' +... }) +{'score': 0.5135612454720828, 'start': 35, 'end': 59, 'answer': 'huggingface/transformers'} + ``` ## Migrating from pytorch-transformers to transformers