用词元预测未来两步,提升检索式生成速度与准确性。
LogitSpec: Accelerating Retrieval-based Speculative Decoding via Next Next Token Speculation
- 基于上一个词元的逻辑值,预估下两个词元,扩大检索范围。
- 在多个文本生成任务中实现最高2.61倍加速,每步平均接受3.28个词元。
- 无需训练、可直接接入现有模型,适合部署优化场景。
推测解码(SD)通过小模型提前生成候选词元,再由目标模型并行验证,成为大模型推理加速的有力方法。为降低生成开销,现有研究尝试以检索方式生成候选词元,但常因匹配不准确导致效果不佳。为此,本文提出LogitSpec,利用最后一个词元的逻辑值不仅预测下一个词元,还可推测下下个词元,从而扩展检索范围,更精准地找到合适参考作为候选。该方法分两步:(1)用最后词元的逻辑值推测下下个词元;(2)同时检索下一个和下下个词元的相关参考。LogitSpec无需训练,可即插即用,轻松集成至现有大模型推理框架。大量实验表明,其在多种文本生成基准上实现最高2.61倍加速,平均每解码步接受3.28个词元。代码已开源:https://github.com/smart-lty/LogitSpec。
原文摘要 · Abstract (English)
Speculative decoding (SD), where a small draft model is employed to propose draft tokens in advance and then the target model validates them in parallel, has emerged as a promising technique for LLM inference acceleration. Many endeavors to improve SD are to eliminate the need for a draft model and generate draft tokens in a retrieval-based manner in order to further alleviate the drafting overhead and significantly reduce the difficulty in deployment and applications. However, retrieval-based SD relies on a matching paradigm to retrieval the most relevant reference as the draft tokens, where these methods often fail to find matched and accurate draft tokens. To address this challenge, we propose LogitSpec to effectively expand the retrieval range and find the most relevant reference as drafts. Our LogitSpec is motivated by the observation that the logit of the last token can not only predict the next token, but also speculate the next next token. Specifically, LogitSpec generates draft tokens in two steps: (1) utilizing the last logit to speculate the next next token; (2) retrieving relevant reference for both the next token and the next next token. LogitSpec is training-free and plug-and-play, which can be easily integrated into existing LLM inference frameworks. Extensive experiments on a wide range of text generation benchmarks demonstrate that LogitSpec can achieve up to 2.61 $\times$ speedup and 3.28 mean accepted tokens per decoding step. Our code is available at https://github.com/smart-lty/LogitSpec.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。