Prompts Forms Resume Reports ★ Saved ★ Saved★ + Submit a tool
Models and algorithms

Speculative Decoding

About 3255 characters Updated Nov 30, 2026 25 views AI wiki

Speculative decoding is a decoding strategy that accelerates autoregressive text generation: a small, fast draft model guesses several tokens in a row, and the target large model verifies these guesses in one pass, keeping as much of the correct part as possible. The key is that it does not change the output distribution mathematically, making it an almost lossless acceleration method.

Core Principles

The fundamental bottleneck of autoregressive generation is serialization: every generated token requires a full forward pass, one pass of a large model is costly, and most of that time goes to moving parameters and caches from memory rather than being filled by computation. Speculative decoding tries to trade serial for parallel: the draft model is small and fast, so it first generates a stretch of candidate tokens autoregressively, say three to five; the target model then takes the original context together with that stretch as input and, in one forward pass, obtains its judgment on each candidate at each position.

The verification step follows a clever sampling rule: for each candidate token, compare the probabilities under the draft distribution and the target distribution and accept or reject it in proportion; once a position is rejected, resample a token from the target distribution and discard all candidates after that position. If every candidate is accepted, the next token given by the target model can be accepted as a bonus. The resulting sequence still strictly follows the target model's distribution in a statistical sense, so accuracy is lossless, while a single verification pass can produce several tokens, raising the effective output per step and achieving roughly two to three times the speedup. Variants include verifying several candidate branches at once with a tree structure, and letting the large model act as its own draft,

From a system perspective, it turns a forward pass that was filled by parameter movement into an operation that does a little more compute in exchange for producing several tokens, raising hardware utilization; in scenarios with low compute utilization this conversion often brings a clearer overall gain and more stable throughput.

Key Points

The acceptance rate determines the payoff: the closer the draft and target distributions are, the more candidates are accepted and the more obvious the speedup; when the two differ greatly, many candidates are discarded after verification and the gain degrades.

The choice of draft model is the engineering core: it can be a small model from the same family, a distilled model, or a lightweight prediction head attached to the same model, and speed, size and consistency must be weighed against each other.

Challenges under batching: different requests have different acceptance lengths, so lengths must be adjusted dynamically within a batch, which raises implementation complexity.

No accuracy loss is its trump card: compared with acceleration methods that affect quality, such as quantization and pruning, it hardly compromises on quality,

Training cost: to obtain a stable acceptance rate, the draft model often has to be trained on data generated by the target model, and this upfront investment cannot be ignored.

Common Misconceptions

It is easy to mistake speculative decoding for a shortcut approximation, when in fact the verification step guarantees distributional consistency and it is not a lossy compression. Another misunderstanding is that a longer draft is always better; overly long candidates raise the rejection probability and actually lower the average payoff.

Application Scenarios

Low-latency dialogue services, code completion, long-text generation, on-device and online inference, batch question-answering systems, and edge deployments that are compute-constrained but still require high throughput.