Quantitative Bounds for Length Generalization in Transformers
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Builds on 33 of its 38 references that are in the map. First posted on arXiv 30 Oct 2025.
Builds on
33 of 38 references.
References · 33
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
- 2022In-context Learning and Induction Headscited by 964
- 2020A Primer in BERTology: What we know about how BERT workscited by 815
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 327
- 2022Tensor Programs V: Tuning Large Neural Networks via Zero-Shot Hyperparameter Transfercited by 288
- 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
- 2021Thinking Like Transformerscited by 184
- 2023Birth of a Transformer: A Memory Viewpointcited by 161
- 2023Teaching Arithmetic to Small Transformerscited by 123
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
21 more
- 2024Looped Transformers for Length Generalizationcited by 99
- 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 78
- 2022A Logic for Expressing Log-Precision Transformerscited by 67
- 2023Positional Description Matters for Transformers Arithmeticcited by 56
- 2024A Formal Framework for Understanding Length Generalization in Transformerscited by 45
- 2024Counting Like Transformers: Compiling Temporal Counting Logic Into Softmax Transformerscited by 39
- 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challengescited by 31
- 2025Understanding and Improving Length Generalization in Recurrent Modelscited by 23
- 2024On Provable Length and Compositional Generalizationcited by 22
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannotcited by 22
- 2024Arithmetic Transformers Can Length-Generalize in Both Operand Length and Countcited by 18
- 2025Extrapolation by Association: Length Generalization Transfer in Transformerscited by 13
- 2025Tropical Attention: Neural Algorithmic Reasoning for Combinatorial Algorithmscited by 12
- 2025Knee-Deep in C-RASP: A Transformer Depth Hierarchycited by 12
- 2025Graph neural networks extrapolate out-of-distribution for shortest pathscited by 11
- 2025Unique Hard Attention: A Tale of Two Sidescited by 10
- 2025The Role of Sparsity for Length Generalization in Transformerscited by 8
- 2025Non-Asymptotic Length Generalizationcited by 7
- 2025On Vanishing Variance in Transformer Length Generalizationcited by 6
- 2025Born a Transformer -- Always a Transformer? On the Effect of Pretraining on Architectural Abilitiescited by 6
- 2025Scale-invariant Attentioncited by 5
Built on by
Citing papers per year: 2025: 1; 2026: 7.
8 papers.
- 2025Softmax Transformers are Turing-Completecited by 9
- 2026Length Generalization Bounds for Transformerscited by 4
- 2026When Does Sparsity Mitigate the Curse of Depth in LLMscited by 4
- 2026On the Ability of Transformers to Verify Planscited by 2
- 2026Universal priors: solving empirical Bayes via Bayesian inference and pretrainingcited by 1
- 2026Tracing LLM Behavior to the Training Data with Empirical Next-Token Distributionscited by 0
- 2026Hierarchical Domain Generalizationcited by 0
- 2026Distance generalization in transformers: why bother with positional encoding?cited by 0
- 2026Distance generalization in transformers: why bother with positional encoding?10 Sep 2026
- 2026Hierarchical Domain Generalization17 Jul 2026
- 2026Tracing LLM Behavior to the Training Data with Empirical Next-Token Distributions15 Jul 2026
- 2026On the Ability of Transformers to Verify Plans20 Mar 2026
- 2026When Does Sparsity Mitigate the Curse of Depth in LLMs16 Mar 2026
- 2026Universal priors: solving empirical Bayes via Bayesian inference and pretraining16 Feb 2026
- 2026Length Generalization Bounds for Transformers13 Feb 2026
- 2025Softmax Transformers are Turing-Complete25 Nov 2025