What is Speculative decoding?
Speeding up inference by having a small model draft several tokens ahead and a large model verify them together, accepting the correct ones at once.
Japanese name: 投機的デコーディング
Speeding up inference by having a small model draft several tokens ahead and a large model verify them together, accepting the correct ones at once.
Japanese name: 投機的デコーディング
First, a small model drafts several tokens ahead. Next, the large model processes the sequence including the draft in a single forward pass. This shows, all at once, which token the large model itself would choose at each position of the draft. The two are compared from the front, and the draft is accepted up to where they agree. At the first position where they disagree, the large model's token is used and the rest is discarded. If the first 3 tokens of a 5-token draft agree, for example, 3 + 1 = 4 tokens are settled in one pass.
Decode tends to be memory-bound when the batch is small. Whether the large model computes one token or several together, the time to read its weights is almost the same. If the draft is often right, the large model is called fewer times. When it is wrong, the computation spent on the draft is wasted. The benefit depends mainly on how often the draft is right and on how light the small model is. Easy passages can be guessed well even by a small model, and that is where calls are saved.
Whether a token is accepted is decided by the large model's computation. With the method that picks the most probable token each time, the output is the same as if the large model had generated it alone. With methods that pick tokens according to their probabilities, a dedicated procedure decides acceptance and rejection probabilistically. This keeps the distribution of the output the same as the large model's. No retraining or change of model structure is needed. The two models normally have to split text into tokens in the same way.
Answer: B. A small model drafts several tokens ahead, the large model verifies them together in one pass, and the correct ones are accepted at once
Decode is memory-bound, so the large model spends nearly the same time reading weights whether it computes one token or several. So a light, small model predicts the next few tokens, the large model checks them all in a single forward pass, and the correct ones are accepted at once. If the predictions are often right, the large model is invoked fewer times, speeding up output without changing its quality.
Not in the basic method. The small model's draft is only a candidate, and the large model decides whether to accept it. At a position where they disagree, the large model's token is used.
The output stays correct, but there is no speed-up. The draft after a missed position is discarded, so that computation is wasted. Generation can even become slower by the time spent running the small model.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.