-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
added the max_matching_ngram_size to GenerationConfig #29131
Conversation
…, for the PromptLookupCandidateGenerator
Hi @mosheber 👋 I'd be happy to merge the PR, conditional on the answer to the following question being yes (preferably backed with data): have you found significant benefits of changing the flag you added? On the original issue, the author's experiments showed that there were little benefits in changing this option. As such, we don't want to add new flags unless they result in clear benefits :) |
The results below show a get_candidates: 0.3467 ms
get_candidates_opt: 0.0047 ms |
@danielkorat convinced by your numbers 👍 Let's add this PR! |
src/transformers/generation/utils.py
Outdated
@@ -698,9 +698,12 @@ def _get_candidate_generator( | |||
Returns the candidate generator to be used in `assisted_generation` | |||
""" | |||
if generation_config.prompt_lookup_num_tokens is not None: | |||
candidate_generator = PromptLookupCandidateGenerator( | |||
candidate_generator_params = dict( |
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.
Instead of creating a dict here, let's:
a) pass keyword arguments to PromptLookupCandidateGenerator
(as before the PR)
b) default max_matching_ngram_size
in PromptLookupCandidateGenerator
to None
, and set it to the original default value in __init__
if it is None
.
This pushes complexity away from generate
and into PromptLookupCandidateGenerator
:)
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.
Thanks for the comment! I switched back to keyword arguments.
@mosheber after applying the fix, please run |
I ran the |
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.
The changes look good to me, thank you for iterating and making transformers
better 💛
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.
Actually, there is a tiny missing thing: max_matching_ngram_size
should have an entry in the docstring of GenerationConfig
our CI is still complaining about code formating, make sure you have the latest version installed when running make fixup
again :)
Great idea! I added the doc string to the GenerationConfig class. |
Yeah don't worry about it :) |
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! just one nit
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
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. |
What does this PR do?
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@gante , would appreciate it if you could give this PR a glance, and thank you in advance.