自注意力模块中的大数值是上下文知识理解的关键
Massive Values in Self-Attention Modules are the Key to Contextual Knowledge Understanding
AI总结:
该研究发现Transformer类大语言模型注意力Q、K中的集中大数值是上下文知识理解的关键,其由RoPE从浅层引发,忽略会显著降低上下文任务性能,为模型机制理解和优化提供了新方向。
摘要:
大语言模型(LLM)已在上下文知识理解领域取得显著成效。本文研究发现,在多种基于Transformer的现代大语言模型中,注意力查询(Q)和键(K)的特定区域会持续出现这类集中的大数值,而值(V)中不存在此类模式(Q、K、V分别指查询层、键层和值层输出的表征)。通过大量实验,我们进一步证实这些大数值在解读上下文知识(从当前上下文窗口获取的知识)中发挥关键作用,而非用于检索存储在模型参数内的参数化知识。我们对量化策略的进一步研究表明,忽略这些大数值会导致需要丰富上下文理解的任务性能显著下降,这与我们的分析一致。最后,我们追踪了集中大数值的产生过程,发现这种集中现象是由旋转位置编码(RoPE)引起的,且从模型的前几层就已出现。这些发现为理解大语言模型中Q和K的运作机制提供了新视角,也为模型设计与优化提供了实用思路。代码可在https://github.com/MingyuJ666/Rope_with_LLM获取。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。