Module 3 · Turning scores into text

Speculative decoding: a small model guesses, a big model checks

In this lesson

  • 8 min read
  • 5 reading sections
  • Knowledge check
  • Lesson 8 of 10 in this chapter

This chapter’s goalChoose and justify a decoding strategy for a given task, read raw log-probabilities to get a usable confidence signal, force structurally valid output without prompt-begging, and explain why identical requests at temperature zero can still differ.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
One round of speculative decodingDraft fourtokens with asmall modelRoughly a tenthof the targetmodel’s cost pertokenCheck all fourin one targetpassThe causal maskmeans eachposition’soutput dependsonly on whatprecedes itAccept by therejection-samplingruleNot “does thetop choicematch”: a rulethat preservesthe target’s owndistributionStop at thefirstdisagreementTake thetarget’s tokenthere and throwthe rest of thedraft awayFive tokens forone targetpass, or oneand a littlewasteGains of two tothree times, setentirely by theacceptance rateDecode is memory-bound, so checking five tokens costs barely more than checking one: the weights areread once either way. The output distribution is provably identical to sampling from the target alone,which is why this is a speed change and not a quality trade.
Decode is memory-bound, so checking five tokens costs barely more than checking one: the weights are read once either way. The output distribution is provably identical to sampling from the target alone, which is why this is a speed change and not a quality trade.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 6Free · no account needed
Lesson steps

The idle machine

Decoding is memory-bound. Each step reads every weight of the model to produce a single token, and the arithmetic units spend most of their time waiting. That means checking five tokens costs barely more than checking one: the weights are read once either way.

Speculative decoding exploits this directly, and it is one of the few optimisations that is free of trade-offs.

The algorithm

  1. A small, fast draft model generates the next k tokens, say four. This is cheap: a 1B draft model is roughly a tenth of the cost of a 70B target model per token.
  2. The large target model processes all four in a single forward pass, producing its own distribution at each of those positions, which it can do because the causal mask means each position’s output depends only on what precedes it.
  3. Compare. Accept the drafted tokens as long as the target model agrees, by a rule that provably preserves the target’s distribution. At the first disagreement, discard the rest and take the target’s own token.
  4. Repeat.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the AI, Actually Explained exam.

Stuck on something?Ask Anjali, your AI tutor

How to cite: Addaly (2026) ‘Speculative decoding: a small model guesses, a big model checks’, in How a Language Model Actually Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/how-llms-work/speculative-decoding (Accessed: 29 November 2026).