揭示注意力头如何分离位置与语义信息,解释旋转编码为何有效
Decoupling Positional and Symbolic Attention Behavior in Transformers
- 定义位置与符号行为并证明二者互斥,提出量化指标
- 发现所有注意力头的行为与频率使用高度对应
- 通过控制频率访问可调节模型性能,适合研究注意力机制者
语言理解与生成的核心能力在于独立编码句子中词语的位置与语义信息。在Transformer中,位置信息通常由位置编码(PEs)表示。其中,旋转位置编码(RoPE)因其优异表现被广泛应用。近期研究指出,RoPE的成功部分源于其利用大频率编码稳健的位置信息、小频率编码语义信息的能力。本文从理论与实证层面深入分析注意力头在位置与符号行为间的二分性,提出行为的通用定义,证明两者互斥,并开发量化指标。应用于基于RoPE的Transformer大模型时,发现所有注意力头的行为与其频率使用存在强对应关系。此外,设计纯位置或纯符号任务,验证模型性能与注意力头适配相应频率的能力存在因果关联;通过控制频率访问,可直接调控模型表现。本工作深化了对RoPE机制及其与模型行为关系的理解。
原文摘要 · Abstract (English)
An important aspect subtending language understanding and production is the ability to independently encode positional and symbolic information of the words within a sentence. In Transformers, positional information is typically encoded using Positional Encodings (PEs). One such popular PE, namely Rotary PE (RoPE), has been widely used due to its empirical success. Recently, it has been argued that part of RoPE's success emerges from its ability to encode robust positional and semantic information using large and small frequencies, respectively. In this work, we perform a deeper dive into the positional versus symbolic dichotomy of attention heads behavior, both at the theoretical and empirical level. We provide general definitions of what it means for a head to behave positionally or symbolically, prove that these are two mutually exclusive behaviors and develop a metric to quantify them. We apply our framework to analyze Transformer-based LLMs using RoPE and find that all heads exhibit a strong correspondence between behavior and frequency use. Finally, we introduce canonical tasks designed to be either purely positional or symbolic, and demonstrate that the Transformer performance causally relates to the ability of attention heads to leverage the appropriate frequencies. In particular, we show that we can control the Transformer performance by controlling which frequencies the attention heads can access. Altogether, our work provides a detailed understanding of RoPE, and how its properties relate to model behavior.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。