Tensorflow version (GPU?): I am not using tensorflow
Using GPU in script?: Yes
Using distributed or parallel set-up in script?: No
Who can help
@patil-suraj @patrickvonplaten @sgugger
Information
Model I am using (Bert, XLNet ...): T5
The problem arises when using:
[ ] the official example scripts: (give details below)
[ ] my own modified scripts: (give details below)
The tasks I am working on is:
[ ] an official GLUE/SQUaD task: (give the name)
[ ] my own task or dataset: (give details below)
To reproduce
I have fine-tuned a T5-small model for key-phrase extraction with the Trainer API by passing it an input paragraph and training it to output the same paragraph, but with the key-phrases surrounded in ‘|||’ (ex. |||George Washington||| was a president and ....). However, when I try to make a prediction with the model, the output always contains exactly 20 tokens, and as a result, the output is cut-off mid sentence. When tokenizing the training, validation, and testing sets, I set the max_length parameter to 512. I do not not know why every single output is only 20 tokens. (My input data is much longer). Aside from the output being chopped off, the model seems to be fine (the '|||' is showing up in some of the predicted outputs despite the output length being only 20).
Steps to reproduce the behavior:
The function I use to tokenize my custom dataset (this is not using the HuggingFace Dataset class):
The output from the last line is always 20, no matter with sample I use from val_mapping.
EDIT
After looking at this issue on the HuggingFace forum I found out that my mymod.config.max_length was 20. After manually reassigning this value to 512, my problem was solved. However, I still have know idea why this was 20 in the first place (I didn't add this). Feel free to close this issue. I only leave it open so that the general issue could be addressed.
The default max_length for generate is set to 20. The max_length really depends on the task/problem, so it should be set either in config or passed to generate.
Environment info
transformers
version: 4.10.0Who can help
@patil-suraj @patrickvonplaten @sgugger
Information
Model I am using (Bert, XLNet ...): T5
The problem arises when using:
The tasks I am working on is:
To reproduce
I have fine-tuned a T5-small model for key-phrase extraction with the Trainer API by passing it an input paragraph and training it to output the same paragraph, but with the key-phrases surrounded in ‘|||’ (ex. |||George Washington||| was a president and ....). However, when I try to make a prediction with the model, the output always contains exactly 20 tokens, and as a result, the output is cut-off mid sentence. When tokenizing the training, validation, and testing sets, I set the
max_length
parameter to 512. I do not not know why every single output is only 20 tokens. (My input data is much longer). Aside from the output being chopped off, the model seems to be fine (the '|||' is showing up in some of the predicted outputs despite the output length being only 20).Steps to reproduce the behavior:
The function I use to tokenize my custom dataset (this is not using the HuggingFace Dataset class):
This is my code to train the model:
The output from the last line is always 20, no matter with sample I use from
val_mapping
.EDIT
After looking at this issue on the HuggingFace forum I found out that my
mymod.config.max_length
was 20. After manually reassigning this value to 512, my problem was solved. However, I still have know idea why this was 20 in the first place (I didn't add this). Feel free to close this issue. I only leave it open so that the general issue could be addressed.