Unverified Commit fd2bed7f authored by Steven Liu's avatar Steven Liu Committed by GitHub
Browse files

Clarify return_tensor and return_text parameters (#20662)

* clarify docstring

* make style
parent c1b9a11d
...@@ -170,11 +170,12 @@ class TextGenerationPipeline(Pipeline): ...@@ -170,11 +170,12 @@ class TextGenerationPipeline(Pipeline):
args (`str` or `List[str]`): args (`str` or `List[str]`):
One or several prompts (or one list of prompts) to complete. One or several prompts (or one list of prompts) to complete.
return_tensors (`bool`, *optional*, defaults to `False`): return_tensors (`bool`, *optional*, defaults to `False`):
Whether or not to include the tensors of predictions (as token indices) in the outputs. Whether or not to return the tensors of predictions (as token indices) in the outputs. If set to
`True`, the decoded text is not returned.
return_text (`bool`, *optional*, defaults to `True`): return_text (`bool`, *optional*, defaults to `True`):
Whether or not to include the decoded texts in the outputs. Whether or not to return the decoded texts in the outputs.
return_full_text (`bool`, *optional*, defaults to `True`): return_full_text (`bool`, *optional*, defaults to `True`):
If set to `False` only added text is returned, otherwise the full text is returned Only meaningful if If set to `False` only added text is returned, otherwise the full text is returned. Only meaningful if
*return_text* is set to True. *return_text* is set to True.
clean_up_tokenization_spaces (`bool`, *optional*, defaults to `False`): clean_up_tokenization_spaces (`bool`, *optional*, defaults to `False`):
Whether or not to clean up the potential extra spaces in the text output. Whether or not to clean up the potential extra spaces in the text output.
...@@ -195,7 +196,8 @@ class TextGenerationPipeline(Pipeline): ...@@ -195,7 +196,8 @@ class TextGenerationPipeline(Pipeline):
corresponding to your framework [here](./model#generative-models)). corresponding to your framework [here](./model#generative-models)).
Return: Return:
A list or a list of list of `dict`: Each result comes as a dictionary with the following keys: A list or a list of list of `dict`: Returns one of the following dictionaries (cannot return a combination
of both `generated_text` and `generated_token_ids`):
- **generated_text** (`str`, present when `return_text=True`) -- The generated text. - **generated_text** (`str`, present when `return_text=True`) -- The generated text.
- **generated_token_ids** (`torch.Tensor` or `tf.Tensor`, present when `return_tensors=True`) -- The token - **generated_token_ids** (`torch.Tensor` or `tf.Tensor`, present when `return_tensors=True`) -- The token
......
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