Unverified Commit 5ca479d2 authored by Nicolas Patry's avatar Nicolas Patry Committed by GitHub
Browse files

Adding doctest for `text-generation` pipeline. (#20264)

parent 449f2ae4
...@@ -23,6 +23,21 @@ class TextGenerationPipeline(Pipeline): ...@@ -23,6 +23,21 @@ class TextGenerationPipeline(Pipeline):
Language generation pipeline using any `ModelWithLMHead`. This pipeline predicts the words that will follow a Language generation pipeline using any `ModelWithLMHead`. This pipeline predicts the words that will follow a
specified text prompt. specified text prompt.
Example:
```python
>>> from transformers import pipeline
>>> generator = pipeline(model="gpt2")
>>> generator("I can't believe you did such a ", do_sample=False)
[{'generated_text': "I can't believe you did such a icky thing to me. I'm so sorry. I'm so sorry. I'm so sorry. I'm so sorry. I'm so sorry. I'm so sorry. I'm so sorry. I"}]
>>> # These parameters will return suggestions, and only the newly created text making it easier for prompting suggestions.
>>> outputs = generator("My tart needs some", num_return_sequences=4, return_full_text=False)
```
[Learn more about the basics of using a pipeline in the [pipeline tutorial]](../pipeline_tutorial)
This language generation pipeline can currently be loaded from [`pipeline`] using the following task identifier: This language generation pipeline can currently be loaded from [`pipeline`] using the following task identifier:
`"text-generation"`. `"text-generation"`.
......
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