Preprint
Large Language Models

Fast inference from transformers via speculative decoding

January 1, 2023

0

Citations

0

Influential Citations

Venue

2023

Year

Abstract

… In this work we introduce speculative decoding - an algorithm to sample from autoregressive models faster without any changes to the outputs, by computing several tokens in parallel. …

Analysis

Why This Paper Matters

Speculative decoding addresses a critical bottleneck in deploying large language models (LLMs): inference latency. Autoregressive generation, where tokens are produced one at a time, becomes increasingly slow as models grow, limiting real-time applications like chatbots, code completion, and interactive assistants. By enabling parallel token generation without sacrificing output quality, this work provides a practical solution that can be integrated into existing systems with minimal changes.

The significance lies in its theoretical guarantee: the algorithm produces exactly the same outputs as standard autoregressive sampling. This is a key differentiator from other acceleration methods that trade off quality for speed. For practitioners, this means they can deploy faster inference without retraining models or altering their behavior, making it highly attractive for production environments.

Technical Contributions

  • Speculative decoding algorithm: Combines a fast draft model with a slower target model. The draft model proposes multiple tokens in parallel, and the target model verifies them, accepting or rejecting based on a rejection sampling scheme that ensures exact output distribution.
  • Parallel token generation: Unlike traditional autoregressive decoding, speculative decoding processes multiple tokens simultaneously, leveraging modern hardware's parallel computation capabilities.
  • Theoretical correctness: The algorithm is proven to sample from the exact target distribution, with no approximation or degradation in output quality.
  • Implementation simplicity: Can be applied to any autoregressive model without architectural changes, requiring only a draft model (which can be a smaller or distilled version of the target).

Results

The paper demonstrates speedups of 2x to 3x on large transformer models (e.g., T5-XXL, GPT-like architectures) across various tasks including machine translation and text summarization. The gains are consistent across different sequence lengths and batch sizes, with larger models benefiting more due to the higher cost of sequential token generation. Importantly, the output quality remains identical to standard decoding, as verified by perplexity and human evaluation.

Significance

Speculative decoding has broad implications for the AI field. It enables faster inference for LLMs without compromising output quality, which is crucial for real-time applications and reducing operational costs. The method is model-agnostic and can be combined with other optimization techniques like quantization and pruning. This work opens avenues for further research into efficient draft model design and adaptive speculation strategies, potentially making large-scale deployment of LLMs more accessible and sustainable.