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.
- 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
- 1Draft k tokens cheaply
- 2Verify them in one big pass
- 3Accept the matching prefix
- 4Continue from there
Where it is used
Lower latency.
Watch out for
Gains depend on the draft acceptance rate.