Learn / Lessons

Speculative decoding

How can a model write faster? Meet speculative decoding. Today we're looking at the model itself. Normally, the large model adds one token at each step.

Chapters

  1. 0:00Introduction
  2. 0:05Where this fits: The AI stack
  3. 0:09Draft, then check: Guess ahead, then check
  4. 0:29When it helps: Good guesses pay
  5. 0:45Choosing words: Turn the dial
  6. 0:55Many users: Memory in blocks
  7. 1:05Wrap up
Read the transcript

Introduction

How can a model write faster? Meet speculative decoding.

Where this fits: The AI stack

Today we're looking at the model itself.

Draft, then check: Guess ahead, then check

Normally, the large model adds one token at each step. With speculative decoding, something quicker drafts a few tokens first. That can be a small model, or another method. The large model then checks those drafts together. It keeps the ones that pass, up to the first miss, and puts its own token there.

When it helps: Good guesses pay

With good guesses, one big step can give several tokens, so tok/s goes up. With poor guesses you gain little, and drafting still costs work and memory. The research paper's method keeps the large model's output odds unchanged.

Choosing words: Turn the dial

For each token, there are many possible choices. Temperature changes how adventurous the pick is. Top k and top p trim the list of choices.

Many users: Memory in blocks

Serving lots of people? Wasted cache memory limits how many fit. Paged Attention hands it out in small blocks, so little goes to waste.

Wrap up

Draft, check, and choose. That's how a reply speeds along.

Sources

More lessons