question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[examples] UserWarning: `max_length` is deprecated

See original GitHub issue

Not sure how many example scripts are affected by this:

src/transformers/generation_utils.py:963: UserWarning: `max_length` is deprecated in this function, use 
`stopping_criteria=StoppingCriteriaList(MaxLengthCriteria(max_length=max_length))` instead.

getting this with at least examples/pytorch/translation/run_translation.py

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Narsilcommented, May 3, 2021

Hi @stas00 ,

Yes, it’s my fault 1 deprecation too much on the generate function ! Just submitted a new PR to remove this extra warnings (which is incorrect).

max_length is used by generate but not by the subsequent functions.

1reaction
stas00commented, May 3, 2021

Thank you for this investigation, @bhadreshpsavani - that’s very helpful. It looks like the change was introduced just a day before I filed this Issue.

@Narsil, could we please check with you on this deprecation you introduced in https://github.com/huggingface/transformers/commit/aad95c7cdebc24e780e5a5cf39d832c015e40075

  1. Unless I’m missing something the deprecation doesn’t seem to be complete since max_length is actively used in the same function:

https://github.com/huggingface/transformers/blob/4e7bf94e7280d2b725ac4644dbe9808560afa5d8/src/transformers/generation_utils.py#L919

I am not sure how a deprecated variable is still used normally in the logic…

Also it’s not documented as deprecated:

            max_length (:obj:`int`, `optional`, defaults to 20):
                The maximum length of the sequence to be generated.
  1. it now generates warnings in the example scripts like run_translation.py and run_summarization.py - so if there is a new way could we please atomically adjust all the places that are now impacted by this change? The examples ideally should be in sync with API changes, since their purpose is to correctly demonstrate how to use the library.

The main entry point leading to this warning in seq2seq examples is:

https://github.com/huggingface/transformers/blob/4e7bf94e7280d2b725ac4644dbe9808560afa5d8/src/transformers/trainer_seq2seq.py#L161-L171

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

max_length and stopping_criteria in generate() #17718 - GitHub
Accordingly, when you pass max_length you get the deprecated warning, which is ok - however, it recommends using the StoppingCriteriaList ...
Read more >
How does max_length, padding and truncation arguments ...
padding=max_length will add a padding of 1 to the third sentence; truncate=True will truncate the first and second sentence so that their length ......
Read more >
2101 (maxlength should be max_length) - Django's bug tracker
My personal recommendation would be to add the "max_length" parameter without removing "maxlength." This way, backwards-compatibility can be maintained while ...
Read more >
Configuration options for isort
The max length of an import line (used for wrapping long imports). Type: Int ... 6-deprecated-alias-for-5, 7-noqa, 8-vertical-hanging-indent-bracket, ...
Read more >
Trainer - Hugging Face
Trainer. The Trainer class provides an API for feature-complete training in PyTorch for most standard use cases. It's used in most of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found