Skip to content

[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
simplexai-labs:mainfrom
okada-shogo:port/serve-fix-ignore-merges
Open

okada-shogo wants to merge 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/serve-fix-ignore-merges

Conversation

@okada-shogo

@okada-shogo okada-shogo commented Nov 22, 2026 •

Copy link
Copy Markdown

Problem and result

The model's tokenizer.json sets ignore_merges: true. Hugging Face's tokenizers use it: a piece that is in the
vocabulary is that one token. strata_tokenizer did not set it for the inkling2 pre-tokenizer (llama.cpp
29b52d398b does not either), so some words came out as several tokens.

text Hugging Face (reference) main this PR alone
kwargs [87550] [86226, 70, 82] [87550]

Only the inkling2 pre-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_MERGES gets inkling2, as it already has glm4, glm5 and lfm2.
  • extract() writes pre_pattern_source as GPT4O with ignore_merges. On main it showed the QWEN35 string.
  • New test 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.
  • Other serve and tokenizer suites (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.
  • The new test, run against main's code, fails as expected.
  • Differential test against Hugging Face tokenizers 0.23.3 with the real thinkingmachines/Inkling-2-Mini
    tokenizer.json: on 9,102 chunks of repository text (~6.24M tokens), main differs in 133 chunks (for example
    kwargs), 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

  • Packs extracted before this change keep their old ignore_merges / pre_pattern_source metadata. This is
    cosmetic: from_dir derives the setting from the pre-tokenizer name.
  • A comparison that sends text to llama.cpp will now tokenize such words differently from llama.cpp. Send token ids.

Credits: VecSzn's Inkling 2 tokenizer on main; Hugging Face tokenizers as the reference.

🤖 Generated with Claude Code

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
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>
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