arXiv:2504.05598cs.CLcs.LG2025-04被引 8

动态调整生成层与推测长度,让大模型推理快1.6倍以上

DEL: Context-Aware Dynamic Exit Layer for Efficient Self-Speculative Decoding

  • 根据上下文动态选择生成层和推测长度,提升推理效率
  • 在多种任务上实现2.16至2.62倍加速,优于现有方法
  • 无需重训练,可直接接入现有推理系统,适合部署优化

推测解码(Speculative Decoding, SD)是一种广泛用于加速大语言模型(LLM)推理的技术,能在不降低生成质量的前提下显著提升速度。其核心是先用轻量模型快速生成多个候选词,再由目标LLM并行验证。现有方法中,早期退出(early-exit)技术利用主模型的部分层进行草稿生成,其余层用于验证,从而减少内存和计算开销。然而,该方法的性能高度依赖于草稿层选择和每轮推测的词数(推测长度),而以往工作采用静态超参数配置。我们发现这些参数不仅任务相关,且随上下文动态变化。为此,提出DEL(Dynamic Exit Layer),一种即插即用的动态策略:通过实时跟踪各层生成词的接受率,启发式选择最优的出口层与推测长度。在多种模型与下游任务上的实验表明,DEL相比原生自回归解码实现2.16×~2.62×加速,优于当前最先进方法(峰值2.43×),最高提升0.19×。代码已开源。

原文摘要 · Abstract (English)

Speculative Decoding (SD) is a widely used approach to accelerate the inference of large language models (LLMs) without reducing generation quality. It operates by first using a compact model to draft multiple tokens efficiently, followed by parallel verification using the target LLM. This approach leads to faster inference compared to auto-regressive decoding. While there are multiple approaches to create a draft model, one promising approach is to use early-exit methods. These methods draft candidate tokens by using a subset of layers of the primary model and applying the remaining layers for verification, allowing a single model to handle both drafting and verification. While this technique reduces memory usage and computational cost, its performance relies on the choice of the exit layer for drafting and the number of tokens drafted (speculation length) in each SD round. Prior works use hyperparameter exploration to statically select these values. However, our evaluations show that these hyperparameter values are task-specific, and even within a task they are dependent on the current sequence context. We introduce DEL (Dynamic Exit Layer), a plug-and-play method that adaptively selects the exit layer and speculation length during inference. DEL dynamically tracks the token acceptance rate if the tokens are drafted at each layer of an LLM and uses that knowledge to heuristically select the optimal exit layer and speculation length. Our experiments across a broad range of models and downstream tasks show that DEL achieves overall speedups of $2.16\times$$\sim$$2.62\times$ over vanilla auto-regressive decoding and improves upon state-of-the-art SD methods, which peak at $2.43\times$, by up to $0.19\times$. The code is available at https://github.com/hoenza/DEL.

推理加速推测解码动态调度

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。