Continue where you left off ×
Speculative Decoding: The Bigram Drafts, the GPT Checks
Inference at Scale · Open board
The Inference at Scale board draws the counter where the model’s weights are wheeled past once for every character. This lesson builds the trick that gets more than one character out of each trip. Stage 5 of the serving series, after Build Your Own Inference Engine .
Before you start. The Prefix Cache: Computed Once made the start of a request cheaper. This stage attacks the other end, the long run of one-character steps that follows. You need the cache from Serve 01: The KV Cache , because a step here feeds new characters into a cache that already holds the past. You need the bigram from The Bigram Model , a table that guesses the next character from the last one alone. Sampling and What Scale Buys gave the GPT that picks the characters. Inference at Scale (why an LLM is fast, and cheap) told this story without code.
The idea in 30 seconds
A decode step costs about the same whether it carries one new character or several, because it is limited by streaming the weights.
A cheap draft model guesses k characters, and the big model checks them all in one verification pass.
You keep guesses up to the first mismatch and take the big model’s own pick there, so a pass always yields at least one character.
A rejected guess costs no extra pass, only a rollback of the cache to the last kept character.
The text is identical to plain decoding, and the acceptance rate, set by the draft’s quality, decides how many characters a pass yields.
Read the story
Lesson 75 of 83 in AI
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson November 2022: a Google paper notices that most words are easy What decides the speedup is acceptance What the run shows What the toy cannot show Eight guesses, one visit Cutting her notes back after the miss All of it in code Terms it explains: draft, verification pass, rollback, acceptance rate.
Review AI
Mark as read Saved in this browser, and to your account when you sign in.