Mistral Tokenizer Converter Script - Initialization with Pattern Argument#42131
Draft
pandora-s-git wants to merge 1 commit intohuggingface:mainfrom
Draft
Mistral Tokenizer Converter Script - Initialization with Pattern Argument#42131pandora-s-git wants to merge 1 commit intohuggingface:mainfrom
pandora-s-git wants to merge 1 commit intohuggingface:mainfrom
Conversation
Contributor
|
@pandora-s-git any chance we can also directly put something like: if self.pre_tokenizer[0] is incorrect:
self.pre_tokenizer[0] = pre_tokenizers.Split(pattern=Regex(r"[^\\r\\n\\p{L}\\p{N}]?[\\p{Lu}\\p{Lt}\\p{Lm}\\p{Lo}\\p{M}]*[\\p{Ll}\\p{Lm}\\p{Lo}\\p{M}]+|[^\\r\\n\\p{L}\\p{N}]?[\\p{Lu}\\p{Lt}\\p{Lm}\\p{Lo}\\p{M}]+[\\p{Ll}\\p{Lm}\\p{Lo}\\p{M}]*|\\p{N}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n/]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+"), behavior = "isolated")
logger.warning("Fix your file ...")directly in the code so that all incorrect tokenizers will be corrected on-the-fly? 🙏 |
Author
|
@patrickvonplaten I dont think would be a good idea to force replace it, since there are finetuned models around that used the old tokenizer - those will be hard to judge if it will be better or worse with the fix - but we could add a warning only potentially ? |
ArthurZucker
approved these changes
Nov 11, 2025
This was referenced Apr 29, 2026
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
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.
The current Mistral Tokenizer from Mistral Common to Transformers converter script uses a default regex pattern for the tokenizer, however Mistral models actually require a specific provided pattern.
More context can be found here: https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503/discussions/84
This PR will aim to fix this issue by intitializing the tokenizer with the correct pattern.
cc @ArthurZucker