Repository navigation
[Engine] Inkling 2: the tokenizer keeps a piece that is a token whole (ignore_merges) - #210
Open
okada-shogo wants to merge 1 commit into
Open
okada-shogo wants to merge 1 commit into
okada-shogo wants to merge 1 commit into
Conversation
The model's tokenizer.json sets ignore_merges, and Hugging Face's tokenizers (the reference the model was trained with) use it: a pre-tokenizer piece that is in the vocabulary is that one token. strata_tokenizer did not set it for the inkling2 pre-tokenizer, as llama.cpp 29b52d398b does not, so a word like "kwargs" (token 87550, which no chain of merges reaches) was encoded as three tokens [86226, 70, 82]. Of 53 golden strings checked against Hugging Face on the full vocabulary, this was the only one that differed; with the fix all 53 match. Only the inkling2 pre-tokenizer changes; the other names are as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
okada-shogo
marked this pull request as ready for review
November 22, 2026 21:27
okada-shogo
added a commit
to okada-shogo/PolyStrata
that referenced
this pull request
Nov 23, 2026
…iece that is a token whole (ignore_merges) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem and result
The model's
tokenizer.jsonsetsignore_merges: true. Hugging Face's tokenizers use it: a piece that is in thevocabulary is that one token.
strata_tokenizerdid not set it for theinkling2pre-tokenizer (llama.cpp29b52d398b does not either), so some words came out as several tokens.
kwargs[87550][86226, 70, 82][87550]Only the
inkling2pre-tokenizer changes.Related discussion
Split out of #200, as the maintainer asked there:
#200 (comment)
The bug was found by the Inkling 2 golden tests, which follow in a separate draft PR (
port/serve-fixtures).Approach
IGNORE_MERGESgetsinkling2, as it already hasglm4,glm5andlfm2.extract()writespre_pattern_sourceas GPT4O with ignore_merges. On main it showed the QWEN35 string.PreTokenizer.test_a_piece_that_is_a_token_is_that_token.Validation
Passed:
cd terminal && ../.venv/bin/python -m unittest serve.test_inkling serve.test_server(CPU only): main 477 tests OK;this branch 478 tests OK.
serve.test_family_parsers,test_lfm2,test_flint,test_gemma,test_prompt_encoder,test_stop_holdback,test_responses,test_tool_addition,test_tool_markup_retry,tools.test_strata_ornith122,tools.test_tokenizer_plain_spans,tools.test_setup_inkling,tools.test_hy4_tokenizer): 211 OK (1 skipped), the same on main and on this branch.thinkingmachines/Inkling-2-Minitokenizer.json: on 9,102 chunks of repository text (~6.24M tokens), main differs in 133 chunks (for examplekwargs), this branch in 0. Random fuzz: 31 of 20,000 strings differ on main, 0 on this branch.Failed: On unchanged main d1f711e, serve.test_inkling + serve.test_server failed 1 of 477 once in 3 runs (the output didn't name the test; it is intermittent on main itself, not in this change). The branch runs passed every time.
Not run: none for this change (CPU-only Python; no engine code changes).
Limits
ignore_merges/pre_pattern_sourcemetadata. This iscosmetic:
from_dirderives the setting from the pre-tokenizer name.Credits: VecSzn's Inkling 2 tokenizer on main; Hugging Face tokenizers as the reference.
🤖 Generated with Claude Code