Generate: remove deprecated public decoding functions and streamline logic 🧼 - #29956
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
Tests on all models are passing 🙌 (the failing pipeline test seems unrelated, and passing locally on my end) |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Yaaay, thanks for clean-up! Looks so much nicer
e3c994f to
db8cc74
Compare
There was a problem hiding this comment.
functions not public -> no docs -> remove link to the docs
There was a problem hiding this comment.
(see comment on L1434)
There was a problem hiding this comment.
Instead of pulling information from generation_config to pass around through model_kwargs, let's use generation_config directly.
A single object to hold all generation parameterization.
There was a problem hiding this comment.
These were being passed through model_kwargs before
There was a problem hiding this comment.
This one was not needed -- contrastive search does not sample
There was a problem hiding this comment.
On most decoding methods eos_token_ids doesn't need to be passed -- it was used when the decoding method was called directly and stopping_criteria was not passed.
However, beam methods still need it.
There was a problem hiding this comment.
function not public -> let's remove the example (preparing its inputs will be more challenging now, as we no longer have API guarantees)
There was a problem hiding this comment.
In the main generate body, we set pad_token_id to eos_token_id in this situation -- this exception will never be reached
|
ping @ArthurZucker -- ready for review :) |
ArthurZucker
left a comment
There was a problem hiding this comment.
Late review but very nice cleanup sir! 🤗
There was a problem hiding this comment.
theoretically some of these can be taken from the config / the generation config if it inherits them. But nit
There was a problem hiding this comment.
Yes! That's a good idea
db8cc74 to
a8b6e58
Compare
|
Reran slow tests locally, all seems good 👍 |
What does this PR do?
🧼 🧼 🧼
Calling the internal decoding functions as part of our public API was scheduled for removal in v4.41 (the next release). Its motivation was flexibility and conciseness: having multiple public interfaces for the same functionality forced us to add repeated logic in many places, increasing every time we added a new decoding method.
Due to this removal from the public API, a few things were changed/removed as a logical consequence:
generate;generate. As such, we can remove a lot of boilerplate (x = x if x is not None else self.generation_config.x).Tests ran locally:
pytest --doctest-modules src/transformers/generation -vv)RUN_SLOW=1 py.test tests/generation/test_utils.py -vv)RUN_SLOW=1 py.test tests/test_cache_utils.py -vv) -- same failures as inmainRUN_SLOW=1 py.test tests/models/llama/test_modeling_llama.py -vv)RUN_SLOW=1 py.test tests/models/whisper/test_modeling_whisper.py -vv) -- same failures as inmain