return_tensors and return_text in TextGenerationPipeline don't work or partially work
See original GitHub issueSystem Info
- transformers version: 4.24.0
- python version: 3.8.11
Who can help?
Library:
- Text generation: @patrickvonplaten, @Narsil, @gante
- Pipelines: @Narsil
Documentation: @sgugger, @stevhliu
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examples
folder (such as GLUE/SQuAD, …) - My own task or dataset (give details below)
Reproduction
- initialize TextGenerationPipeline, assume we call it
pipeline
below - run the following code snips:
results = pipeline(text_input, return_text=True, return_full_text=False, return_tensors=False)[0]
results = pipeline(text_input, return_text=True, return_full_text=False, return_tensors=True)[0]
results = pipeline(text_input, return_text=False, return_full_text=False, return_tensors=True)[0]
results = pipeline(text_input, return_text=False, return_full_text=False, return_tensors=False)[0]
- all the four code snips return the same dict with only one key
generated_text
Expected behavior
- when
return_text=True
andreturn_tensors=False
, return a dict contains only one keygenerated_text
- when
return_text=False
andreturn_tensors=True
, return a dict contains only one keygenerated_token_ids
- when
return_text=True
andreturn_tensors=True
, return a dict contains bothgenerated_text
andgenerated_token_ids
Issue Analytics
- State:
- Created 9 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Pipelines - Hugging Face
This pipeline only works for inputs with exactly one token masked. Experimental: We added support for multiple masks. The returned values are raw...
Read more >Text Generation with HuggingFace - GPT2 | Kaggle
This project is a work in progress and I will continually update it as I learn more ... GPT2Tokenizer #get large GPT2 tokenizer...
Read more >Mudit Rustagi, Author at Analytics India Magazine
Ideally, we would want to collect every possible review and work with that. However, in the real world, data is often limited.
Read more >Hugging Face Transformers Pipeline Functions | Advanced NLP
Advanced Deep Learning NLP. This article was published as a part of the Data Science Blogathon. ... Let's build a text generation pipeline....
Read more >v1.0.5 PDF - BentoML
Integrations & Ecosystem Learn how BentoML works together with other tools ... responsible for building and training the model, often don't.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes the docs could use some polish here, maybe even soft deprecate
return_text
& co in favor ofreturn_type
. Soft deprecate meaning we don’t ever have to actually remove them, just don’t make them as prominent since they are indeed confusing.@stevhliu thanks for the replying! Now I’m clear with the functionality and relationship between
return_text
andreturn_tensors
, and I think it would be clear to more people if the documentation also target this out. 😄