mlsanityData to 14 Oct 2026

The Role of Sparsity for Length Generalization in Transformers

arXiv 2502.16792 ↗First posted 24 Feb 2025cs.LG cs.AI cs.CLcited by 8

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

  1. 2017Attention Is All You Needcited by 60,361
  2. 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
  3. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
  4. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
  5. 2019Transformer-XL: Attentive Language Models Beyond a Fixed-Length Contextcited by 1,850
  6. 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,651
  7. 2019Generating Long Sequences with Sparse Transformerscited by 1,546
  8. 2022Solving Quantitative Reasoning Problems with Language Modelscited by 1,392
  9. 2024RULER: What's the Real Context Size of Your Long-Context Language Models?cited by 1,346
  10. 2018Self-Attention with Relative Position Representationscited by 1,120
  11. 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
  12. 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 886
38 more
  1. 2020Efficient Transformers: A Surveycited by 790
  2. 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 740
  3. 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 601
  4. 2017Convolutional Sequence to Sequence Learningcited by 552
  5. 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 503
  6. 2024Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attackscited by 486
  7. 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 327
  8. 2022Transformers Learn Shortcuts to Automatacited by 268
  9. 2019Compositionality decomposed: how do neural networks generalise?cited by 265
  10. 2022Neural Networks and the Chomsky Hierarchycited by 217
  11. 2024Repeat After Me: Transformers are Better than State Space Models at Copyingcited by 216
  12. 2022Exploring Length Generalization in Large Language Modelscited by 206
  13. 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 199
  14. 2020Rethinking Positional Encoding in Language Pre-trainingcited by 197
  15. 2021Thinking Like Transformerscited by 184
  16. 2020Understanding the Failure Modes of Out-of-Distribution Generalizationcited by 146
  17. 2023Representational Strengths and Limitations of Transformerscited by 133
  18. 2023Teaching Arithmetic to Small Transformerscited by 123
  19. 2021The Devil is in the Detail: Simple Tricks Improve Systematic Generalization of Transformerscited by 117
  20. 2023Randomized Positional Encodings Boost Length Generalization of Transformerscited by 117
  21. 2023PoSE: Efficient Context Window Extension of LLMs via Positional Skip-wise Trainingcited by 111
  22. 2022Unveiling Transformers with LEGO: a synthetic reasoning taskcited by 106
  23. 2024ContextCite: Attributing Model Generation to Contextcited by 98
  24. 2024Transformers Can Achieve Length Generalization But Not Robustlycited by 86
  25. 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 78
  26. 2023Exposing Attention Glitches with Flip-Flop Language Modelingcited by 75
  27. 2024Why are Sensitive Functions Hard for Transformers?cited by 74
  28. 2020Improve Transformer Models with Better Relative Position Embeddingscited by 73
  29. 2023Generalization on the Unseen, Logic Reasoning and Degree Curriculumcited by 73
  30. 2021Making Transformers Solve Compositional Taskscited by 72
  31. 2024On Limitations of the Transformer Architecturecited by 63
  32. 2021The Neural Data Router: Adaptive Control Flow in Transformers Improves Systematic Generalizationcited by 62
  33. 2023Positional Description Matters for Transformers Arithmeticcited by 56
  34. 2024A Formal Framework for Understanding Length Generalization in Transformerscited by 45
  35. 2023CLEX: Continuous Length Extrapolation for Large Language Modelscited by 44
  36. 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challengescited by 31
  37. 2023Learning to Reason and Memorize with Self-Notescited by 30
  38. 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

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 6; 2026: 2.

8 papers.