Fast Inference from Transformers via Speculative Decoding

Yaniv Leviathan, Matan Kalman, Yossi Matias
11/30/2022
2,406 citations
cs.LGcs.CL
transformer-attention

No official code found. Best implementation: romsto/Speculative-Decoding (117 stars, MIT, last commit 2024-12-02). 1 more below.

Abstract

Inference from large autoregressive models like Transformers is slow - decoding K tokens takes K serial runs of the model. 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.

Show full abstract

At the heart of our approach lie the observations that (1) hard language-modeling tasks often include easier subtasks that can be approximated well by more efficient models, and (2) using speculative execution and a novel sampling method, we can make exact decoding from the large models faster, by running them in parallel on the outputs of the approximation models, potentially generating several tokens concurrently, and without changing the distribution. Our method can accelerate existing off-the-shelf models without retraining or architecture changes. We demonstrate it on T5-XXL and show a 2X-3X acceleration compared to the standard T5X implementation, with identical outputs.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
romsto/Speculative-DecodingCommunity117–MIT2024-12-02
kyegomez/Speculative-DecodingCommunity9–––
MIT

Implementation of the paper Fast Inference from Transformers via Speculative Decoding, Leviathan et al. 2023.

11725Apr 22, 20241 years agoMIT
fast-inferencellmllm-inferencellm-optimizationspeculative-decoding

My own implementation of "Fast Inference from Transformers via Speculative Decoding"

91

Similar Papers

Cite this paper

@article{leviathan2022fast,
  title  = {Fast Inference from Transformers via Speculative Decoding},
  author = {Yaniv Leviathan and Matan Kalman and Yossi Matias},
  year   = {2022},
  eprint = {2211.17192},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2211.17192}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2211.17192.svg)](https://codeofpaper.com/paper/2211.17192)

Discussion