arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2211.17192cs.LGcs.CL
收藏

通过推测解码实现Transformer的快速推理

Fast Inference from Transformers via Speculative Decoding

Google Research(谷歌研究院)

Yaniv Leviathan, Matan Kalman, Yossi Matias

AI总结:

本文提出推测解码算法,通过并行计算和高效小模型近似,在不改变输出分布的前提下加速大型自回归模型推理,在T5-XXL上实现2至3倍加速且无需重新训练。

摘要:

从大型自回归模型(如Transformers)进行推理的速度很慢——解码K个token需要模型进行K次串行运行。在这项工作中,我们引入了推测解码——一种通过并行计算多个token来更快地从自回归模型中采样的算法,且不改变输出结果。我们方法的核心在于以下观察:(1)困难的语言建模任务通常包含更容易的子任务,这些子任务可以被更高效的模型很好地近似;(2)使用推测执行和一种新颖的采样方法,我们可以通过在近似模型的输出上并行运行大型模型,潜在地并发生成多个token,且不改变分布,从而加快大型模型的精确解码速度。我们的方法可以加速现有的现成模型,而无需重新训练或更改架构。我们在T5-XXL上进行了演示,与标准的T5X实现相比,显示出2倍至3倍的加速,且输出完全相同。

英文摘要:

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. 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑