arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2409.16560cs.AI
收藏

用于高效 LLM 推理的动态宽度推测束解码

Dynamic-Width Speculative Beam Decoding for Efficient LLM Inference

University of California Los Angeles(加州大学洛杉矶分校)

Zongyue Qin, Zifan He, Neha Prakriya, Jason Cong, Yizhou Sun

AI总结:

本文提出 DSBD,将推测解码与束采样结合,通过多序列草拟验证、自适应束宽、多树并行验证及内存优化提升 LLM 推理效率与质量。

摘要:

大语言模型(LLM)已在众多现实任务中表现出卓越性能。然而,这些模型的自回归特性使推理过程缓慢且成本高昂。推测解码已成为一种有前景的解决方案,它利用较小的辅助模型草拟未来 token,随后由较大模型同时验证这些 token,实现 1–2 倍的加速。尽管推测解码能够匹配与多项式采样相同的分布,但多项式采样本身容易产生次优输出;相比之下,束采样因在每一步维护多个候选序列而被广泛认为能够生成更高质量的结果。本文探索了将推测解码与束采样进行新颖结合。但这面临四个关键挑战:(1)在给定小模型草拟序列的情况下,如何从大模型的分布生成多个序列;(2)如何动态优化束数量,以平衡效率与准确性;(3)如何高效地并行验证多个草拟结果;以及(4)如何解决束采样固有的额外内存成本。为应对这些挑战,我们提出动态宽度推测束解码(DSBD)。具体而言,我们首先引入一种新颖的草拟与验证方案,基于小模型的束采样轨迹,生成遵循大模型分布的多个序列。随后,我们引入自适应机制,根据上下文动态调整束数量,从而优化效率和效果。此外,我们扩展基于树的并行验证,使其能够同时处理多个树,以加速验证过程。最后,我们说明对算法的一个简单修改,以缓解束采样的内存开销。

英文摘要:

Large language models (LLMs) have shown outstanding performance across numerous real-world tasks. However, the autoregressive nature of these models makes the inference process slow and costly. Speculative decoding has emerged as a promising solution, leveraging a smaller auxiliary model to draft future tokens, which are then validated simultaneously by the larger model, achieving a speed-up of 1-2x. Although speculative decoding matches the same distribution as multinomial sampling, multinomial sampling itself is prone to suboptimal outputs, whereas beam sampling is widely recognized for producing higher-quality results by maintaining multiple candidate sequences at each step. This paper explores the novel integration of speculative decoding with beam sampling. However, there are four key challenges: (1) how to generate multiple sequences from the larger model's distribution given drafts sequences from the small model; (2) how to dynamically optimize the number of beams to balance efficiency and accuracy; (3) how to efficiently verify the multiple drafts in parallel; and (4) how to address the extra memory costs inherent in beam sampling. To address these challenges, we propose dynamic-width speculative beam decoding (DSBD). Specifically, we first introduce a novel draft and verification scheme that generates multiple sequences following the large model's distribution based on beam sampling trajectories from the small model. Then, we introduce an adaptive mechanism to dynamically tune the number of beams based on the context, optimizing efficiency and effectiveness. Besides, we extend tree-based parallel verification to handle multiple trees simultaneously, accelerating the verification process. Finally, we illustrate a simple modification to our algorithm to mitigate the memory overhead of beam sampling...

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

↑