Speculative Decoding

12 min read

A big model writes one token per step, and each step is slow. Speculative decoding lets a tiny, fast model guess the next few tokens. Then the big model checks all the guesses at once. The output is exactly what the big model would have written, often 2–3× faster.

New words

Decode
The phase where the model writes the answer one token at a time.
Draft model
A small, fast model that guesses the next few tokens.
Verify
The big model checks the draft guesses in a single pass.
Acceptance rate (α)
The share of draft guesses that the big model accepts.
Memory-bound
Speed is limited by reading data from memory, not by maths.
Batch
Many user requests that the GPU handles together.

What you will learn

  1. Why decoding is slow
  2. The trick: guess cheaply, verify in bulk
  3. Try it: watch the guesses get checked
  4. Same quality, guaranteed
  5. Where the draft comes from
  6. When it helps, and when it doesn’t
  7. In code
  8. In a real system
  9. Interview tip
  10. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap