Foundations — Speculative decoding
This page assumes you know nothing. Every letter, arrow, and squiggle the parent note throws at you is built here from the ground up, in an order where each idea leans on the one before it.
0. What is a "token"?
Before any symbol, the object everything acts on: a token.

Look at the figure: text on the left, its token-numbers on the right. From now on when we write , we mean one token (one box). Everything the models do is "pick the next box".
1. The subscript notation and
Picture: a row of boxes. is the shaded stretch already written; is the one box we are about to fill.
Why the topic needs it: the entire game is "given everything so far (), what is the next token ()?" You cannot even state the problem without this notation.
2. Probability — the model's opinion
The model never returns a single word. It returns a probability for every possible next token.
Picture: a bar chart over the vocabulary. Tall bar on "Paris", tiny bars on everything else. The whole set of bar heights is the model's distribution for this position.

Why the topic needs it: speculative decoding compares two such bar charts (draft's vs. target's) at every position. Everything downstream is arithmetic on these bar heights.
3. Where the numbers come from:
The parent writes . Let us earn each piece.
Why and not just "divide by the sum"? Because logits can be negative, and plain division could give negative "probabilities". Exponentiating with guarantees positivity and keeps the ordering (bigger logit ⇒ bigger probability). That is exactly the tool for "turn arbitrary scores into a probability bar chart".
Recall Why is one token expensive?
To get you must build , which means loading all the model's billions of weights from memory. ::: Each new token = one full memory trip through the whole model.
4. "Sampling" and the squiggle
Picture: a dartboard whose sector sizes equal the bar heights. Throw one dart → you get one token. Tall bars are big sectors, so likely tokens usually win, but rare ones can still land.
Why the topic needs it: the draft model samples guesses; the acceptance test then samples a coin flip. Both are this same dice-roll idea.
5. The two models: with , and with
Picture: two bar charts side by side over the same vocabulary — mostly agreeing, differing on a few tokens. The whole method lives in that gap between and .
6. The lookahead
Picture: the row of boxes with dashed "guess" boxes drawn ahead of the current position.
Why the topic needs it: bigger = more potential speedup per target pass, but also more guesses that can be wrong. is the knob balancing that trade-off.
7. The ratio and — the accept coin
This is the heart of the method, so we build it very slowly.
The draft handed us a guess that it liked with probability . The target's opinion of that same token is . We compare them by dividing:
Why divide, why ? Division asks "how does the target's enthusiasm compare to the draft's?" — a pure ratio, scale-free. The exists because a probability can never exceed ; we never "accept more than always". Together they are precisely the tool that makes the kept tokens follow exactly (proven in the parent's derivation).

Picture: subtract the bars from the bars; keep only the bars that stick up above zero. Those leftover stumps, normalized, are the resample distribution.
8. Expected value and the geometric sum
The speedup analysis uses .
The closed form comes from a geometric series — a sum where each term is the previous times . You do not need to prove it here; just know and are the ingredients, and see 3.2.4-Beam-search for a contrasting "keep-many-candidates" strategy.
The prerequisite map
Read top to bottom: raw tokens feed positions, positions feed probabilities, probabilities feed both the two models and the accept-coin, and all of it pours into the topic node.
Equipment checklist
Cover the right side; can you answer before revealing?
- What a token is, and why the model sees numbers not letters ::: A token is one text chunk; the model reads/writes lists of token-numbers, picking the next one each step.
- What means ::: All tokens before position — the story written so far.
- What the "" bar means in ::: "given" — the probability of given the past .
- Why softmax and not plain division ::: Exponentiating makes every score positive and preserves order; dividing by the total forces a valid probability sum of .
- Why one token is memory-expensive ::: Building loads all the model's billions of weights from memory — one full trip per token.
- What the tilde in and the mean ::: Tilde marks a draft guess; means "drawn by dice-roll from" a distribution.
- Which model is and which is ::: = powerful/target (big, accurate, slow); = quick/draft (small, fast, rough).
- What controls ::: How many tokens the draft guesses before the target verifies.
- What decides ::: The probability of accepting a draft token: always if , else with chance .
- What is for ::: The rescaled "leftover target desire" we resample from after a rejection, to stay unbiased.
- What and mean ::: = per-token acceptance chance; = average tokens produced per cycle.
Related foundations you may want fresh: 6.1.11-Model-quantization, 6.2.1-Distributed-training.