fix(auto): Map deepseek_v2 and deepseek_v3 to LlamaTokenizer#44783
Open
BillionClaw wants to merge 1 commit intohuggingface:mainfrom
Open
fix(auto): Map deepseek_v2 and deepseek_v3 to LlamaTokenizer#44783BillionClaw wants to merge 1 commit intohuggingface:mainfrom
BillionClaw wants to merge 1 commit intohuggingface:mainfrom
Conversation
DeepSeek V2 and V3 models use SentencePiece tokenization (like Llama) but were falling back to the generic TokenizersBackend in v5. This caused incorrect decoding where spaces were lost (e.g., "How are you?" becoming "Howareyou?"). This fix explicitly maps deepseek_v2 and deepseek_v3 model types to LlamaTokenizer, which properly handles the SentencePiece-style tokenization with Metaspace and the correct decoder chain. Fixes huggingface#44779
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto |
Contributor
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=44783&sha=4af4cd |
Collaborator
ArthurZucker
left a comment
There was a problem hiding this comment.
This is just wrong, #44779 (comment) see this comment
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.
This PR fixes the DeepSeek tokenizer issue where spaces were lost during decoding in Transformers v5.
Problem
DeepSeek V2 and V3 models use SentencePiece tokenization (like Llama) but were falling back to the generic TokenizersBackend in v5. This caused incorrect decoding where spaces were lost. For example, encoding and decoding "How are you doing?" would produce "Howareyoudoing?".
Root Cause
In Transformers v5, the tokenizer mapping system changed. Models not explicitly mapped in TOKENIZER_MAPPING_NAMES fall back to TokenizersBackend. DeepSeek models need the special SentencePiece handling provided by LlamaTokenizer (Metaspace pretokenizer with ▁ replacement and proper decoder chain).
Fix
Explicitly map
deepseek_v2anddeepseek_v3model types toLlamaTokenizerinTOKENIZER_MAPPING_NAMES.Verification
deepseek_v2anddeepseek_v3now resolve toLlamaTokenizerFixes #44779
Tagging: @ArthurZucker @itazap (tokenizers),