Language Models Can Control Their Own Attention

📄 arXiv: 2609.02737v1 📥 PDF

作者: Namgyu Ho, Huzama Ahmad, Woosung Koh, Se-Young Yun, Tal Schuster, Cicero Nogueira dos Santos

分类: cs.CL, cs.AI, cs.LG

发布日期: 2026-09-02


💡 一句话要点

提出声明性注意力以优化语言模型的上下文处理

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 语言模型 注意力机制 长上下文处理 声明性注意力 计算效率 自然语言处理 模型优化

📋 核心要点

  1. 现有语言模型在处理长上下文时,需扫描整个KV缓存,导致计算成本高昂,效率低下。
  2. 本文提出声明性注意力(DA),使模型能够自我声明关注的上下文部分,从而优化注意力分配。
  3. 在零-shot评估中,DA显著减少了解码过程中的注意力标记,且对模型准确率的影响较小,展示了良好的效果。

📝 摘要(中文)

语言模型在处理上下文时,通常只关注少量相关信息,但仍需读取整个KV缓存以找到重要的标记。现有方法通过轻量级的代理评分来预选相关标记,但仍需O(N)的计算成本。本文提出声明性注意力(DA)协议,促使模型声明其关注的上下文部分,将生成过程分为全局、聚焦和局部三种模式,从而显著减少解码过程中的注意力标记数量。在15个长上下文任务的零-shot评估中,DA在现成模型上显著降低了总关注标记(分别为52.0%和31.1%),且准确率仅有适度下降,随着模型规模的增大,下降幅度减小。DA为稀疏注意力开辟了新的方向,未来可在基于训练的方法中进一步探索。

🔬 方法详解

问题定义:本文旨在解决语言模型在长上下文处理中的高计算成本问题。现有方法依赖于全局扫描KV缓存,导致效率低下和资源浪费。

核心思路:提出声明性注意力(DA),使模型能够主动声明其关注的上下文部分,分为全局、聚焦和局部三种模式,从而减少不必要的计算。

技术框架:DA协议通过解析模型的声明,像工具调用一样处理注意力,整体流程包括声明解析、模式选择和KV缓存读取的优化。

关键创新:DA的核心创新在于模型主动选择关注区域,而非依赖外部评分机制,从而实现了更高效的注意力分配。

关键设计:在实现中,模型的声明通过特定的标记进行区分,确保在解码过程中只读取必要的上下文信息,优化了计算效率。具体参数设置和损失函数设计待进一步研究。

🖼️ 关键图片

fig_0
img_1
img_2

📊 实验亮点

实验结果显示,使用声明性注意力的模型在15个长上下文任务中,解码过程中的总关注标记减少了52.0%和31.1%,同时准确率仅下降1.27pp和2.75pp,且随着模型规模的增大,准确率下降幅度减小,展现了良好的性能提升。

🎯 应用场景

该研究的潜在应用领域包括对话系统、长文本生成和信息检索等场景,能够显著提高模型在处理大规模上下文时的效率和响应速度。未来,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: (full context), (a specific region), and (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.