arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2310.15141cs.LGcs.CLcs.DScs.ITmath.IT
收藏

SpecTr:通过最优传输实现快速推测解码

SpecTr: Fast Speculative Decoding via Optimal Transport

Google Research(谷歌研究院)

Ziteng Sun, Ananda Theertha Suresh, Jae Hun Ro, Ahmad Beirami, Himanshu Jain, Felix Yu

AI总结:

本文将推测解码建模为带隶属代价的最优传输问题,提出支持 k 个 token 候选、接受概率达 (1-1/e) 乘法近似最优的 SpecTr,实现无损且最高 2.13 倍的解码加速。

摘要:

从大型语言模型进行自回归采样已在多项自然语言任务中取得最先进结果。然而,自回归采样一次只生成一个 token,因此速度缓慢,在某些任务中甚至令人无法接受。加速采样的一种方法是 speculative decoding(推测解码):使用一个小模型采样一个 draft(草稿,即一个 token 块或 token 序列),然后由大型语言模型并行地为草稿中的所有 token 打分。草稿中的一部分 token 会被接受(其余则被拒绝),其依据是一种统计方法,用以保证最终输出遵循大型语言模型的分布。在本工作中,我们通过带有 membership cost(隶属代价)的最优传输(OT)视角,对推测解码提供了一种有原则的理解。该框架可被视为著名的 maximal-coupling(最大耦合)问题的扩展。这一新表述使我们能够推广推测解码方法,允许在 token 层级使用一组 k 个候选,从而带来改进的最优隶属代价。我们表明,最优草稿选择算法(传输计划)可通过线性规划计算,而其已知最佳运行时间关于 k 是指数级的。随后,我们提出一种有效的草稿选择算法,其接受概率在乘法意义上达到 (1-1/e)-最优。此外,它的计算时间几乎与单个 token 的定义域大小呈线性关系。利用这种 new draft selection(新草稿选择)算法,我们开发了一种名为 SpecTr 的新型自回归采样算法,它可在解码中提供加速,同时确保解码输出不存在质量下降。我们通过实验证明,对于最先进的大型语言模型,所提方法在标准基准测试上实现了 2.13 倍的挂钟时间加速,相比推测解码进一步获得 1.37 倍加速。

英文摘要:

Autoregressive sampling from large language models has led to state-of-the-art results in several natural language tasks. However, autoregressive sampling generates tokens one at a time making it slow, and even prohibitive in certain tasks. One way to speed up sampling is $\textit{speculative decoding}$: use a small model to sample a $\textit{draft}$ (block or sequence of tokens), and then score all tokens in the draft by the large language model in parallel. A subset of the tokens in the draft are accepted (and the rest rejected) based on a statistical method to guarantee that the final output follows the distribution of the large model. In this work, we provide a principled understanding of speculative decoding through the lens of optimal transport (OT) with $\textit{membership cost}$. This framework can be viewed as an extension of the well-known $\textit{maximal-coupling}$ problem. This new formulation enables us to generalize the speculative decoding method to allow for a set of $k$ candidates at the token-level, which leads to an improved optimal membership cost. We show that the optimal draft selection algorithm (transport plan) can be computed via linear programming, whose best-known runtime is exponential in $k$. We then propose a valid draft selection algorithm whose acceptance probability is $(1-1/e)$-optimal multiplicatively. Moreover, it can be computed in time almost linear with size of domain of a single token. Using this $new draft selection$ algorithm, we develop a new autoregressive sampling algorithm called $\textit{SpecTr}$, which provides speedup in decoding while ensuring that there is no quality degradation in the decoded output. We experimentally demonstrate that for state-of-the-art large language models, the proposed approach achieves a wall clock speedup of 2.13X, a further 1.37X speedup over speculative decoding on standard benchmarks.

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

↑