On the Emergence of Position Bias in Transformers

Xinyi Wu, Yifei Wang, Stefanie Jegelka, A. Jadbabaie
2/14/2026

No official code found. Best implementation: xinyiwu98/position-bias-in-attention (11 stars, MIT, last commit 2025-11-12).

Abstract

Recent studies have revealed various manifestations of position bias in transformer architectures, from the"lost-in-the-middle"phenomenon to attention sinks, yet a comprehensive theoretical understanding of how attention masks and positional encodings shape these biases remains elusive. This paper presents a graph-theoretic framework for analyzing position bias in multi-layer attention. Modeling attention masks as directed graphs, we quantify how tokens interact with contextual information based on their sequential positions. We uncover two key insights: First, causal masking inherently biases attention toward earlier positions, as tokens in deeper layers attend to increasingly more contextualized representations of earlier tokens. Second, we characterize the competing effects of the causal mask and relative positional encodings, such as the decay mask and rotary positional encoding (RoPE): while both mechanisms introduce distance-based decay within individual attention maps, their aggregate effect across multiple attention layers$\unicode{x2013}$coupled with the causal mask$\unicode{x2013}$leads to a trade-off between the long-term decay effects and the cumulative importance of early sequence positions. Through controlled numerical experiments, we not only validate our theoretical findings but also reproduce position biases observed in real-world LLMs. Our framework offers a principled foundation for understanding positional biases in transformers, shedding light on the complex interplay of attention mechanism components and guiding more informed architectural design.

View on arXivView PDF

Code Implementations(1)

MIT

[ICML 2025] On the Emergence of Position Bias in Transformers

111PythonMay 28, 202511 months agoMIT

Similar Papers

Cite this paper

@article{wu2026emergence,
  title  = {On the Emergence of Position Bias in Transformers},
  author = {Xinyi Wu and Yifei Wang and Stefanie Jegelka and A. Jadbabaie},
  year   = {2026},
  eprint = {2502.01951},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2502.01951},
  journal = {ICML 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.01951.svg)](https://codeofpaper.com/paper/2502.01951)

Discussion