scoring should not be signiﬁcantly slower for small 𝐾.
Modiﬁed Rejection Sampling
We require a method to recover the distribution of the target model from samples from the draft
model, and logits of said tokens from both models.
To achieve this, we introduce the following rejection sampling scheme of the drafted tokens. Given a
sequence of tokens 𝑥1𝑥𝑛, and𝐾draft tokens ˜𝑥𝑛¸1 ˜𝑥𝑛¸𝐾generated from 𝑝¹jº, we accept ˜𝑥𝑛¸1
with probability:
min
1𝑞¹˜𝑥𝑛¸1j𝑥1𝑥𝑛º
𝑝¹˜𝑥𝑛¸1j𝑥1𝑥𝑛º
We present speculative sampling, an algorithm for accelerating transformer
decoding by enabling the generation of multiple tokens from each transformer
call. Our algorithm relies on the observation that the latency of parallel
scoring of short continuations, generated by a faster but less powerful draft
model, is comparable to that of sampling a single token from the larger target
model. This is combined with a novel modified rejection sampling scheme which
preserves the distribution of the target model within hardware numerics. We
benchmark speculative sampling with Chinchilla, a 70 billion parameter language
model, achieving a 2-2.5x decoding speedup in a distributed setup, without
compromising the sample quality or making modifications to the model itself.
Charlie Chen Sebastian Borgeaud Geoffrey Irving Jean-Baptiste Lespiau Laurent Sifre John Jumper