Generate: inner decoding methods are no longer public#29437
Generate: inner decoding methods are no longer public#29437gante merged 1 commit intohuggingface:mainfrom
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. |
ArthurZucker
left a comment
There was a problem hiding this comment.
Thanks, might be easier to have both contrastive_search and _ contrastive_search for overloading? Tho it gives freedom, up to you!
| logger.warning_once( | ||
| "Calling `contrastive_search` directly is deprecated and will be removed in v4.41. Use `generate` or a " | ||
| "custom generation loop instead.", | ||
| ) |
There was a problem hiding this comment.
we could even leave it as is, this way custom self._contrastive_search are easily changeable for users? or something like that
There was a problem hiding this comment.
In the future, I don't want to have all these methods, as they are near copies of each other -- e.g. greedy_search and sample differ by <5 lines. As such, some of them will be deleted, so users won't be able to call e.g. _greedy_search :D
What does this PR do?
This PR sets the inner decoding methods (such as
greedy_search) as private methods, with a deprecation warning.This will enable us to complete the following projects with fewer speed bumps:
torch.compile: as seen in the PoC PR, a few interface pieces should be touched. E.g. Some special tokens can be alist(e.g.eos_token_id), which is not compile-friendly, and thustorch.tensorshould be used instead;generate. Having multiple interfaces to maintain will constrain our ability to refactor the code.