语言模型可以控制自己的注意力
研究论文 · 2026/09/03
语言模型的大部分注意力集中在少量上下文上,但为了找到关键标记,它们仍需读取整个 KV 缓存。本文提出声明式注意力(DA)协议,让模型在思维链中声明需要关注的区域,从而跳过大部分 KV 缓存读取。在 15 个长上下文任务上的零样本评估表明,DA 在 Gemma-4-31B 和 Qwen-3.6-27B 上分别减少了 52.0% 和 31.1% 的注意力标记,同时准确率仅下降 1.27 和 2.75 个百分点,且随模型规模增大而减小。DA 为稀疏注意力提供了新方向,未来可结合训练方法进一步优化。
本文提出了一种新颖的稀疏注意力方法,通过让模型自我声明注意力区域来显著减少计算开销,在保持较高准确率的同时大幅提升效率。实验验证了其有效性,并指出随模型规模增大优势更明显,为未来研究提供了新方向。
Language models spend most of their attention on a small fraction of context, yet they read the entire KV cache to find the few tokens that matter. If the user asks about a previous detail in a 1M-token conversation, global attention layers must scan the full context to generate each token of the reply. A prominent approach mitigates this cost by pre-selecting relevant tokens via lightweight proxy scores, but this extrinsic scoring still incurs O(N) per step. We take an intrinsic approach motivated by the simple question: wouldn't the model already know which parts of the context are relevant? To this end, we introduce Declarative Attention (DA), a protocol that elicits the model to declare where it needs to attend within its chain-of-thought, partitioning generation into three modes: (recent output only). The inference engine parses these declarations like tool calls and skips most of the KV cache read. Under zero-shot evaluation across 15 long-context tasks, DA on off-the-shelf models (Gemma-4-31B, Qwen-3.6-27B) significantly reduces total attended tokens during decoding (52.0%, 31.1%) with modest accuracy drops (1.27pp, 2.75pp) that shrink with model scale. DA unlocks a new axis of sparse attention, with further potential under training-based methods that future work can explore. (a specific region), and (full context),