Quantitative Bounds for Length Generalization in Transformers
Zachary Izzo, Eshaan Nichani, Jason D. Lee
Abstract
We study the problem of length generalization (LG) in transformers: the ability of a model trained on shorter sequences to maintain performance when evaluated on much longer, previously unseen inputs. Prior work by Huang et al. (2025) established that transformers eventually achieve length generalization once the training sequence length exceeds some finite threshold, but left open the question of how large it must be. In this work, we provide the first quantitative bounds on the required training length for length generalization to occur. Motivated by previous empirical and theoretical work, we analyze LG in several distinct problem settings: ℓ ∞ error control vs. average error control over an input distribution, infinite-precision softmax attention vs. finite-precision attention (which reduces to an argmax) in the transformer, and one-vs. two-layer transformers. In all scenarios, we prove that LG occurs when the internal behavior of the transformer on longer sequences can be "simulated" by its behavior on shorter sequences seen during training. Our bounds give qualitative estimates for the length of training data required for a transformer to generalize, and we verify these insights empirically. These results sharpen our theoretical understanding of the mechanisms underlying extrapolation in transformers, and formalize the intuition that richer training data is required for generalization on more complex tasks.
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.
6 top-tier papers have 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
- What Algorithms can Transformers Learn? A Study in Length Generalization cites Thinking Like Transformers
- What Algorithms can Transformers Learn? A Study in Length Generalization cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- What Algorithms can Transformers Learn? A Study in Length Generalization cites The Impact of Positional Encoding on Length Generalization in Transformers
- What Algorithms can Transformers Learn? A Study in Length Generalization cites Exploring Length Generalization in Large Language Models
- Length Generalization Bounds for Transformers cites What Algorithms can Transformers Learn? A Study in Length Generalization
- Length Generalization Bounds for Transformers cites Thinking Like Transformers
- Length Generalization Bounds for Transformers cites Exploring Length Generalization in Large Language Models
- Softmax Transformers are Turing-Complete cites Thinking Like Transformers
- Softmax Transformers are Turing-Complete cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Discovering Interpretable Algorithms by Decompiling Transformers to RASP cites What Algorithms can Transformers Learn? A Study in Length Generalization
- Discovering Interpretable Algorithms by Decompiling Transformers to RASP cites Softmax Transformers are Turing-Complete
- Discovering Interpretable Algorithms by Decompiling Transformers to RASP cites Thinking Like Transformers
- The Impact of Positional Encoding on Length Generalization in Transformers cites Thinking Like Transformers
- The Impact of Positional Encoding on Length Generalization in Transformers cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- The Impact of Positional Encoding on Length Generalization in Transformers cites Exploring Length Generalization in Large Language Models
- On the Ability of Transformers to Verify Plans cites Softmax Transformers are Turing-Complete
- On the Ability of Transformers to Verify Plans cites Thinking Like Transformers
- On the Ability of Transformers to Verify Plans cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- On the Ability of Transformers to Verify Plans cites The Impact of Positional Encoding on Length Generalization in Transformers
- On the Ability of Transformers to Verify Plans cites Exploring Length Generalization in Large Language Models
- Exploring Length Generalization in Large Language Models cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
Cited by top-tier papers6
- Softmax Transformers are Turing-CompleteHongjian Jiang, Michael Hahn, Georg Zetzsche, Anthony W. LinICLR 2026 · 12 citations
- When Does Sparsity Mitigate the Curse of Depth in LLMsYao Yao, Xinyuan Song, Sebastian Pokutta, Max Zimmer et al.ICML 2026 · 5 citations
- Discovering Interpretable Algorithms by Decompiling Transformers to RASPXinting Huang, Aleksandra Bakalova, Satwik Bhattamishra, William Merrill et al.ICML 2026 · 3 citations
- On the Ability of Transformers to Verify PlansYash Sarrof, Yupei Du, Katharina Stein, Alexander Koller et al.ICML 2026 · 1 citation
- Length Generalization Bounds for TransformersAndy Yang, Pascal Bergsträßer, Georg Zetzsche, David Chiang et al.ICML 2026
Builds on21
- Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 citations
- The Impact of Positional Encoding on Length Generalization in TransformersAmirhossein Kazemnejad, Inkit Padhi, Karthikeyan Natesan Ramamurthy, Payel Das et al.NeurIPS 2023 · 444 citations
- Exploring Length Generalization in Large Language ModelsCem Anil, Yuhuai Wu, Anders Andreassen, Aitor Lewkowycz et al.NeurIPS 2022 · 267 citations
- What Algorithms can Transformers Learn? A Study in Length GeneralizationHattie Zhou, Arwen Bradley, Etai Littwin, Noam Razin et al.ICLR 2024 · 189 citations
- Thinking Like TransformersGail Weiss, Yoav Goldberg, Eran YahavICML 2021 · 183 citations
Related papers
- Length Generalization via Auxiliary TasksPranjal Awasthi, Anupam Gupta, Ravi KumarNeurIPS 2025
- Extrapolation by Association: Length Generalization Transfer In TransformersZiyang Cai, Nayoung Lee, Avi Schwarzschild, Samet Oymak et al.NeurIPS 2025 · 13 citations
- A Formal Framework for Understanding Length Generalization in TransformersXinting Huang, Andy Yang, Satwik Bhattamishra, Yash Raj Sarrof et al.ICLR 2025
- Generalizing Reasoning Problems to Longer LengthsChangnan Xiao, Bing LiuICLR 2025
- On the "Induction Bias" in Sequence ModelsMohammadReza Ebrahimi, Michaël Defferrard, Sunny Panchal, Roland MemisevicICML 2026 · 3 citations
