Repository navigation
vocab : add clean_spaces GGUF key - #30940
Merged
Merged
Conversation
CISC
approved these changes
Oct 21, 2026
Member
|
@ggerganov This is generally Also wondering if it makes sense to run |
ggerganov
approved these changes
Oct 22, 2026
ggerganov
left a comment
Member
There was a problem hiding this comment.
Also wondering if it makes sense to run --check-decode on more/all vocabs (including ggml-org/vocabs)?
We can do that, but maybe after we move all tokenizer tests in a dedicated workflow? Currently they run through ctest and execute for a lot of jobs - not needed.
6 tasks
auRose94
pushed a commit
to auRose94/llama.cpp
that referenced
this pull request
Oct 28, 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.
Overview
The problem was that
llama_detokenizedeletes the space before!?.,and prior to's'm're'vefor certain models. As an example, Gemma 4 convertsx != yintox!= y, while the text is left unchanged by Hugging Face. This happened because llama.cpp, for BPE vocabs, by default sets clean up on. The Hugging Face setting (clean_up_tokenization_spaces), which is either not set or false for these specific models, was never stored by the GGUF. My PR does two things: First, the converter saves the setting into a new GGUF key,tokenizer.ggml.clean_spaces, and the loader then reads it. Also, clean up is now by default turned off for the pre-tokenizers that are affected (gemma4,lfm2,glm4/glm5,chatglm-bpe,exaone4,mellum2,minicpm5,dbrx), which means that already existing GGUFs are also fixed.Fixes #30905
Additional information
Before the fix, the
--check-decodetest did not pass and had 2 decode errors. After the fix it passes. All 15test-tokenizer-0tests pass, and InferCheck decode disagreements decreased to 0 for GLM-4, GLM-4.5, GLM-4.7, LFM2, MiniCPM5, EXAONE 4 and Phi-4.Requirements
--check-decodetest. I reviewed this code and then ran the tests myself. I also wrote the PR and commit message myself.