通过动态生成与优化决策,提升多候选推测解码速度
Improving Multi-candidate Speculative Decoding
- 用目标模型初始化多候选序列,减少生成偏差
- 动态调整长度并使用感知拓扑的掩码,适应不同生成阶段
- 引入决策模型实现早期停止,适合高并发推理场景
推测解码(SD)通过低复杂度的草稿模型提出候选词,并由大模型验证以加速大语言模型推理。多候选推测解码(MCSD)在每步采样多个候选词并行验证,提高采纳率、缩短生成时间。现有方法依赖草稿模型初始化多候选序列,采用固定长度和树状注意力结构,难以应对草稿与目标模型输出分布差异,尤其在动态生成中表现不佳。本文提出新版本MCSD:引入目标模型初始化的多候选生成、动态切片拓扑感知因果掩码以支持动态长度调整,并设计决策模型优化早期停止。在Llama 2-7B及其变体上实验,使用JackFram 68M作为草稿模型,在三个基准测试中相较基线最多提速27.5%。同时评估了不同草稿模型下目标模型初始化对输出质量的影响。
原文摘要 · Abstract (English)
Speculative Decoding (SD) is a technique to accelerate the inference of Large Language Models (LLMs) by using a lower complexity draft model to propose candidate tokens verified by a larger target model. To further improve efficiency, Multi-Candidate Speculative Decoding (MCSD) improves upon this by sampling multiple candidate tokens from the draft model at each step and verifying them in parallel, thus increasing the chances of accepting a token and reducing generation time. Existing MCSD methods rely on the draft model to initialize the multi-candidate sequences and use static length and tree attention structure for draft generation. However, such an approach suffers from the draft and target model's output distribution differences, especially in a dynamic generation context. In this work, we introduce a new version of MCSD that includes a target model initialized multi-candidate generation, a dynamic sliced topology-aware causal mask for dynamic length adjustment, and decision models to optimize early stopping. We experimented with our method on Llama 2-7B and its variants and observed a maximum 27.5% speedup compared to our MCSD baseline across three benchmarks with Llama 2-7B as the target model and JackFram 68M as the draft model. Additionally, we evaluate the effects of using the target model initialized multi-candidate process with different draft models on output quality.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。