Speculative Sampling
Definition
Speculative Sampling is a method for accelerating text generation where a small (draft) model quickly generates several candidate tokens, and a large model checks and accepts or rejects them. This reduces the number of sequential calls to the large model.
Algorithm
graph TD
A[Draft model] -->|K tokens| B[Large model]
B -->|Verify| C{Acceptance}
C -->|Accepted| D[Continue generation]
C -->|Rejected| E[Regenerate]
Advantages
- Accelerates inference by 2–3 times without loss of quality.
- Compatible with existing models without fine-tuning.
- Reduces latency for interactive applications.