From e21fc9ccfd3f74cd7c7f822c2e0fc85c6213477d Mon Sep 17 00:00:00 2001 From: MKhalusova Date: Thu, 28 Sep 2023 12:09:42 -0400 Subject: [PATCH 1/2] navigation improvement between text generation pipelines and text generation docs --- docs/source/en/generation_strategies.md | 3 ++- src/transformers/pipelines/text2text_generation.py | 6 ++++-- src/transformers/pipelines/text_generation.py | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/source/en/generation_strategies.md b/docs/source/en/generation_strategies.md index 44fd6623040562..51f92e0610322d 100644 --- a/docs/source/en/generation_strategies.md +++ b/docs/source/en/generation_strategies.md @@ -82,7 +82,8 @@ Even if the default decoding strategy mostly works for your task, you can still commonly adjusted parameters include: - `max_new_tokens`: the maximum number of tokens to generate. In other words, the size of the output sequence, not -including the tokens in the prompt. +including the tokens in the prompt. As an alternative to using the output's length as a stopping criteria, you can choose +to stop generation whenever the full generation exceeds some amount of time. To learn more, check [`StoppingCriteria`]. - `num_beams`: by specifying a number of beams higher than 1, you are effectively switching from greedy search to beam search. This strategy evaluates several hypotheses at each time step and eventually chooses the hypothesis that has the overall highest probability for the entire sequence. This has the advantage of identifying high-probability diff --git a/src/transformers/pipelines/text2text_generation.py b/src/transformers/pipelines/text2text_generation.py index 39d4c3a59105ee..d937d1b6c841dd 100644 --- a/src/transformers/pipelines/text2text_generation.py +++ b/src/transformers/pipelines/text2text_generation.py @@ -39,8 +39,10 @@ class Text2TextGenerationPipeline(Pipeline): [{'generated_text': 'question: Who created the RuPERTa-base?'}] ``` - Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial) - + Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial). + You can pass text generation parameters to this pipeline to control stopping criteria, decoding strategy, and more. + Learn more about text generation parameters in [Text generation strategies](../generation_strategies) and + [Text generation](text_generation). This Text2TextGenerationPipeline pipeline can currently be loaded from [`pipeline`] using the following task identifier: `"text2text-generation"`. diff --git a/src/transformers/pipelines/text_generation.py b/src/transformers/pipelines/text_generation.py index 79da7ce31050d5..6479222a75d9c9 100644 --- a/src/transformers/pipelines/text_generation.py +++ b/src/transformers/pipelines/text_generation.py @@ -39,7 +39,10 @@ class TextGenerationPipeline(Pipeline): >>> 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) + Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial). + You can pass text generation parameters to this pipeline to control stopping criteria, decoding strategy, and more. + Learn more about text generation parameters in [Text generation strategies](../generation_strategies) and + [Text generation](text_generation). This language generation pipeline can currently be loaded from [`pipeline`] using the following task identifier: `"text-generation"`. From a70d7683883f37694b630e66250e5a36c5a9fc85 Mon Sep 17 00:00:00 2001 From: MKhalusova Date: Thu, 28 Sep 2023 12:35:51 -0400 Subject: [PATCH 2/2] make style --- src/transformers/pipelines/text2text_generation.py | 8 ++++---- src/transformers/pipelines/text_generation.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/transformers/pipelines/text2text_generation.py b/src/transformers/pipelines/text2text_generation.py index d937d1b6c841dd..5b9ce06832da64 100644 --- a/src/transformers/pipelines/text2text_generation.py +++ b/src/transformers/pipelines/text2text_generation.py @@ -39,10 +39,10 @@ class Text2TextGenerationPipeline(Pipeline): [{'generated_text': 'question: Who created the RuPERTa-base?'}] ``` - Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial). - You can pass text generation parameters to this pipeline to control stopping criteria, decoding strategy, and more. - Learn more about text generation parameters in [Text generation strategies](../generation_strategies) and - [Text generation](text_generation). + Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial). You can pass text + generation parameters to this pipeline to control stopping criteria, decoding strategy, and more. Learn more about + text generation parameters in [Text generation strategies](../generation_strategies) and [Text + generation](text_generation). This Text2TextGenerationPipeline pipeline can currently be loaded from [`pipeline`] using the following task identifier: `"text2text-generation"`. diff --git a/src/transformers/pipelines/text_generation.py b/src/transformers/pipelines/text_generation.py index 6479222a75d9c9..109971d8ac85a9 100644 --- a/src/transformers/pipelines/text_generation.py +++ b/src/transformers/pipelines/text_generation.py @@ -39,10 +39,10 @@ class TextGenerationPipeline(Pipeline): >>> 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). - You can pass text generation parameters to this pipeline to control stopping criteria, decoding strategy, and more. - Learn more about text generation parameters in [Text generation strategies](../generation_strategies) and - [Text generation](text_generation). + Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial). You can pass text + generation parameters to this pipeline to control stopping criteria, decoding strategy, and more. Learn more about + text generation parameters in [Text generation strategies](../generation_strategies) and [Text + generation](text_generation). This language generation pipeline can currently be loaded from [`pipeline`] using the following task identifier: `"text-generation"`.