4.2.9 · D3Tokenization & Language Modeling

Worked examples — Perplexity as a metric

2,562 words12 min readBack to topic

Before anything, a one-line reminder of the two tools we lean on the whole way down. Both come straight from the parent, but let's re-anchor them in plain words so nothing is assumed.


The scenario matrix

Every case class perplexity can throw at you, and the example that nails it.

Cell Scenario class What's special Example
A Uniform over tokens Degenerate "no knowledge" model; exactly Ex 1
B Perfect model Every ; lower limit Ex 2
C Mixed per-token probs The everyday geometric-mean case Ex 3
D Zero-probability real token Limiting value Ex 4
E Compare two models, same data The practical decision use Ex 5
F Base trap ( vs ) Same answer only if bases match Ex 6
G Different tokenizers, same text changes → PPL not comparable; use Bits-Per-Character (BPC) Ex 7
H Real-world word problem Weather forecaster analogy, from raw counts Ex 8
I Exam twist: PPL → recover a hidden prob Invert the formula Ex 9

We now walk each cell. Figures accompany the ones where a picture carries the reasoning.


Cell A — the uniform (know-nothing) model


Cell B — the perfect model


Cell C — the everyday mixed case


Cell D — the catastrophic zero


Cell E — comparing two models on the same data


Cell F — the base trap


Cell G — different tokenizers, same text


Cell H — real-world word problem


Cell I — the exam twist (invert it)


The 80/20 of "every scenario"

Recall What each cell taught

Uniform model → PPL (ceiling) ::: Ex 1 Perfect model → PPL (floor) ::: Ex 2 Real models live in ::: Ex 1 + Ex 2 One zero-prob token → PPL ::: Ex 4 Geometric mean (not arithmetic) controls PPL ::: Ex 3 Compare only on same data ::: Ex 5 Base cancels iff you exponentiate with the same base ::: Ex 6 Different tokenizers are NOT comparable ::: Ex 7 You can invert PPL to recover a probability ::: Ex 9


Connections