Here’s the intuition (and a sketch of the math) for why—even though we “draft” tokens from a smaller model—the accepted tokens end up exactly distributed as if we’d sampled autoregressively from the large model’s true distribution (p).
1. Speculative Decoding as Rejection Sampling
At each step, we do exactly the following:
- Proposal
– Draw (y) from a fast, smaller model (q(y)).
- Accept/Reject
– Compute the large model’s probability (p(y)).
– Accept (y) with probability
[
A(y) ;=;\min!\Bigl(1,;\frac{p(y)}{M,q(y)}\Bigr)
]
for some constant (M \ge \max_{y}\tfrac{p(y)}{q(y)}).
- Output
– If accepted, emit (y).
– If rejected, go back to (1) and sample a new proposal.
This is exactly classical rejection sampling. By well‐known results:
• The probability we propose (y) and accept it
[
q(y); \times; A(y)
;=;
q(y); \times; \frac{p(y)}{M,q(y)}
;=;
\frac{p(y)}{M},.
]
• Renormalizing over all possible (y) then gives exactly (p(y)).
In other words, the distribution of accepted samples is identical to (p).
2. Multi-token Drafting & Parallel Verification
Leviathan speeds this up by:
- Proposing a block of (k) tokens (,(y_1,\dots,y_k)) from (q) in one go.
- Running the large model once over the entire block to get (p(y_i\mid \text{context},,y_{<i})).
- Accepting each (y_i) in turn with
[
A_i ;=;
\min!\Bigl(1,,\frac{p(y_i\mid \text{ctx},,y_{<i})}
{q(y_i\mid \text{ctx},,y_{<i})}\Bigr).
]
Because each token’s acceptance is still governed by the correct ratio
(\tfrac{p}{q}), the marginal distribution of the first accepted token—and then the second, and so on—remains exactly the same as if you had sampled directly from (p) one token at a time.
3. Why “Identity of Distributions” Holds
- Correct Ratio
We compare (p(y)) vs. (q(y)) at each position, so we’re faithfully enforcing
the large model’s true probabilities.
- Rejection Sampling Guarantee
By accepting proposals with probability proportional to (p/q), the accepted tokens follow (p) exactly.
- No Bias from Parallelism
Batching (k) tokens only changes how we compute; it does not change what distribution we’re sampling from.
🎯 Bottom line:
Speculative decoding is nothing more (and nothing less) than an instance of rejection sampling done in parallel. That’s why—even though we “draft” with a small model—the final tokens you output are distributed exactly according to the original large‐model distribution (p).