LLM Library
Running and Using LLMsAnimated
Speculative Decoding
A small model guesses ahead and a big model checks.
The idea
A cheap draft model proposes several tokens. The large model verifies them in one pass and keeps the correct prefix. The answer is the same as the large model alone, only faster.
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 several tokens
- 2Verify them in one large-model pass
- 3Accept the matching prefix
- 4Continue from the first mismatch
Where it is used
Lower latency serving.
Watch out for
The gain depends on how often the draft is right.