arXiv:2502.01563cs.CL2025-02ICML被引 55

大模型理解上下文的关键在于注意力中的巨量值

Massive Values in Self-Attention Modules are the Key to Contextual Knowledge Understanding

  • 发现注意力机制中特定区域存在集中巨量值,仅出现在查询和键中
  • 这些巨量值对上下文知识理解至关重要,而非模型参数知识
  • 旋转位置编码导致该现象,量化时忽略会显著降低性能

大型语言模型在上下文知识理解方面取得显著成果。本文发现,在多种基于Transformer的现代大模型中,注意力查询(Q)和键(K)的特定区域持续出现集中式的巨量值,而值(V)中并无此类模式。通过大量实验,我们进一步证明这些巨量值在解释上下文知识(即从当前上下文窗口获得的知识)中起关键作用,而非用于检索模型参数中存储的静态知识。对量化策略的进一步研究显示,忽略这些巨量值会导致需要丰富上下文理解的任务性能显著下降,与分析结果一致。最后,我们追踪巨量值的生成过程,发现其集中现象源于自第一层起就存在的旋转位置编码(RoPE)。这些发现为理解大模型中查询与键的作用提供了新视角,并为模型设计与优化提供了实用启示。

原文摘要 · Abstract (English)

Large language models (LLMs) have achieved remarkable success in contextual knowledge understanding. In this paper, we show that these concentrated massive values consistently emerge in specific regions of attention queries (Q) and keys (K) while not having such patterns in values (V) in various modern transformer-based LLMs (Q, K, and V mean the representations output by the query, key, and value layers respectively). Through extensive experiments, we further demonstrate that these massive values play a critical role in interpreting contextual knowledge (knowledge obtained from the current context window) rather than in retrieving parametric knowledge stored within the model's parameters. Our further investigation of quantization strategies reveals that ignoring these massive values leads to a pronounced drop in performance on tasks requiring rich contextual understanding, aligning with our analysis. Finally, we trace the emergence of concentrated massive values and find that such concentration is caused by Rotary Positional Encoding (RoPE), which has appeared since the first layers. These findings shed new light on how Q and K operate in LLMs and offer practical insights for model design and optimization. The Code is Available at https://github.com/MingyuJ666/Rope_with_LLM.

大模型注意力机制上下文理解位置编码

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。