L
Member
Most "the new checkpoint is slightly worse" reports I see are not model quality regressions at all. They come from a tokenizer/template change that nobody versioned. A tokenizer swap is not a vocab resize with random init and a fine-tune on top; it silently changes three things that the loss curve will not show you for weeks.
One: special-token ids and their meaning
Every added token (`<|im_start|>`, `<|endoftext|>`, pad, unk) has an integer id that only means something relative to that tokenizer. If you load a tokenizer from one repo and weights from another, ids still resolve, the forward pass still runs, and the model still emits plausible text — it is just conditioning on the wrong control tokens. Nothing crashes. Symptoms show up as slightly worse instruction following, occasional role leakage, or truncated multi-turn context.
Two: the chat template is a string, and whitespace matters
Templates add role prefixes, newlines, and a trailing generation prompt. Two templates can look identical in a diff and still differ in: a trailing space after the role tag, whether the BOS is prepended once or twice, whether the system block is dropped when empty, and how the generation prompt is appended. For a model trained on one exact rendering, a stray space or a missing newline shifts every position by one token and degrades quality in a way that looks like "the model got dumber at long context."
Three: segmentation of the inputs you actually care about
CJK, emoji, indentation in code, and long numbers are where tokenizers disagree most. A merge that looks fine on English prose can split a 6-space indent into different token counts, or fall back to byte-level tokens for a character the old vocab covered. That changes effective context length per document and changes the position distribution the model saw in training.
Methods and criteria
A. Fixed-prompt logprob comparison. Take 30–50 prompts you already use, render them with the reference template, and score per-token negative log-likelihood with both the old and new stack, using the same tokenizer for tokenization when comparing model weights. Criterion: mean per-token loss should move by less than a few percent on prompts that were in-domain for both; a jump concentrated on multi-turn or non-ASCII prompts points at template/segmentation, not weights.
B. Golden template tests. Store 8–10 rendered strings as fixtures: empty system, system with newline, multi-turn with tool role, generation prompt with trailing whitespace, non-ASCII user text. Diff character by character. Any change to a fixture must be an explicit, reviewed decision with a version bump, not a side effect of pulling a newer tokenizer.
C. Token boundary audit. For each language you ship, compare token counts for the same string across old and new tokenizers and list the tokens that changed. Criterion: if a common character sequence (a CJK phrase, an indent, a date) changes token count, treat it as a behavior change and re-run your task evals rather than assuming equivalence.
D. Special-token map assertion. Load the model config and assert: bos/eos/pad/unk ids match the tokenizer, added-token count matches the resized embedding rows, and no id is mapped to two strings. This is a five-line unit test that catches the most expensive class of bug here.
Failure modes worth listing
- Checking only fine-tune loss. A model can fit its fine-tune set while conditioning on a wrong BOS; the loss goes down, the eval does not.
- Resizing embeddings but not lm_head (or the reverse). Shapes mismatch loudly, but a partially resized checkpoint loaded with strict=False fails silently.
- Flipping padding side. Generation is fine, batched scoring is not, and the difference only appears when batch size > 1.
- Duplicated EOS. Generation runs to max_tokens and gets truncated, which reads as "worse at long answers."
- Trusting "same vocab size" as "same tokenizer." Vocab size is a count, not an identity.
Checklist before you ship a tokenizer or template change
1) Special-token id map asserted against config; added tokens counted and matched to embedding rows.
2) Template fixtures diffed; any change versioned and reviewed.
3) Token-count delta listed per language and per input class you ship.
4) Fixed-prompt per-token loss compared old vs new, with the same tokenizer where weights are the variable.
5) Batched scoring re-run with batch size 1 vs 8 to catch padding-side effects.
6) Long-generation run to confirm EOS is emitted once and stop strings still match.
7) One regression task set (10–20 items) run end to end, with outputs diffed, not just aggregate scores.
The point is not that tokenizer changes are dangerous; it is that they are invisible. Treat the tokenizer and the chat template as versioned artifacts with their own tests, and most "quality regressions" disappear before anyone starts retraining.
One: special-token ids and their meaning
Every added token (`<|im_start|>`, `<|endoftext|>`, pad, unk) has an integer id that only means something relative to that tokenizer. If you load a tokenizer from one repo and weights from another, ids still resolve, the forward pass still runs, and the model still emits plausible text — it is just conditioning on the wrong control tokens. Nothing crashes. Symptoms show up as slightly worse instruction following, occasional role leakage, or truncated multi-turn context.
Two: the chat template is a string, and whitespace matters
Templates add role prefixes, newlines, and a trailing generation prompt. Two templates can look identical in a diff and still differ in: a trailing space after the role tag, whether the BOS is prepended once or twice, whether the system block is dropped when empty, and how the generation prompt is appended. For a model trained on one exact rendering, a stray space or a missing newline shifts every position by one token and degrades quality in a way that looks like "the model got dumber at long context."
Three: segmentation of the inputs you actually care about
CJK, emoji, indentation in code, and long numbers are where tokenizers disagree most. A merge that looks fine on English prose can split a 6-space indent into different token counts, or fall back to byte-level tokens for a character the old vocab covered. That changes effective context length per document and changes the position distribution the model saw in training.
Methods and criteria
A. Fixed-prompt logprob comparison. Take 30–50 prompts you already use, render them with the reference template, and score per-token negative log-likelihood with both the old and new stack, using the same tokenizer for tokenization when comparing model weights. Criterion: mean per-token loss should move by less than a few percent on prompts that were in-domain for both; a jump concentrated on multi-turn or non-ASCII prompts points at template/segmentation, not weights.
B. Golden template tests. Store 8–10 rendered strings as fixtures: empty system, system with newline, multi-turn with tool role, generation prompt with trailing whitespace, non-ASCII user text. Diff character by character. Any change to a fixture must be an explicit, reviewed decision with a version bump, not a side effect of pulling a newer tokenizer.
C. Token boundary audit. For each language you ship, compare token counts for the same string across old and new tokenizers and list the tokens that changed. Criterion: if a common character sequence (a CJK phrase, an indent, a date) changes token count, treat it as a behavior change and re-run your task evals rather than assuming equivalence.
D. Special-token map assertion. Load the model config and assert: bos/eos/pad/unk ids match the tokenizer, added-token count matches the resized embedding rows, and no id is mapped to two strings. This is a five-line unit test that catches the most expensive class of bug here.
Failure modes worth listing
- Checking only fine-tune loss. A model can fit its fine-tune set while conditioning on a wrong BOS; the loss goes down, the eval does not.
- Resizing embeddings but not lm_head (or the reverse). Shapes mismatch loudly, but a partially resized checkpoint loaded with strict=False fails silently.
- Flipping padding side. Generation is fine, batched scoring is not, and the difference only appears when batch size > 1.
- Duplicated EOS. Generation runs to max_tokens and gets truncated, which reads as "worse at long answers."
- Trusting "same vocab size" as "same tokenizer." Vocab size is a count, not an identity.
Checklist before you ship a tokenizer or template change
1) Special-token id map asserted against config; added tokens counted and matched to embedding rows.
2) Template fixtures diffed; any change versioned and reviewed.
3) Token-count delta listed per language and per input class you ship.
4) Fixed-prompt per-token loss compared old vs new, with the same tokenizer where weights are the variable.
5) Batched scoring re-run with batch size 1 vs 8 to catch padding-side effects.
6) Long-generation run to confirm EOS is emitted once and stop strings still match.
7) One regression task set (10–20 items) run end to end, with outputs diffed, not just aggregate scores.
The point is not that tokenizer changes are dangerous; it is that they are invisible. Treat the tokenizer and the chat template as versioned artifacts with their own tests, and most "quality regressions" disappear before anyone starts retraining.

