LLM & Transformer Fundamentals·Question 18 of 109Basic

What does perplexity measure, and why can't you compare it across models with different tokenizers?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Perplexity is the exponentiated average negative log-likelihood per token on held-out text: PPL = exp(-(1/N) Σ log p(x_t | x_<t)). Intuitively it is the effective number of tokens the model is choosing between at each step: a perplexity of 8 means the model is, on average, as uncertain as a uniform choice among 8 tokens. Lower is better, and it is the training loss, just exponentiated.

Full worked answer

Perplexity is the exponentiated average negative log-likelihood per token on held-out text: PPL = exp(-(1/N) Σ log p(x_t | x_<t)). Intuitively it is the effective number of tokens the model is choosing between at each step: a perplexity of 8 means the model is, on average, as uncertain as a uniform choice among 8 tokens. Lower is better, and it is the training loss, just exponentiated.

The trap is the denominator. "Per token" depends on the tokenizer. A model with a 200k vocabulary splits the same document into fewer, larger tokens than a 32k-vocab model, so each prediction carries more information and per-token perplexity rises even if the model predicts the text better. Comparing per-token perplexity across tokenizers is comparing numbers in different units.

The fix is to normalise by something tokenizer-independent. Bits per byte (BPB) divides the document's total negative log-likelihood, in bits, by its UTF-8 byte count: BPB = (loss in nats per token / ln 2) / (bytes per token). The total log-likelihood of a document is comparable across models; dividing by a model-specific unit is where it goes wrong. Byte-level and tokenizer-free papers report BPB for exactly this reason.

Other ways perplexity misleads:

  • Post-trained models usually score worse perplexity on web text than their base models, because SFT and RL sharpen the distribution toward a chat style. That is not a capability regression.
  • The average is dominated by easy tokens. Function words and boilerplate are predicted well by any model; the tokens that carry reasoning are a small fraction of the mean.
  • Contamination: if the eval text was in pretraining, perplexity collapses and tells you nothing.
  • It says nothing about instruction following, factuality or tool use.

Where it is still the right tool: comparing checkpoints within one run, data-mixture and tokenizer ablations (in BPB), detecting domain shift, and filtering pretraining data by a reference model's perplexity.

What a good answer covers

  • Perplexity is the exponentiated average negative log-likelihood per token on held-out text
  • Intuitively it is the effective number of tokens the model is choosing between at each step
  • Lower is better, and it is the training loss, just exponentiated
  • "Per token" depends on the tokenizer
  • Comparing per-token perplexity across tokenizers is comparing numbers in different units

Interviewer follow-ups to expect

  1. Convert a loss of 2.0 nats per token into perplexity. Tokenizer A averages 3.5 bytes per token and tokenizer B averages 4.5: how do you compare their losses?

  2. Why might a better model show higher perplexity on your eval set?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep