Speculative decoding

Speculative decoding speeds up text generation by having a small, fast draft model propose several tokens that the large model then checks in one pass, producing the same output distribution as the large model alone.

Large language models write one token at a time, and each token needs a full pass through the model. That makes generation slow in a particular way: the chips spend much of their time waiting for the model's weights to arrive from memory rather than doing arithmetic. Checking several tokens at once costs little more than producing one. Speculative decoding exploits that gap.

The method pairs the large target model with a much smaller draft model. The draft model quickly guesses the next few tokens. The target model then scores all of those guesses in a single parallel pass. Guesses it agrees with are kept; at the first one it would not have produced, the rest are thrown away and the target model's own choice is used instead. If the draft model guessed four tokens and the first three were accepted, the large model has advanced four tokens, three accepted guesses plus its own correction, for roughly the cost of one step.

The important property is that nothing is lost. A modified acceptance rule, a form of rejection sampling, guarantees that the final text follows exactly the probability distribution the large model would have produced on its own. This is what separates speculative decoding from simply using a smaller model: the answers are the large model's answers, only faster.

The idea was published independently twice. Yaniv Leviathan, Matan Kalman and Yossi Matias posted Fast Inference from Transformers via Speculative Decoding in November 2022, reporting a 2 to 3 times speed-up on T5-XXL with identical outputs and no retraining. In February 2023 Charlie Chen and colleagues described speculative sampling and reported 2 to 2.5 times faster decoding of the 70-billion-parameter Chinchilla model in a distributed setup.

The speed-up depends on how often the draft model guesses right, which varies with the task and with how closely the draft model matches the target. It also uses extra computation, since rejected guesses are wasted work, so it helps most when hardware is underused, as with single users waiting on a chatbot, and less when a server is already running large batches. Open-source serving engines such as vLLM support it for exactly that low-load, memory-bound case.

Common questions

What is speculative decoding?

It is an inference technique in which a small draft model proposes several upcoming tokens and a large target model verifies them all at once. Accepted tokens are kept, so the large model advances several tokens per step instead of one, making generation faster.

Does speculative decoding change the model's output?

No. The acceptance rule is designed so the output follows exactly the same probability distribution as the large model running alone. Leviathan and colleagues describe the outputs as identical to standard decoding.

How much faster is speculative decoding?

The original papers reported 2 to 3 times faster generation on T5-XXL and 2 to 2.5 times on the 70-billion-parameter Chinchilla model. Real gains vary with how well the draft model predicts the target model, the type of text and how busy the hardware already is.

What is a draft model?

A draft model is the small, fast model in speculative decoding that guesses upcoming tokens for the large model to verify. It is often a smaller model from the same family, so that it shares a tokenizer and tends to make similar predictions.

Finding more

Search for "speculative decoding", "speculative sampling" or "draft model" to follow the technique and its later variants. The original papers on arXiv explain the method and its guarantee clearly, and the documentation of open-source inference engines shows how it is used in practice. Treat speed-up figures as specific to the models, hardware and prompts they were measured on.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.