Abstract
Autoregressive (AR) decoding remains the dominant paradigm for sequence-to-sequence generation, yet its sequential nature leads to significant latency and underutilization of parallel hardware. We present Speculative Decoding (SpecDec), a novel framework designed to accelerate AR generation through speculative execution. SpecDec utilizes a lightweight, independent "Spec-Drafter" to generate multiple candidate tokens, which are subsequently verified in parallel by the target AR model. By introducing a relaxed verification criterion (Spec-Verify), we significantly increase the token acceptance rate. Our experiments demonstrate that SpecDec achieves up to a 5× speedup on standard Transformer architectures while maintaining generation quality comparable to traditional greedy and beam search methods.
1. Introduction
Modern text generation models, such as Transformers, typically employ autoregressive decoding, where each token is predicted based on the preceding sequence. While accurate, this process is computationally inefficient on GPUs, which are optimized for parallel workloads. Previous attempts to mitigate this, such as Blockwise Decoding, achieved only modest speedups (1.4×–2×) due to rigid verification processes and simplistic drafting mechanisms. SpecDec revitalizes the "draft-then-verify" paradigm by optimizing both the drafting architecture and the verification logic.
2. Methodology
SpecDec's efficiency stems from two primary components: the Spec-Drafter and the Spec-Verification mechanism.
2.1 Spec-Drafter
The Spec-Drafter is a specialized, lightweight model designed to align with the target model's behavior while minimizing latency. Unlike prior work that integrated drafting heads into the main model, Spec-Drafter is an independent model with a deep-encoder and a very shallow decoder (e.g., 2 layers). This design adheres to the "Capability Principle"—ensuring the drafter is sophisticated enough to mimic the main model—and the "Latency Principle"—ensuring the drafting phase does not become a bottleneck.
2.2 Spec-Verification
Standard verification is often too restrictive, discarding drafted tokens that do not exactly match the target model's top-1 prediction. Spec-Verification relaxes this by accepting a drafted token if it is among the top-$β$ candidates of the target model, provided the log-likelihood difference is within a threshold $τ$. This flexibility allows the system to bypass minor discrepancies that do not materially impact output quality, thereby increasing the number of tokens generated per forward pass of the large model.
3. Experimental Results
We evaluated SpecDec on WMT14 (EN↔DE), WMT16 (EN↔RO), and CNN/DailyMail benchmarks.
3.1 Speed and Efficiency
SpecDec achieved a 5× speedup over standard beam search on Transformer-base models. In scenarios involving already optimized deep-encoder models, it still provided a 2.5× to 3.3× improvement. Furthermore, the increased throughput led to a 4.2× reduction in carbon emissions, highlighting the framework's energy efficiency.
3.2 Qualitative Analysis
The relaxed verification mechanism ensures that generation quality remains high. Figure 6 demonstrates an example where the drafter's output is verified and partially corrected by the target model. The system successfully accepts multiple tokens in a single step, even when the drafter's prediction requires slight adjustment (e.g., correcting "worry" to "be").
4. Discussion and Conclusion
SpecDec effectively transforms the sequential AR decoding problem into a partially parallel one. By investing in a capable drafter and a flexible verification strategy, we achieve significant latency reductions. While the approach requires additional GPU memory to host the drafter model, the trade-off is highly favorable for real-time applications where latency is the primary constraint. Future work may explore self-drafting mechanisms or more complex tree-based verification to further push the boundaries of speculative generation.
Summary updated