You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
merge: row/TOKENIZER-TEKKEN -- recognize and split the Mistral Tekken pre-tokenizer (#283)
Closes#168. External contribution from Filip Sajdak (@filipsajdak).
The PR's red agent-record and pr-size checks were a FORK ARTIFACT, not a
defect: both checkers refused with "base must be an ancestor of head"
because the branch had not been rebased onto current main, so neither could
compute a commit range at all. Every substantive job -- build, cuda-fat-
build, build-test-cpu, build-test-cpu-arm64, build-test-vulkan,
device-leakage, documentation-checkpoint, commit-protocol-tag -- was green.
The sanitize-cpu (address,undefined) failure is the pre-existing main
baseline (test_load_direct_upload, test_llama_embedding_fold,
test_laguna_nvfp4_loader, test_openai_api_server, test_capi), identical on
every open PR. Merging locally supplies the ancestry those two checkers
wanted.
Tekken is the first pattern here whose letter rule is CASE-AWARE. It is
tiktoken's o200k_base pat_str with exactly two edits -- no (?i:'s|'t|...)
contraction group, and single-codepoint \p{N} instead of \p{N}{1,3} -- so
an uppercase run ends a piece when a lowercase run follows ("HelloWorld" ->
"Hello" + "World"). Because the two letter classes OVERLAP on {Lm, Lo, M},
this needs genuine ordered-alternation backtracking and could not fold into
MatchLetterRun's single-predicate scan; MatchTekkenAlt walks the greedy
give-back stops longest-first, which is exactly what the regex engine picks.
Two seams widened rather than bent:
- A separate narrow LetterCase table (Lu/Lt=upper, Ll=lower, Lm/Lo in
BOTH), because UCat collapses all of L* into kLetter and cannot express
the split. UCat and every existing consumer keep their exact bytes.
- The single marks_aware flag splits into marks_in_run and
marks_excluded. Tekken carries \p{M} inside its letter classes (like
kQwen2) while its punct negation omits \p{M} (like kLlama3) -- a
combination no other pattern has, which is why one flag sufficed until
now. Both derived flags evaluate identically to the old one for kQwen2
and for every other pattern, so this is non-regressive by construction.
Verified before merging rather than taken on trust:
- tools/gen_unicode_data.py reproduces the checked-in
include/vllm/tokenizer/unicode_data.h and src/.../unicode_data.cpp
BYTE-FOR-BYTE (md5 identical after a local regen, unidata 15.0.0, 1861
letter-case ranges). The generated table is not hand-edited.
- The goldens are oracle-derived, not authored: gen_pretok_goldens.py
drives the real HF tokenizers Split pre-tokenizer with the regex quoted
verbatim from mistralai/Mistral-Nemo-Instruct-2407 tokenizer.json, over
~90 cases including 60 seeded random strings.
- DetectPattern keys on an exact regex-string match, so a checkpoint that
does not match falls through to today's behavior. No existing model can
change class.
FOLLOWING_AGENTS_PROTOCOL
Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: Claude:claude-opus-5 [ClaudeCode]
0 commit comments