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
fd2bed7f
Unverified
Commit
fd2bed7f
authored
Dec 12, 2022
by
Steven Liu
Committed by
GitHub
Dec 12, 2022
Browse files
Clarify return_tensor and return_text parameters (#20662)
* clarify docstring * make style
parent
c1b9a11d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
src/transformers/pipelines/text_generation.py
src/transformers/pipelines/text_generation.py
+6
-4
No files found.
src/transformers/pipelines/text_generation.py
View file @
fd2bed7f
...
@@ -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
...
...
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