[generate] Run custom generation code from the Hub #36405
Draft
+31
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
👉 This is a draft PR for feature discussion 👈
This PR enables the definition of custom decoding methods on the hub, sharing the same interface as
generate
. In a nutshell, iftrust_remote_code=True
andrecipe="user/repo_name"
are passed togenerate
, the arguments togenerate
are forwarded to a customgenerate
function, defined ingenerate.py
in that repo.Why does this matter
With the popularity of LLMs, LLM-derived models (like VLMs), and test-time compute techniques, there is an explosion of what we can do regarding decoding methods. Instead of having a complex process to include a certain technique in
transformers,
this would enable developers and researchers to build their own decoding methods and share them with the world with zero additional Python dependencies.The Hub-hosted decoding techniques would also get all benefits from the Hub, including proper credit to the creator (downloads/likes), a place to discuss the method, ...
Working Example
(generate.py in joaogante/test_generate_from_hub)
TODO
Before this PR is ready to be merged, the following are missing: