# On the Emergence of Position Bias in Transformers

트랜스포머에서 위치 편향의 출현에 관하여

Xinyi Wu, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie · arXiv · 2025년 2월 4일

- **연구 문제** 트랜스포머의 어텐션 마스크와 위치 인코딩이 다층 구조에서 어떤 위치 편향을 만드는지 이론적으로 설명하는 것이 이 논문의 문제입니다.
- **연구 방법** 어텐션 마스크를 방향 그래프로 모델링하고, 여러 층에 걸친 문맥 선택 확률을 분석합니다. 인과 마스크, decay mask, RoPE를 대상으로 각각의 편향을 정리로 도출합니다.
- **주요 결과** 인과 마스크에서는 깊은 층일수록 문맥이 앞쪽 토큰으로 지수적으로 수렴하며, decay mask와 RoPE의 거리 감쇠는 여러 층의 누적에서 임계점을 가집니다. 합성 실험에서는 깊이에 따라 앞쪽 편향이 증폭되는 경향이 잔차 연결이 없는 설정에서 관찰되었습니다.

## 연구 문제: 어텐션 마스크와 위치 인코딩이 만드는 위치 편향

트랜스포머는 입력 순서를 직접 알지 못하므로 어텐션 마스크와 위치 인코딩을 통해 순서 정보를 다룹니다. 그러나 최근 실험들은 입력의 특정 위치에 과도하게 집중하는 위치 편향이 나타난다고 보고합니다. 대표적으로 정보가 입력 중간에 놓이면 검색 정확도가 떨어지는 lost-in-the-middle 현상과, 의미와 무관하게 많은 주의를 받는 attention sinks가 있습니다. 본 논문은 이러한 경험적 관찰을 이론적으로 설명하고자 하며, 마스크와 위치 인코딩이 다층 어텐션에서 위치 편향을 어떻게 형성하는지를 묻습니다. 논문은 어텐션 마스크를 방향 그래프 G로 모델링하고, 여러 층에 걸친 문맥 선택 확률 P(t)를 분석 대상으로 삼습니다.

이 틀에서 인과 마스크, decay mask, RoPE가 각각 어떤 편향을 만드는지 검토합니다.

## 그래프 관점과 문맥 선택 확률

논문은 어텐션 마스크를 방향 그래프로 봅니다. 간선 (j, i)는 토큰 i가 토큰 j를 참조할 수 있음을 뜻하며, 어떤 노드 v가 모든 노드에서 도달 가능하면 v를 center node라고 정의합니다. 어텐션 갱신은 X(t+1) = A(t)X(t)W\_V(t) 형태이며, A(t)는 마스크 그래프의 간선 위에서 softmax로 정규화됩니다. 여러 층을 거친 누적 확률 P(t)(z\_i = j \| X(0))는 A(t)···A(0)의 원소로 주어지며, 이는 attention rollout과 같은 양입니다. 논문은 이 양을 특정 입력의 시각화가 아니라 임의 입력에 대한 이론적 대상으로 분석합니다. 분석은 A1(질의·키 가중치의 노름 유계)과 A2(가치 행렬 곱의 유계)를 가정합니다.

![Figure 1: Three types of attention masks and their correspond- ing directed graphs G used in the analysis (self-loops are omitted for clarity). A directed edge…](https://refivu.com/papers/30c44117-6449-44f4-b744-0034b372d932/figures/figure-cfbbd07172d821b4a46bdbbad696d0ab.png?thumb=512)

**Figure 1** : Three types of attention masks and their correspond- ing directed graphs G used in the analysis (self-loops are omitted for clarity). A directed edge from token j to i indicates that i attends to j. The center node(s) (Definition 3.1), highlighted in yellow, represent tokens that can be directly or indirectly attended to by all other tokens in the sequence. As depicted in the top row, the graph-theoretic formulation captures both direct and indirect contributions of tokens to the overall context, providing a compre- hensive view of the token interactions under multi-layer attention.

[원문](https://arxiv.org/abs/2502.01951v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Xinyi Wu, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie · On the Emergence of Position Bias in Transformers · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.

## 인과 마스크의 지수적 수렴과 첫 토큰 편향

인과 마스크 G에서 Theorem 4.1은 A1-A2 아래 모든 토큰 i에 대해 lim P(t)(z\_i = 1 \| X(0)) = 1임을 보입니다. 또한 1 \< j ≤ i와 t ≥ 0에 대해 P(t)(z\_i = j \| X(0)) ≤ C(1 − (j − 1)ϵ)^t 형태의 상한이 주어집니다. 이 결과는 층이 깊어질수록 문맥이 첫 번째 토큰으로 지수적으로 모인다는 뜻입니다. 저자들은 깊은 층의 토큰이 입력 원자료가 아니라 이전 층에서 문맥화된 앞선 토큰을 참조하기 때문에 이러한 누적이 생긴다고 해석합니다. softmax는 그래프의 간선을 완전히 끊지 못하므로 center node가 문맥에서 우세해집니다. 이 해석은 인과 마스크 설정에 한정되며, 다른 마스크의 결론은 아래 단락에서 따로 다룹니다.

## 슬라이딩 윈도우와 접두어 마스크의 일반화

Theorem 4.1의 결과는 슬라이딩 윈도우 마스크와 접두어 마스크로 일반화됩니다. 슬라이딩 윈도우 마스크(폭 w ≥ 2)에서도 첫 토큰으로의 수렴이 나타나지만, 수렴 속도는 시퀀스 길이 N과 윈도우 폭 w의 비율에 의해 결정됩니다. 따라서 작은 윈도우가 앞쪽 토큰 편향을 완화하더라도 그 효과에는 한계가 있습니다. 접두어 마스크(처음 K개 토큰이 접두어)에서는 문맥이 한 토큰이 아니라 K개의 접두어 토큰에 수렴하며, 각 접두어 토큰이 하한 κ 이상의 영향을 가진다고 설명됩니다. 이 결과들은 모두 A1-A2 가정 아래의 이론적 결론입니다.

![Figure 11: Attention sinks tend to emerge on the absolute first token when the context window size w is larger, under the sliding-window mask](https://refivu.com/papers/30c44117-6449-44f4-b744-0034b372d932/figures/figure-bceaa3f76010079feedbb84261a27a89.png?thumb=512)

**Figure 11** : Attention sinks tend to emerge on the absolute first token when the context window size w is larger, under the sliding-window mask.

[원문](https://arxiv.org/abs/2502.01951v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Xinyi Wu, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie · On the Emergence of Position Bias in Transformers · 원문 그림 인용 · 원본 PDF 23쪽에서 그림 영역을 추출했습니다.

![Figure 12: Attention sinks emerge on the K prefix tokens, not just on the first token alone, under the prefix mask](https://refivu.com/papers/30c44117-6449-44f4-b744-0034b372d932/figures/figure-36654a3cd1b5a66452dd045eb8359b26.png?thumb=512)

**Figure 12** : Attention sinks emerge on the K prefix tokens, not just on the first token alone, under the prefix mask.

[원문](https://arxiv.org/abs/2502.01951v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Xinyi Wu, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie · On the Emergence of Position Bias in Transformers · 원문 그림 인용 · 원본 PDF 23쪽에서 그림 영역을 추출했습니다.

## decay mask와 RoPE의 거리 감쇠 및 누적 효과

decay mask는 각 층의 어텐션 점수에 거리 기반 편향 D\_ij = −(i − j)m (j ≤ i)을 더합니다. Lemma 4.4는 인과 구조 아래 각 어텐션 맵이 C\_min e^{−(i−j)m} ≤ (A(t)\_decay)\_ij ≤ C\_max e^{−(i−j)m}으로 거리에 따라 지수적으로 감쇠함을 보입니다. Theorem 4.5는 여러 층의 누적 확률이 Θ((t+i−j choose i−j) e^{−(i−j)m}) 형태이며, L(x) = log((t+x choose x) e^{−xm})의 임계점 x\* = t/(e^m − 1)을 가짐을 보입니다. 이로부터 감쇠 강도 m이 커지면 x\*가 작아져 최근 토큰을 선호하고, 층 수 t가 커지면 x\*가 커져 초기 토큰을 선호합니다.

RoPE는 쿼리·키를 위치에 비례한 각도로 회전시키며, Lemma 4.6은 저주파 특성만 쓴다는 d = 2 가정에서 거리 기반 감쇠를 보입니다. Theorem 4.7은 RoPE 누적 확률에서 임계점 x\*가 깊이 t에 대해 증가하고 기저 각 θ1에 대해 감소함을 보입니다. 이 임계점 분석은 해당 정리의 조건과 Stirling 근사에 의존합니다.

## 합성 검색 과제와 위치 편향 측정 방식

검증은 Reddy(2024)의 합성 정보 검색 과제를 따릅니다. 모델은 x1, y1, ..., xn, yn, x\_query로 이루어진 교대 시퀀스에서 질의의 라벨 y\_query를 예측하도록 교차 엔트로피 손실로 학습됩니다. x\_i는 K개 클래스를 갖는 Gaussian mixture에서 샘플링되며, 실험에서는 n = 8과 d = 64를 사용합니다. 위치 편향은 \[a, b\]와 \[b, a\]의 검색 정확도 차이로 측정하며, Accuracy Gap은 같은 내용을 가진 두 위치에서의 선호를 나타냅니다. 학습 데이터에 위치 편향이 없을 때 결과는 Figure 2에 제시되며, 양의 값은 앞쪽 위치 선호, 음의 값은 뒤쪽 위치 선호를 뜻합니다.

이 설정은 단순화된 어텐션 전용 네트워크이므로 실제 LLM 전체에 바로 일반화되지는 않습니다.

## 깊이와 잔차 연결이 위치 편향에 주는 영향

잔차 연결이 없는 설정에서 어텐션 깊이를 늘리면 PE의 종류와 관계없이 앞쪽 토큰에 대한 편향이 증폭된다고 보고됩니다. 이 실험은 학습 데이터에 위치 편향이 없고 질의 위치가 무작위로 배정된 조건에서 수행되었습니다. 보조 설정에서는 decay mask의 거리 감쇠가 RoPE보다 더 강하게 최근 토큰을 선호하는 것으로 나타납니다. 반면 잔차 연결이 있는 모델에서는 위치 편향과 깊이의 관계가 단조롭지 않으며, PE와 깊이 영역에 따라 편향이 증폭되거나 감소합니다. 따라서 잔차 연결의 효과는 깊이 단조 증가로 일반화되지 않습니다.

## 위치 인코딩 없는 인과 마스크와 학습 데이터의 역할

위치 인코딩이 없는 인과 마스크는 시퀀스 시작 위치에 대한 편향을 학습할 수 있지만, 끝 위치 편향은 학습하지 못했다고 보고됩니다. 저자들은 이를 인과 마스크가 절대 위치를 명시적으로 모사하기보다 앞쪽 토큰에 더 많이 의존하는 구조적 편향을 가진다는 해석으로 제시합니다. 학습 데이터에 시작과 끝 위치의 편향이 함께 있을 때에만 검색 정확도가 U자형을 보이는 lost-in-the-middle 패턴이 나타납니다. 이 관찰은 학습 데이터의 위치 편향 종류가 모델이 위치를 우선순위화하는 방식에 영향을 준다는 저자 해석과 연결됩니다. 이 결과는 합성 과제와 정해진 학습 데이터 설정에 한정된 관찰입니다.

![Figure 15: Position bias exhibited by the model when trained on data biased toward the first and last positions](https://refivu.com/papers/30c44117-6449-44f4-b744-0034b372d932/figures/figure-7adf5d3dd2b187a38f09207ce1fe2ce1.png?thumb=512)

**Figure 15** : Position bias exhibited by the model when trained on data biased toward the first and last positions.

[원문](https://arxiv.org/abs/2502.01951v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Xinyi Wu, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie · On the Emergence of Position Bias in Transformers · 원문 그림 인용 · 원본 PDF 25쪽에서 그림 영역을 추출했습니다.

## 어텐션 싱크의 측정과 이론과의 연결

인과 마스크 설정에서 어텐션 싱크는 첫 번째 토큰에 나타난다고 보고되며, 측정 임계값 τ는 0.2로 설정됩니다. 어텐션 싱크 지표는 마스크 그래프의 열 합으로 정규화한 뒤, 여러 층의 A(t)\_ij가 τ를 넘는 비율로 계산됩니다. 슬라이딩 윈도우와 접두어 마스크에서도 절대 첫 토큰 또는 K개 접두어 토큰에 싱크가 나타난다고 보고됩니다. 이 결과는 어텐션 싱크가 center node 구조와 연결된다는 저자 해석을 뒷받침하지만, 이 측정 자체는 특정 설정의 관찰입니다.

![Figure 10: Attention sinks emerge on the first token under the causal attention mask](https://refivu.com/papers/30c44117-6449-44f4-b744-0034b372d932/figures/figure-d908703f7c652117958adc22354e38af.png?thumb=512)

**Figure 10** : Attention sinks emerge on the first token under the causal attention mask.

[원문](https://arxiv.org/abs/2502.01951v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Xinyi Wu, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie · On the Emergence of Position Bias in Transformers · 원문 그림 인용 · 원본 PDF 23쪽에서 그림 영역을 추출했습니다.

## 적용 범위와 한계

본 논문의 이론은 A1-A2 가정, 즉 질의·키 가중치의 노름 유계와 가치 행렬 곱의 유계에 의존합니다. 실험은 합성 데이터와 단순화된 어텐션 네트워크에서 수행되었으므로, 실제 LLM 전체에 바로 옮길 수 있는지는 본문 실험만으로 확정되지 않습니다. 또한 비교 결과는 특정 학습 예산과 설정에서 얻은 것이며, 잔차 연결·값 투영·MLP 같은 다른 구성요소의 상호작용은 향후 연구 과제로 남아 있습니다.

## 논문 정보

- **저자**: Xinyi Wu, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2025년 2월 4일
- **등록일**: 2026년 10월 30일
- **수정일**: 2025년 8월 9일
- **버전**: v4
- **arXiv**: 2502.01951
- **분류**: cs.LG
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2502.01951v4) · [원문 PDF ↗](https://arxiv.org/pdf/2502.01951v4)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

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.

## 원문 인용

Xinyi Wu, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie (2025). On the Emergence of Position Bias in Transformers. arXiv:2502.01951v4. https://arxiv.org/abs/2502.01951v4

**BibTeX**

```
@misc{wu2025emergence,
  title = {{On the Emergence of Position Bias in Transformers}},
  author = {Xinyi Wu and Yifei Wang and Stefanie Jegelka and Ali Jadbabaie},
  year = {2025},
  eprint = {2502.01951},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.01951v4}
}
```

## 이 논문의 용어

- [softmax](https://refivu.com/terms/4a7673b6518d-softmax)
- [회전 위치 임베딩](https://refivu.com/terms/64a8b6696ec8-rotary-position-embedding-rope)
- [Theorem 4.1](https://refivu.com/terms/5490ca501b92-theorem-4-1)
- [position bias](https://refivu.com/terms/a70d2454f5a2-position-bias)
- [Gaussian mixture](https://refivu.com/terms/0df0902734f9-gaussian-mixture)
- [attention rollout](https://refivu.com/terms/998a97071246-attention-rollout)
- [attention sinks](https://refivu.com/terms/e6fdf17c8785-attention-sinks)
- [causal mask](https://refivu.com/terms/3bf200651a46-causal-mask)
- [Accuracy Gap](https://refivu.com/terms/af7f0206b18a-accuracy-gap)
- [lost-in-the-middle](https://refivu.com/terms/6c6f070a9b27-lost-in-the-middle)
- [Rotary Positional Encoding](https://refivu.com/terms/4be54191cbc1-rotary-positional-encoding)
- [Theorem 4.5](https://refivu.com/terms/04f01dcfaf2f-theorem-4-5)

## 관련 논문

- [Causal Localization of Evidence Effects in Transformers](https://refivu.com/papers/f96b5a12-0c53-49d2-8d6f-292224474229-causal-localization-of-evidence-effects-in-transformers.md)
- [CriticEval: Evaluating Large-scale Language Model as Critic](https://refivu.com/papers/49cb4d52-0b81-4cbd-9b74-dfe48638ac34-criticeval-evaluating-large-scale-language-model-as-critic.md)
- [Coarse Semantic Blocks for Efficient Training-Free Sparse Attention](https://refivu.com/papers/52935b53-62a3-4266-90b0-b3631ba9ddcc-coarse-semantic-blocks-for-efficient-training-free-sparse.md)
- [Evaluating classification and explainability in multimodal petrographic image analysis](https://refivu.com/papers/17298a4b-352b-4273-9ab4-b451803ecd99-evaluating-classification-and-explainability-in-multimodal.md)
- [SmolWAM: A Latent World-Action Model for Robotic Manipulation on Edge Devices](https://refivu.com/papers/0fcff0f4-e626-4624-88df-147586408ac6-smolwam-a-latent-world-action-model-for-robotic.md)
- [Aspect-wise Pairwise Tournaments for Test-Time Selection](https://refivu.com/papers/1c1b6d7a-3b53-497b-a00d-ef382ac91c72-aspect-wise-pairwise-tournaments-for-test-time-selection.md)

## 다른 논문 해설

- [LEAPS: A discrete neural sampler via locally equivariant networks](https://refivu.com/papers/18f47342-603c-4a46-8dcc-4336d46c678b-leaps-a-discrete-neural-sampler-via-locally-equivariant.md)
- [Accelerating Linear Recurrent Neural Networks for the Edge with Unstructured Sparsity](https://refivu.com/papers/b2a9f6b3-8ba3-44da-96ae-f86807c7d69e-accelerating-linear-recurrent-neural-networks-for-the-edge.md)
- [Widening the Network Mitigates the Impact of Data Heterogeneity on FedAvg](https://refivu.com/papers/13f2de6e-50d1-4287-863a-4ef9f45fce40-widening-the-network-mitigates-the-impact-of-data.md)
- [Towards Theoretical Understanding of Transformer Test-Time Computing: Investigation on In-Context Linear Regression](https://refivu.com/papers/a4b4122b-59db-46e5-9a5b-ffca7c65fd90-towards-theoretical-understanding-of-transformer-test-time.md)
- [Diagonal Symmetrization of Neural Network Solvers for the Many-Electron Schrödinger Equation](https://refivu.com/papers/dc323c3a-1543-4d1b-af35-f33e841e1b65-diagonal-symmetrization-of-neural-network-solvers-for-the.md)
- [Learning to (Learn at Test Time): RNNs with Expressive Hidden States](https://refivu.com/papers/6a02f8bd-d757-4f00-9d97-6829bf6db29f-learning-to-learn-at-test-time-rnns-with.md)
- [Ehrenfeucht-Haussler Rank and Chain of Thought](https://refivu.com/papers/cd83075a-e02f-4d42-b023-d9aff551bfbf-ehrenfeucht-haussler-rank-and-chain-of-thought.md)
- [Vulnerability-Aware Alignment: Mitigating Uneven Forgetting in Harmful Fine-Tuning](https://refivu.com/papers/1df651fe-a060-4bd5-bae0-8e9931bfa576-vulnerability-aware-alignment-mitigating-uneven-forgetting.md)
- [Finite-Time Global Optimality Convergence in Deep Neural Actor-Critic Methods for Decentralized Multi-Agent Reinforcement Learning](https://refivu.com/papers/7cb21181-7f21-4d9d-a1ab-072b74b80f38-finite-time-global-optimality-convergence-in-deep-neural.md)
- [Understanding Nonlinear Implicit Bias via Region Counts in Input Space](https://refivu.com/papers/4f651ef8-f538-4406-8e71-5b281c8afaea-understanding-nonlinear-implicit-bias-via-region-counts-in.md)
- [Sparse Spectral Training and Inference on Euclidean and Hyperbolic Neural Networks](https://refivu.com/papers/fe14dce1-7320-4b0a-850d-c59ef71afe28-sparse-spectral-training-and-inference-on-euclidean-and.md)
- [A Closer Look at Multimodal Representation Collapse](https://refivu.com/papers/e9b6a122-e8a7-4f9a-bfdb-ad721ee1ec50-a-closer-look-at-multimodal-representation-collapse.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/30c44117-6449-44f4-b744-0034b372d932-on-the-emergence-of-position-bias-in-transformers)
