-
Notifications
You must be signed in to change notification settings - Fork 30.3k
[generate] PromptLookupCandidateGenerator
won't generate forbidden tokens
#40726
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
Merged
+60
−58
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f2090b8
no longer flaky :)
gante 46cc6d5
PR comments
gante 1f72346
any token-blocking logits processor works
gante 6cb81b4
Merge branch 'main' into test_prompt_lookup
gante e87e275
?
gante d57ee31
default
gante f3453cc
-_-
gante 4589257
create fake tensors once
gante File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -779,27 +779,6 @@ def test_prompt_lookup_decoding_matches_greedy_search(self): | |
"blip2", # overridden `generate()` for all BLIP models | ||
"instructblip", | ||
"instructblipvideo", | ||
# TODO: The list is growing huge 🙃! Let's try to check if the config has any of audio/image/video token id and skip the test! | ||
# All models below: shouldn't suggest image tokens. Can be fixed by passing `suppress_ids` to candidate generator: @joaa @raushan | ||
"llava", | ||
"idefics2", | ||
"idefics3", | ||
"mllama", | ||
"paligemma", | ||
"emu3", | ||
"gotocr2", | ||
"qwen2vl", | ||
"qwen2_5_vl", | ||
"ayavision", | ||
"janus", | ||
"gemma3", | ||
"mistral3", | ||
"chameleon", | ||
"internvl", | ||
"qwen2_5omni", # the file is named `qwen2_5_omni`, but the model class is `Qwen2_5Omni`, | ||
# All models below: shouldn't suggest audio tokens. Can be fixed by passing `suppress_ids` to candidate generator: @joaa @raushan | ||
"voxtral", | ||
"qwen2audio", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yaaaaaay 💃🏻 |
||
] | ||
): | ||
self.skipTest(reason="May fix in the future: need model-specific fixes") | ||
|
@@ -835,11 +814,12 @@ def test_prompt_lookup_decoding_matches_greedy_search(self): | |
"return_dict_in_generate": True, | ||
"use_cache": True, | ||
} | ||
logits_processor_kwargs = self._get_logits_processor_kwargs(config=model.config) | ||
|
||
output_greedy = model.generate(**generation_kwargs, **inputs_dict) | ||
output_greedy = model.generate(**generation_kwargs, **inputs_dict, **logits_processor_kwargs) | ||
|
||
generation_kwargs.update({"prompt_lookup_num_tokens": 2}) # see b) | ||
output_prompt_lookup = model.generate(**generation_kwargs, **inputs_dict) | ||
output_prompt_lookup = model.generate(**generation_kwargs, **inputs_dict, **logits_processor_kwargs) | ||
|
||
# The two outputs must match and their shape must be as expected | ||
self.assertTrue(has_similar_generate_outputs(output_greedy, output_prompt_lookup)) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
(docstring args were out of order, and some were missing)