Behind RoPE: How Does Causal Mask Encode Positional Information?

Junu Kim, Xiao Liu, Zhenghao Lin, Lei Ji, Yeyun Gong, Edward Choi · DOI

Introduction

In Large Language Models (LLMs), understanding sequence structure is critical. While explicit positional encodings like RoPE are standard, the causal mask itself provides implicit positional information. However, a discrepancy exists between theoretical models—which predict an "early token bias"—and empirical observations of real-world decoders that exhibit a "recency bias." This paper identifies LayerNorm as the key component that flips this behavior, inducing a strong preference for recent tokens even without explicit positional encodings.

Methodology

The researchers isolated the causes of recency bias using a "minimal" Transformer decoder with no learnable parameters. Their approach combined:

  • Mathematical Analysis: Formal proofs (Theorem 1) demonstrating how attention scores evolve across layers.
  • Simulations: 100,000 runs with random Gaussian input embeddings to visualize attention patterns.
  • Anisotropy Modeling: Adding a shared bias vector to simulate real-world word embedding distributions, where vectors often cluster in a specific direction.

Key Insights: The Catalyst of Recency Bias

LayerNorm and Anisotropy

The study reveals that LayerNorm (LN) transforms the inherent early bias of causal attention into recency bias. LN normalizes the cumulative information in the causal chain, making the most recent tokens appear more salient to subsequent layers. This effect is significantly amplified by anisotropy; as embeddings become more clustered (anisotropic), the recency bias becomes more extreme.

The Role of Residual Connections

While LN induces recency bias, residual connections act as a dampening mechanism. By re-introducing unprocessed information from earlier layers, residuals prevent attention from concentrating too heavily on the most recent tokens, promoting a more uniform distribution.

Key Results

Heatmaps showing attention patterns across layers (1-4) under different configurations. Row 1 (noLN, noRes) shows early token bias in later layers. Row 2 (LN, noRes) shows the emergence of recency bias. Row 3 (alpha=0.5, LN, noRes) shows anisotropy amplifying recency bias. Row 4 (alpha=0.5, LN, Res) shows residual connections dampening the bias.

The authors mathematically proved that in a stack of causal attention layers with LayerNorm, the attention score $S_{ij}$ is strictly increasing in the key index $j$. As shown in the simulation visualizations above, without LN, attention eventually concentrates on the first tokens (index 0). With LN and anisotropy, a sharp gradient appears, focusing heavily on the most recent tokens. The researchers also derived an explicit formula (Equation 5) showing that this bias is driven by an exponential term related to the model's hidden dimension $d$.

Limitations and Future Work

This analysis focused on the architectural "skeleton" and did not include Feed-Forward Networks (FFNs) or multi-head attention, which may further modulate these biases. Additionally, the interaction between this implicit LayerNorm-induced bias and explicit signals like RoPE remains an open question. Understanding how learnable parameters in real models exploit or counteract these natural tendencies is a crucial next step for long-context modeling research.

Summary updated

BibTeX
@misc{kim2025behind,
  author = {Junu Kim and Xiao Liu and Zhenghao Lin and Lei Ji and Yeyun Gong and Edward Choi},
  title = {{Behind RoPE: How Does Causal Mask Encode Positional Information?}},
  year = {2025},
  eprint = {2509.21042},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.21042},
}
Figure