Computation Mechanism Behind LLM Position Generalization
Chi Han, Heng Ji
Abstract
Most written natural languages are composed of sequences of words and sentences. Similar to humans, large language models (LLMs) exhibit flexibility in handling textual positions -a phenomenon we term position generalization. They can understand texts with position perturbations and generalize to longer texts than those encountered during training with the latest techniques. These phenomena suggest that LLMs handle positions tolerantly, but how LLMs computationally process positional relevance remains largely unexplored. This work connects the linguistic phenomenon with LLMs' computational mechanisms. We show how LLMs enforce certain computational mechanisms for the aforementioned tolerance in position perturbations. Despite the complex design of the self-attention mechanism, this work reveals that LLMs learn a counterintuitive disentanglement of attention logits. Their values show a 0.959 linear correlation with an approximation of the arithmetic sum of positional relevance and semantic importance. Furthermore, we identify a prevalent pattern in intermediate features, which we prove theoretically enables this effect. The pattern, which is different from how randomly initialized parameters would behave, suggests that it is a learned behavior rather than a natural result of the model architecture. Based on these findings, we provide computational explanations and criteria for LLMs' position flexibilities. This work takes a pioneering step in linking position generalization with modern LLMs' internal mechanism.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
1 top-tier paper has cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Bayesian Attention Mechanism: A Probabilistic Framework for Positional Encoding and Context Length Extrapolation cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- In-Context Pretraining: Language Modeling Beyond Document Boundaries cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
Cited by top-tier papers1
Builds on4
- Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 citations
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context MemoryChaojun Xiao, Pengle Zhang, Xu Han, Guangxuan Xiao et al.NeurIPS 2024 · 223 citations
- In-Context Pretraining: Language Modeling Beyond Document BoundariesWeijia Shi, Sewon Min, Maria Lomeli, Chunting Zhou et al.ICLR 2024 · 87 citations
- Eliminating Position Bias of Language Models: A Mechanistic ApproachZiqi Wang, Hanlin Zhang, Xiner Li, Kuan-Hao Huang et al.ICLR 2025
Related papers
- Exploring Context Window of Large Language Models via Decomposed Positional VectorsZican Dong, Junyi Li, Xin Men, Xin Zhao et al.NeurIPS 2024 · 37 citations
- Length Representations in Large Language ModelsSangjun Moon, Dasom Choi, Jingun Kwon, Hidetaka Kamigaito et al.EMNLP Findings 2025
- Characterizing Positional Bias in Large Language Models: A Multi-Model Evaluation of Prompt Order EffectsPatrick Schilcher, Dominik Karasin, Michael Schöpf, Haisam Saleh et al.EMNLP Findings 2025 · 1 citation
- A Training-Free Length Extrapolation Approach for LLMs: Greedy Attention Logit InterpolationYan Li, Tianyi Zhang, Zechuan Li, Caren HanEMNLP 2025
- Found in the middle: Calibrating Positional Attention Bias Improves Long Context UtilizationCheng-Yu Hsieh, Yung-Sung Chuang, Chun-Liang Li, Zifeng Wang et al.ACL Findings 2024 · 31 citations
