Model and Inference EngineeringTraining data and objectivesStaff
How do you compare language-model loss after changing tokenizers without confusing the measurement units?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
Two models score the same reversible 100-byte passage under comparable boundaries. Tokenizer A produces 50 scored tokens at 1.5 nats each. Tokenizer B produces 25 at 2 nats each. Compare per-token loss and common-byte code length, explain what likelihood claim is justified, and design a fair corpus/task comparison including context and template differences.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
Per-token loss uses a unit that changes with the tokenizer. A usual language-model loss averages negative log probability per target token. Different tokenizers cut the same text into different numbers of tokens, with different prediction problems at each step. If one tokenizer makes 50 tokens and another makes 25 from the same passage, their per-token losses use different units. Hugging Face's perplexity documentation explicitly notes that tokenization affects perplexity comparisons.
Take a toy 100-byte passage. Model A's tokenizer creates 50 scored tokens with average loss 1.5 nats per token. Model B's creates 25 scored tokens with average loss 2.0 nats per token. Reporting just the averages makes B look worse. Their total negative log probabilities for their respective encoded sequences are 75 and 50 nats. B gives its encoded sequence the shorter model-based code length under these conditions. This comparison should not be described as the exact marginalized probability of the decoded text without additional assumptions about alternative tokenizations. Divide by the same byte count to get 0.75 versus 0.50 nats per byte, or convert to bits per byte. This example assumes each tokenizer represents the same text reversibly and that both likelihoods include comparable boundaries and targets.
In a real comparison, use the same held-out raw documents, comparable context budgets in content, and explicit treatment of BOS, EOS, whitespace, byte normalization and ignored spans. A fixed token-length window can expose one model to less raw text than the other. Report bits per byte or another common text unit alongside downstream task results. For chat models, also check that different templates do not turn the comparison into two different instruction-following tasks.
A nat uses the natural logarithm as its information unit. Dividing the total negative log likelihood by the same byte count gives a common normalization. Dividing again by log(2) converts nats to bits, yielding about 1.082 versus 0.721 bits per byte in this example. Preserve exact text bytes or document the normalization applied before counting them.
Reversible encoding means decoding the canonical tokenization recovers the source text. It does not necessarily mean that no other token sequence can decode to the same text. A true text-level probability can require summing over such alternatives. Standard canonical-token scoring is still a useful reproducible comparison when labeled precisely. Its value is a common-unit likelihood/code-length measure, rather than a blanket claim about every generation path.
This does not mean bits per byte settles every product decision. Tokenization changes inference length and cost, and a model can do better on text likelihood while doing worse on tool calls or rare names. The tokenizer changes midway through training, but the weight files still load. What has been mixed? covers changing tokenizer in the middle of one training run, which mixes incompatible token identities. Here each run can be internally sound. The mistake is reading two per-token metrics as if the token meant the same amount of text.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux