让大模型推理更快更准,用小模型预估多条路径并动态调整验证数量。
Dynamic-Width Speculative Beam Decoding for Efficient LLM Inference
- 用小模型生成多条候选路径,大模型按其分布验证,提升输出质量。
- 根据上下文动态调整验证的路径数,平衡速度与准确率,实测提速1.5倍以上。
- 支持并行验证多条路径,适合需要高质量输出的实时应用如对话系统。
大型语言模型在众多实际任务中表现出色,但其自回归特性导致推理缓慢且成本高。推测解码通过使用小型辅助模型预估未来标记,并由大模型同时验证,实现1-2倍加速。尽管推测解码能匹配多项式采样的分布,但该方法易产生次优结果;而束搜索(beam sampling)因保留多条候选序列,被广泛认为可生成更高品质输出。本文探索将推测解码与束搜索结合的新方法。面临四大挑战:(1) 如何基于小模型生成的草案序列,从大模型分布中生成多个序列;(2) 如何动态优化束宽以平衡效率与精度;(3) 如何高效并行验证多个草案;(4) 如何缓解束搜索带来的额外内存开销。为此,提出动态宽度推测束解码(DSBD)。首先设计一种新草案与验证机制,基于小模型的束搜索轨迹生成符合大模型分布的多条序列;其次引入自适应机制,根据上下文动态调节束宽;此外,扩展树状并行验证以同时处理多棵搜索树,加速验证过程;最后,提出简单修改方案,缓解束搜索的内存开销。
原文摘要 · Abstract (English)
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...
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。