Absolute Position Embedding Learns Sinusoid-like Waves for Attention Based on Relative Position
Yuji Yamamoto, Takuya Matsuzaki
Abstract
Attention weight is a clue to interpret how a Transformer-based model makes an inference. In some attention heads, the attention focuses on the neighbors of each token. This allows the output vector of each token to depend on the surrounding tokens and contributes to make the inference context-dependent. We analyze the mechanism behind the concentration of attention on nearby tokens. We show that the phenomenon emerges as follows: (1) learned position embedding has sinusoid-like components, (2) such components are transmitted to the query and the key in the self-attention, (3) the attention head shifts the phases of the sinusoid-like components so that the attention concentrates on nearby tokens at specific relative positions. In other words, a certain type of Transformer-based model acquires the sinusoidal positional encoding to some extent on its own through Masked Language Modeling.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext ad8ff7bd-5436-411b-9a40-ab0720da9f6eCited by top-tier papers1
Ask how each one uses itBuilds on5
- BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and ComprehensionMike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad et al.ACL 2020 · 1,224 citations
- On Position Embeddings in BERTBenyou Wang, Lifeng Shang, Christina Lioma, Xin Jiang et al.ICLR 2021 · 129 citations
- What Do Position Embeddings Learn? An Empirical Study of Pre-Trained Language Model Positional EncodingYu-An Wang, Yun-Nung ChenEMNLP 2020 · 71 citations
- The Geometry of Multilingual Language Model RepresentationsTyler A. Chang, Zhuowen Tu, Benjamin K. BergenEMNLP 2022 · 22 citations
- The Impact of Positional Encodings on Multilingual CompressionVinit Ravishankar, Anders SøgaardEMNLP 2021 · 7 citations
Related papers
- Attention is Not Only a Weight: Analyzing Transformers with Vector NormsGoro Kobayashi, Tatsuki Kuribayashi, Sho Yokoi, Kentaro InuiEMNLP 2020 · 138 citations
- What are you sinking? A geometric approach on attention sinkValeria Ruscio, Umberto Nanni, Fabrizio SilvestriNeurIPS 2025 · 29 citations
- On Scalar Embedding of Relative Positions in Attention ModelsJunshuang Wu, Richong Zhang, Yongyi Mao, Junfan ChenAAAI 2021 · 4 citations
- Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer TransformerYuandong Tian, Yiping Wang, Beidi Chen, Simon S. DuNeurIPS 2023 · 125 citations
- On the Emergence of Position Bias in TransformersXinyi Wu, Yifei Wang, Stefanie Jegelka, Ali JadbabaieICML 2025 · 1 citation
