Skip to content
StackDecode
System Design
19. AI System Design and LLM InfrastructureAnimated

Speculative Decoding

A small model drafts, a big model verifies.

The idea

The draft proposes several tokens, and the big model checks them in a single pass, accepting the matching prefix.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

small draft model proposes 4 tokens quicklyd1d2d3d4
  • accepted
  • rejected

Round 1: the cheap draft model guesses the next 4 tokens.

produced:
0
1/10

The output is identical to running the big model alone, only faster.

Step by step

  1. 1Draft k tokens cheaply
  2. 2Verify them in one big pass
  3. 3Accept the matching prefix
  4. 4Continue from there

Where it is used

Lower latency.

Watch out for

Gains depend on the draft acceptance rate.

Related