-
Notifications
You must be signed in to change notification settings - Fork 31.3k
Log the decoder chosen by GenerationMixin #17196
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
|
Hey @mapmeld, Thanks for the PR. To me, that is a bit too much of an edge-case and I'm not very happy with cluttering the generation code with @gante @patil-suraj what do you think? |
|
Hey @mapmeld! Thank you for the PR 👍 I'm also not a fan of all the WDYT? |
|
@patrickvonplaten @gante That makes sense to me, log.debug level, no extra argument. I've made a commit for that |
|
Agree with @gante 's comment, using |
gante
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
(to get rid of CI errors, rebase with main -- some issues were fixed since you opened the PR)
|
Sorry, I think I wasn't super clear in my last message. Personally, I would prefer to not merge this PR because:
|
|
OK, will close then. If I can suggest changes beyond logging to this section, here are some ideas:
|
|
Thanks a lot @mapmeld - those are really nice suggestions! Also after some discussion we think it could make a lot of sense to do maybe the following:
|
|
Also keen to hear suggestions from @gante :-) |
(@mapmeld) Yeah, we are working on it :D TF generate should have a big release soon.
(@patrickvonplaten) Without if's and else's, the cleanest solution would possibly be to hold some dictionary with all passed arguments, in addition to a set of accepted arguments for each generation type, and raise an exception with all unexpected arguments (e.g. WDYT? |
|
In a first step I was rather thinking about just warning the user if parameters are passed in |
|
Adding sub-generation specific logging logic sounds very complex, would be open if we find a clean, concise solution but at the moment I'd like to prevent adding hardcoded lists of which generation parameter is relevant for which sub generation method (also hard to maintain) |
|
@gante the solution sounds interesting - would need to see a PR for it to fully understand it. The problem I see is that we won't detect unnecessary generation parameters since they are inside |
|
Overall, also just want to say here that IMO two mistakes were made a while back:
Will be very hard to remedy these things without breaking backward comp, but open to suggestions / comments! |
|
Would it be possible for us to talk about it in the HF Slack? I would be interested in finding a part of this where I can contribute |
|
Invited you :-) Let's chat on Slack |
What does this PR do?
When calling
model.generate(content, log_decoder=True), the PR would log which decoder and warper(s) are actually used in generation.I have a demo where I show text generated with different options (top_k, typical_p, repetition_penalty, num_beams, etc.). The final chosen decoding strategy is not obvious. It is tricky to test by comparing outputs because a generative model often returns different text on multiple runs.
By design the function tolerates mistakes -- if there is a missing arg (
typical_p=0.5but nodo_sample=True) or mismatched value (typical_p=3) or typo'd arg (numBeams=2) then the function silently chooses another decoding strategy. The code does not flag these because the remaining**kwargsare passed to the model.I believe the logger is the best place to check whether decoding actually happened as expected.
Example usage: https://colab.research.google.com/drive/1DpMnZkSCtZIiaONoxfzYxYI4vgiTNYLN?usp=sharing
The first commit is unnecessary thanks to docs for typical decoding #17186Rebased on this PR and adding one additional section to the documentation about typical decodinglog_decoderto always dologger.infoin these placeslogger.info, I could move logger calls intoBeamSearchScorer. Trying to avoid adding too many argslogger.warnif these issues warrant itDiscussion: https://discuss.huggingface.co/t/logging-which-decoder-selected-in-generation/18133
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.