-
Notifications
You must be signed in to change notification settings - Fork 30.9k
Patch MistralCommonTokenizer #41439
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
ArthurZucker
merged 10 commits into
huggingface:main
from
juliendenize:patch_mistral_tokenizer
Oct 14, 2025
Merged
Patch MistralCommonTokenizer #41439
ArthurZucker
merged 10 commits into
huggingface:main
from
juliendenize:patch_mistral_tokenizer
Oct 14, 2025
Conversation
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
juliendenize
commented
Oct 8, 2025
patrickvonplaten
approved these changes
Oct 8, 2025
[For maintainers] Suggested jobs to run (before merge) run-slow: auto |
ArthurZucker
approved these changes
Oct 9, 2025
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 updating! 🤗
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. |
bbe0c0f
to
8938039
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR patches the
MistralCommonTokenizer
:_piece_to_id
and_is_control_token
._piece_to_id
was incorrect for Tekkenizer.a) the special tokens were not supported
b) the normal tokens were not shifted by adding the number of special tokens
get_vocab
to a function that should better mimic what happens inTransformers
: now the mapping is based on the real ids but some ids are missing due to conversion loss of some tokens in Tekken.add_generation_prompt
has been added. This is to match signature of Transformers. In practice this value is ignored except if:a)
continue_final_message
andadd_generation_prompt
areTrue
an error is raised.b) if
add_generation_prompt
isTrue
and the last message isassistant
then an error is raised as the user should have passedcontinue_final_message
.[FEATURE] Now the tokenizer is set to fast because:a)
it is true(Edit: not so sure about that after discussion)b) it removes annoying message when initializing the tokenizer.
Edit 2: this has been reverted as it doesn't bring value and is misleading.
Also added minimal tests to ensure SPM also works in the future.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@patrickvonplaten @ArthurZucker @itazap