用稀疏注意力提升大模型推理效率,效果不降反升
A Preliminary Study on the Promises and Challenges of Native Top-$k$ Sparse Attention
- 只保留最相关的上下文键值,实现高效解码
- 稀疏注意力在多个评测集上表现超越或持平全注意力
- 首次从熵角度解释稀疏注意力有效性的理论机制
大型语言模型在长上下文建模中应用日益广泛,但推理计算成本已成为智能体和多模态应用发展的关键瓶颈。本报告初步探究了顶k注意力机制在解码与训练阶段的有效性及理论机制。实验表明,解码阶段仅保留与查询相似度最高的前k个键作为上下文窗口,可在HELMET和LongBench v2等下游任务上达到甚至超过全注意力的效果。进一步研究发现,训练与推理阶段保持顶k操作一致,能充分释放其潜力,显著提升模型性能。针对精确顶k注意力计算复杂度高的问题,研究分析了近似算法精度对下游任务的影响,结果表明任务性能与近似保真度呈正相关,并对DeepSeek-V3.2-Exp模型中Lightning Indexer的精度进行了统计评估。最后,从熵的角度提供理论解释:经过顶k注意力微调的模型在下游任务中表现出明显的熵降低现象,验证了低熵状态更适配顶k解码的假设。
原文摘要 · Abstract (English)
Large Language Models (LLMs) are increasingly prevalent in the field of long-context modeling, however, their inference computational costs have become a critical bottleneck hindering the advancement of tasks such as agents and multimodal applications. This report conducts a preliminary investigation into the effectiveness and theoretical mechanisms of the Top-$k$ Attention mechanism during both the decoding and training phases. First, we validate the effectiveness of exact Top-$k$ Decoding through extensive experimentation. Experiments demonstrate that retaining only the pivotal Keys with the highest similarity to the Query as the context window during the decoding stage achieves performance comparable to, or even surpassing, full attention on downstream tasks such as HELMET and LongBench v2. Second, we further explore the native Top-$k$ Attention training strategy. Experiments confirm that ensuring the consistency between training and inference regarding Top-$k$ Attention operations facilitates the further unlocking of Top-$k$ Decoding's potential, thereby significantly enhancing model performance. Furthermore, considering the high computational complexity of exact Top-$k$ Attention, we investigate the impact of approximate Top-$k$ algorithm precision on downstream tasks. Our research confirms a positive correlation between downstream task performance and approximation fidelity, and we provide statistical evaluations of the Lightning Indexer's precision within the DeepSeek-V3.2-Exp model. Finally, this report provides a theoretical interpretation from the perspective of Entropy. Experimental observations indicate that models subjected to Top-$k$ Attention SFT exhibit a distinct phenomenon of entropy reduction in downstream tasks, which validates the hypothesis that low-entropy states are better adapted to Top-$k$ Decoding.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。