The Role of Sparsity for Length Generalization in Transformers
Not on the map. Why?
Abstract (arXiv)
Training large language models to predict beyond their training context lengths has drawn much attention in recent years, yet the principles driving such behavior of length generalization remain underexplored. We propose a new theoretical framework to study length generalization for the next-token prediction task, as performed by decoder-only transformers. Conceptually, we show that length generalization occurs as long as each predicted token depends on a small (fixed) number of previous tokens. We formalize such tasks via a notion we call k-sparse planted correlation distributions, and show that an idealized model of transformers which generalize attention heads successfully length-generalize on such tasks. As a bonus, our theoretical model justifies certain techniques to modify positional embeddings which have been introduced to improve length generalization, such as position coupling. We support our theoretical results with experiments on synthetic tasks and natural language, which confirm that a key factor driving length generalization is a ``sparse'' dependency structure of each token on the previous ones. Inspired by our theory, we introduce Predictive Position Coupling, which trains the transformer to predict the position IDs used in a positional coupling approach. Predictive Position Coupling thereby allows us to broaden the array of tasks to which position coupling can successfully be applied to achieve length generalization.
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Builds on 59 of its 70 references that are in the map. First posted on arXiv 24 Feb 2025.
Builds on
59 of 70 references.
References · 59
- 2017Attention Is All You Needcited by 60,361
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
- 2019Transformer-XL: Attentive Language Models Beyond a Fixed-Length Contextcited by 1,850
- 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,651
- 2019Generating Long Sequences with Sparse Transformerscited by 1,546
- 2022Solving Quantitative Reasoning Problems with Language Modelscited by 1,392
- 2024RULER: What's the Real Context Size of Your Long-Context Language Models?cited by 1,346
- 2018Self-Attention with Relative Position Representationscited by 1,120
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 886
38 more
- 2020Efficient Transformers: A Surveycited by 790
- 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 740
- 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 601
- 2017Convolutional Sequence to Sequence Learningcited by 552
- 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 503
- 2024Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attackscited by 486
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 327
- 2022Transformers Learn Shortcuts to Automatacited by 268
- 2019Compositionality decomposed: how do neural networks generalise?cited by 265
- 2022Neural Networks and the Chomsky Hierarchycited by 217
- 2024Repeat After Me: Transformers are Better than State Space Models at Copyingcited by 216
- 2022Exploring Length Generalization in Large Language Modelscited by 206
- 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 199
- 2020Rethinking Positional Encoding in Language Pre-trainingcited by 197
- 2021Thinking Like Transformerscited by 184
- 2020Understanding the Failure Modes of Out-of-Distribution Generalizationcited by 146
- 2023Representational Strengths and Limitations of Transformerscited by 133
- 2023Teaching Arithmetic to Small Transformerscited by 123
- 2021The Devil is in the Detail: Simple Tricks Improve Systematic Generalization of Transformerscited by 117
- 2023Randomized Positional Encodings Boost Length Generalization of Transformerscited by 117
- 2023PoSE: Efficient Context Window Extension of LLMs via Positional Skip-wise Trainingcited by 111
- 2022Unveiling Transformers with LEGO: a synthetic reasoning taskcited by 106
- 2024ContextCite: Attributing Model Generation to Contextcited by 98
- 2024Transformers Can Achieve Length Generalization But Not Robustlycited by 86
- 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 78
- 2023Exposing Attention Glitches with Flip-Flop Language Modelingcited by 75
- 2024Why are Sensitive Functions Hard for Transformers?cited by 74
- 2020Improve Transformer Models with Better Relative Position Embeddingscited by 73
- 2023Generalization on the Unseen, Logic Reasoning and Degree Curriculumcited by 73
- 2021Making Transformers Solve Compositional Taskscited by 72
- 2024On Limitations of the Transformer Architecturecited by 63
- 2021The Neural Data Router: Adaptive Control Flow in Transformers Improves Systematic Generalizationcited by 62
- 2023Positional Description Matters for Transformers Arithmeticcited by 56
- 2024A Formal Framework for Understanding Length Generalization in Transformerscited by 45
- 2023CLEX: Continuous Length Extrapolation for Large Language Modelscited by 44
- 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challengescited by 31
- 2023Learning to Reason and Memorize with Self-Notescited by 30
- 2021Pointer Value Retrieval: A new benchmark for understanding the limits of neural network generalizationcited by 29
50 most cited of 59 All 59 (JSON)
Built on by
Citing papers per year: 2025: 6; 2026: 2.
8 papers.
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalizationcited by 14
- 2025Quantitative Bounds for Length Generalization in Transformerscited by 8
- 2025From Shortcut to Induction Head: How Data Diversity Shapes Algorithm Selection in Transformerscited by 6
- 2025To Infinity and Beyond: Tool-Use Unlocks Length Generalization in State Space Modelscited by 4
- 2026On the Spatiotemporal Dynamics of Generalization in Neural Networkscited by 3
- 2026On the Ability of Transformers to Verify Planscited by 2
- 2025From Small to Large: Generalization Bounds for Transformers on Variable-Size Inputscited by 1
- 2025Position as Probability: Self-Supervised Transformers that Think Past Their Training for Length Extrapolationcited by 0
- 2026On the Ability of Transformers to Verify Plans20 Mar 2026
- 2026On the Spatiotemporal Dynamics of Generalization in Neural Networks2 Feb 2026
- 2025From Shortcut to Induction Head: How Data Diversity Shapes Algorithm Selection in Transformers21 Dec 2025
- 2025From Small to Large: Generalization Bounds for Transformers on Variable-Size Inputs14 Dec 2025
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization10 Nov 2025
- 2025Quantitative Bounds for Length Generalization in Transformers30 Oct 2025
- 2025To Infinity and Beyond: Tool-Use Unlocks Length Generalization in State Space Models16 Oct 2025
- 2025Position as Probability: Self-Supervised Transformers that Think Past Their Training for Length Extrapolation1 Jun 2025