Closed ayaka14732 closed 2 years ago
Hi @ayaka14732 👋 That happens because the stopping conditions take precedence over anything else. The default for max_length
is 20
, so that's why you see 20 generated tokens. In your example, if you rewrite the generate line into generate_ids = model.generate(inputs.input_ids, num_beams=5, min_length=50, max_length=100)
, you'll get the results you expect.
@patrickvonplaten @patil-suraj should we raise an exception in this case? (min_length
> max_length
)
@gante, yes this would work for me! Let's maybe do this in generate()
before we just into the sub-generation methods
@ayaka14732 if you pull from master (or install transformers==4.19.0.dev0
), you shall see an informative Exception if you try to run your original script.
Thank you for reporting this issue :D
Environment info
transformers
version: 4.18.0.dev0Who can help
@patil-suraj @patrickvonplaten
Information
Model I am using: BART
To reproduce
Steps to reproduce the behavior:
Output:
Expected behavior
The output should not be truncated.
Actual behavior
The output is truncated.
Note that the output is truncated even if
min_length=50
is specified.