用滚动波设计位置编码,让Transformer更好捕捉位置关系
Do traveling waves make good positional encodings?
- 通过循环滚动查询和键张量,实现基于相位差的位置编码
- 在多个任务上优于传统绝对位置编码,接近RoPE性能
- 为理解注意力机制与脑信息传递的关系提供新视角
Transformer依赖位置编码来克服自注意力的置换不变性缺陷。传统方法使用绝对正弦嵌入或学习的位置向量,近期研究更强调相对编码以更好捕捉平移等变性。本文提出RollPE,一种基于行进波的位置编码机制,通过在自注意力中对查询和键张量施加循环滚动操作,引入位置间的相位偏移,使注意力计算依赖于相对位置差而非绝对索引。实验表明,该简单方法显著优于传统绝对位置编码,且性能接近RoPE。我们推导了RollPE的连续形式,隐式在查询和键空间施加拓扑结构;进一步证明其与特定配置的RoPE存在数学等价性。从行进波视角审视RollPE,或可简化RoPE,并将其与大脑中的信息流动过程建立联系。
原文摘要 · Abstract (English)
Transformers rely on positional encoding to compensate for the inherent permutation invariance of self-attention. Traditional approaches use absolute sinusoidal embeddings or learned positional vectors, while more recent methods emphasize relative encodings to better capture translation equivariances. In this work, we propose RollPE, a novel positional encoding mechanism based on traveling waves, implemented by applying a circular roll operation to the query and key tensors in self-attention. This operation induces a relative shift in phase across positions, allowing the model to compute attention as a function of positional differences rather than absolute indices. We show this simple method significantly outperforms traditional absolute positional embeddings and is comparable to RoPE. We derive a continuous case of RollPE which implicitly imposes a topographic structure on the query and key space. We further derive a mathematical equivalence of RollPE to a particular configuration of RoPE. Viewing RollPE through the lens of traveling waves may allow us to simplify RoPE and relate it to processes of information flow in the brain.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。