竞争条件下自注意力的检索容量

·

研究论文 · 2026/10/01

语言模型实际从上下文中使用多少token,以及什么决定了这个数量?我们通过自注意力研究这个问题。在不重新训练的情况下,我们在每个头、层和查询处仅保留注意力权重最高的token,并保持其原始权重不变。通过改变所选集合的大小并测量负对数似然(NLL)的增加,我们估计在选定的损失容差内所需的有效注意力集合大小。相对较小的所选集合可以使NLL接近全注意力基线,尽管所需大小因模型而异。基于注意力的选择显著优于随机选择。所选集合表现出几何结构,尽管仅几何分离并不能保证模型损失得以保持。在评估相同预测目标时扩展上下文会增加所需的集合大小,而其占上下文的比例在测试范围内下降。使用固定支持事实的实验表明,额外的背景会将其token推低注意力排名并减少其注意力质量。重新归一化保留的权重可以大幅减少所需的集合大小,表明它还取决于所选表示的组合方式。条件理论模型解释了竞争和注意力质量保留如何在没有更多可检索的不同信息的情况下产生增长的集合大小。这些结果提供了一种测量语言模型中有效注意力集合大小并研究其对上下文、竞争和聚合依赖性的方法。

该研究提供了一种量化语言模型实际使用上下文信息量的方法,揭示了注意力机制在竞争下的检索能力,对理解模型效率、上下文利用和注意力机制有重要价值。

How many tokens from its context does a language model actually use, and what determines that number? We study this question through self-attention. Without retraining, we retain only the tokens with the highest attention weights at each head, layer, and query, keeping their original weights unchanged. By varying the selected set size and measuring the increase in negative log-likelihood (NLL), we estimate the effective attention set size needed to stay within a chosen loss tolerance. Relatively small selected sets can keep NLL close to the full-attention baseline, although the required size varies across models. Attention-based selection substantially outperforms random selection. Selected sets exhibit geometric structure, although geometric separation alone does not establish that model loss is preserved. Extending context while evaluating the same prediction targets increases the required set size, while its fraction of context decreases over the tested range. Experiments with a fixed supporting fact show that additional background pushes its tokens down the attention ranking and reduces their attention mass. Renormalizing the retained weights can substantially reduce the required set size, showing that it also depends on how selected representations are combined. Conditional theoretical models explain how competition and attention-mass retention can produce growing set sizes without more distinct information to retrieve. These results provide a way to measure effective attention set size in language models and investigate its dependence on context, competition, and aggregation.

阅读原文

参与讨论