Preserve existing tokenizer metadata - #703
Open
NeonBohdan wants to merge 1 commit into
Open
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
NeonBohdan
marked this pull request as ready for review
August 25, 2026 08:16
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.
Re-adding an existing configured token as a plain string can replace its
AddedTokenmetadata, including special-token, matching, normalization, and whitespace flags.Skip names already present in the selected output vocabulary. Missing names are still added normally, and configured embedding
sourceandforcebehavior remains unchanged.The regression covers explicit-model,
base, anduniontokenizer construction, plus ordinary missing-token addition on the direct-model path.Note
Low Risk
Small guard in tokenizer construction with targeted tests; no auth, data, or merge-math changes.
Overview
When merge config lists tokens that are already in the output vocabulary,
build_tokenizerno longer callsadd_tokensfor those names. Re-adding them as plain strings could overwriteAddedTokenmetadata (special-token flags, lstrip/rstrip, normalization, etc.).Missing configured token names are still added as before; embedding
source/forcebehavior is unchanged.A new regression test (
model_specialfixture + parametrizedtest_configured_tokens_preserve_metadata_and_add_missing) checks that an existing special token keeps id, decoder metadata, and decode behavior across model, base, and union tokenizer sources, and that a genuinely new configured token is still added on the direct-model path.Reviewed by Cursor Bugbot for commit 42a8ecc. Bugbot is set up for automated code reviews on this repo. Configure here.