Speculative decoding is a method that speeds up generation without changing the output distribution by having a small, fast "approximation model" draft several tokens ahead and then verifying them all in a single pass of the large "target model". It was published in 2022 by Leviathan, Kalman, and Matias at Google Research (ICML 2023). On the 11-billion-parameter T5-XXL, it achieves a 2 to 3× speedup without changing the output at all.
Autoregressive models such as the Transformer need to run the model times in sequence to generate tokens. Moreover, inference with large models is often bound by memory bandwidth and communication rather than by the amount of computation, leaving compute resources to spare. The idea of this method is therefore to use the spare compute by increasing the number of tokens verified at once.
It is based on "speculative execution" in processors. As in branch prediction, work that may be needed is carried out ahead of time; if it turns out to be needed, the result is used, and otherwise it is discarded. The paper extends this to the probabilistic setting. As an analogy, it is like a veteran editor (the large model) reading several lines drafted by a newcomer (the small model) all at once, adopting them up to the point where they are correct, and fixing only the first mistake personally.
The rule for accepting or rejecting drafts (speculative sampling) is the same as speculative sampling, published independently at around the same time by Chen et al. (2023) at DeepMind. This article covers what the paper by Leviathan et al. puts at its center: the analysis that estimates speed and compute from the acceptance rate, and how to choose the approximation model. Note that the two papers use opposite notation; this article follows Leviathan et al. and writes the target model as and the approximation model as .

