arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2601.08297cs.LGcs.AIcs.CL
收藏

解开注意力中的斜线模式之谜:RoPE的作用

Demystifying the Slash Pattern in Attention: The Role of RoPE

National University of Singapore(新加坡国立大学);Sea AI Lab(冬海集团人工智能实验室);Nanyang Technological University(南洋理工大学);Yale University(耶鲁大学)

Yuan Cheng, Fengzhuo Zhang, Yunlong Hou, Cunxiao Du, Chao Du, Tianyu Pang, Aixin Sun, Zhuoran Yang

AI总结:

本文研究了大型语言模型中斜线注意力模式的成因,通过实证和理论分析揭示RoPE在形成斜线主导头中的作用。

摘要:

大型语言模型(LLMs)常常表现出斜线注意力模式,即注意力分数集中在第Δ条次对角线上,对于某些偏移量Δ。这些模式在跨token传递信息中起关键作用。但为什么会出现这些斜线主导头(SDHs)?在本文中,我们从经验和理论的角度揭开这些SDHs出现的原因。首先,通过分析开源LLMs,我们发现SDHs是内在的,并且能够推广到分布外提示。为了解释内在的出现,我们分析了查询、键和旋转位置嵌入(RoPE),这些共同决定了注意力分数。我们的实证分析揭示了SDHs的两个特征条件:(1)查询和键几乎是一阶的,(2)RoPE由中频和高频成分主导。在这些条件下,查询和键在token之间几乎相同,而中频和高频成分之间的相互作用导致了SDHs的出现。除了实证证据外,我们还从理论上证明这些条件足以确保SDHs的出现,通过将它们正式化为我们的建模假设。特别是,我们分析了配备RoPE的浅层Transformer在这些条件下的训练动态,并证明通过梯度下降训练的模型会表现出SDHs。SDHs能够推广到分布外提示。

英文摘要:

Large Language Models (LLMs) often exhibit slash attention patterns, where attention scores concentrate along the $Δ$-th sub-diagonal for some offset $Δ$. These patterns play a key role in passing information across tokens. But why do they emerge? In this paper, we demystify the emergence of these Slash-Dominant Heads (SDHs) from both empirical and theoretical perspectives. First, by analyzing open-source LLMs, we find that SDHs are intrinsic to models and generalize to out-of-distribution prompts. To explain the intrinsic emergence, we analyze the queries, keys, and Rotary Position Embedding (RoPE), which jointly determine attention scores. Our empirical analysis reveals two characteristic conditions of SDHs: (1) Queries and keys are almost rank-one, and (2) RoPE is dominated by medium- and high-frequency components. Under these conditions, queries and keys are nearly identical across tokens, and interactions between medium- and high-frequency components of RoPE give rise to SDHs. Beyond empirical evidence, we theoretically show that these conditions are sufficient to ensure the emergence of SDHs by formalizing them as our modeling assumptions. Particularly, we analyze the training dynamics of a shallow Transformer equipped with RoPE under these conditions, and prove that models trained via gradient descent exhibit SDHs. The SDHs generalize to out-of-distribution prompts.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑