-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow adding custom logits processors in the generate
method
#11413
Comments
I think I could submit a pull request to this, if I had
Also, maybe one would need the new argument to be What do you folks think? Would you accept this pull request (after maybe giving me some tips related to the tests)? |
Hey @wadimiusz, Sorry to only come back to you now! I think in general, I'm fine with such an extension. The only problem I see is that a user could add a custom logits processor that already exists (e.g. a user would create his own => So I'm ok with this extension. Interested in hearing your thoughts about this @patil-suraj @Narsil |
I think it's a very nice idea !. The problem you mention @patrickvonplaten I think will be relevant mostly for power users (that want to add a LogitsProcessor) so they should be careful in terms of how they use this tool. I guess we could emphasis this in the documentation for the |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
@wadimiusz Is there any update on this? I think it would be a great addition. |
Hi @ScientiaEtVeritas, the feature seems not hard to implement and I think I already have the code somewhere, but it would require nice and thorough tests that I don't have the time to write right now. If you could help me with the tests, we could submit a pull request together :) |
There used to be a PR that might be used as a starting point: Thanks if you can work on this ! |
馃殌 Feature request
Hello,
I'd like to request a new feature in the
generate
method of theGenerationMixin
class fromgeneration_utils
. Specifically, I'd like a feature that allows a user to pass custom LogitsProcessors by adding a new argumentlogit_processors: Optional[LogitsProcessorList] = None
to thegenerate
method.Motivation
I'd like to run generation on a pre-trained model, and I'd like to modify its output logits according to my custom function before the search or sampling or whatever is used. I think that this could be a common use case for controlled natural generation because one often wants to implement some trivial restrictions over generated logits.
Here is an example of how this could be used:
Your contribution
I have no experience in open source, but I can try to help if you need a hand. I think that the general approach to implementing this is to do the following:
logit_processors: Optional[LogitsProcessorList] = None
argument to thegenerate
method,_get_logits_processor
method of GenerationMixin and add the custom logit processors after all the other logit processors are in place._get_logits_processor
in thegenerate
method.What do you think?
The text was updated successfully, but these errors were encountered: