Skip to content

Preserve existing tokenizer metadata - #703

Open
NeonBohdan wants to merge 1 commit into
arcee-ai:mainfrom
NeonGeckoCom:fix/preserve-tokenizer-metadata
Open

Preserve existing tokenizer metadata#703
NeonBohdan wants to merge 1 commit into
arcee-ai:mainfrom
NeonGeckoCom:fix/preserve-tokenizer-metadata

Conversation

@NeonBohdan

@NeonBohdan NeonBohdan commented Aug 24, 2026

Copy link
Copy Markdown

Re-adding an existing configured token as a plain string can replace its AddedToken metadata, 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 source and force behavior remains unchanged.

The regression covers explicit-model, base, and union tokenizer 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_tokenizer no longer calls add_tokens for those names. Re-adding them as plain strings could overwrite AddedToken metadata (special-token flags, lstrip/rstrip, normalization, etc.).

Missing configured token names are still added as before; embedding source / force behavior is unchanged.

A new regression test (model_special fixture + parametrized test_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.

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@NeonBohdan

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@NeonBohdan
NeonBohdan marked this pull request as ready for review August 25, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant