What Algorithms can Transformers Learn? A Study in Length Generalization
Not on the map. Why?
Cited by 26 in LLM reasoning, but placed by its own abstract, which didn’t fit.
Abstract (arXiv)
Large language models exhibit surprising emergent generalization properties, yet also struggle on many simple reasoning tasks such as arithmetic and parity. This raises the question of if and when Transformer models can learn the true algorithm for solving a task. We study the scope of Transformers' abilities in the specific setting of length generalization on algorithmic tasks. Here, we propose a unifying framework to understand when and how Transformers can exhibit strong length generalization on a given task. Specifically, we leverage RASP (Weiss et al., 2021) -- a programming language designed for the computational model of a Transformer -- and introduce the RASP-Generalization Conjecture: Transformers tend to length generalize on a task if the task can be solved by a short RASP program which works for all input lengths. This simple conjecture remarkably captures most known instances of length generalization on algorithmic tasks. Moreover, we leverage our insights to drastically improve generalization performance on traditionally hard tasks (such as parity and addition). On the theoretical side, we give a simple example where the "min-degree-interpolator" model of learning from Abbe et al. (2023) does not correctly predict Transformers' out-of-distribution behavior, but our conjecture does. Overall, our work provides a novel perspective on the mechanisms of compositional generalization and the algorithmic capabilities of Transformers.
Key facts. Cited by 198 papers in the map (data through 7 Oct 2026). Builds on 46 of its 62 references that are in the map. First posted on arXiv 24 Oct 2023.
Builds on
46 of 62 references.
References · 46
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Training Verifiers to Solve Math Word Problemscited by 9,743
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
- 2022Least-to-Most Prompting Enables Complex Reasoning in Large Language Modelscited by 1,397
- 2022Solving Quantitative Reasoning Problems with Language Modelscited by 1,359
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,085
- 2022Measuring and Narrowing the Compositionality Gap in Language Modelscited by 1,054
- 2022In-context Learning and Induction Headscited by 930
34 more
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
- 2023Progress measures for grokking via mechanistic interpretabilitycited by 822
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
- 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 496
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 319
- 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 286
- 2023Reasoning or Reciting? Exploring the Capabilities and Limitations of Language Models Through Counterfactual Taskscited by 243
- 2022Exploring Length Generalization in Large Language Modelscited by 204
- 2023How does GPT-2 compute greater-than?: Interpreting mathematical abilities in a pre-trained language modelcited by 199
- 2022The Parallelism Tradeoff: Limitations of Log-Precision Transformerscited by 191
- 2021Thinking Like Transformerscited by 182
- 2023The Clock and the Pizza: Two Stories in Mechanistic Explanation of Neural Networkscited by 153
- 2021Saturated Transformers are Constant-Depth Threshold Circuitscited by 137
- 2021Investigating the Limitations of Transformers with Simple Arithmetic Taskscited by 136
- 2023Representational Strengths and Limitations of Transformerscited by 132
- 2022Faithful Reasoning Using Large Language Modelscited by 130
- 2022Text and Patterns: For Effective Chain of Thought, It Takes Two to Tangocited by 128
- 2015Neural GPUs Learn Algorithmscited by 118
- 2023Randomized Positional Encodings Boost Length Generalization of Transformerscited by 114
- 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 110
- 2023Tracr: Compiled Transformers as a Laboratory for Interpretabilitycited by 99
- 2020Compositional Generalization in Semantic Parsing: Pre-training vs. Specialized Architecturescited by 95
- 2021Neural Algorithmic Reasoningcited by 92
- 2023Testing the General Deductive Reasoning Capacity of Large Language Models Using OOD Examplescited by 84
- 2022Simplicity Bias in Transformers and their Ability to Learn Sparse Boolean Functionscited by 68
- 2023Auto-Regressive Next-Token Predictors are Universal Learnerscited by 65
- 2021Linear algebra with transformerscited by 62
- 2020How Can Self-Attention Networks Recognize Dyck-n Languages?cited by 51
- 2022Towards Better Out-of-Distribution Generalization of Neural Algorithmic Reasoning Taskscited by 29
- 2021Symbolic Brittleness in Sequence Models: on Systematic Generalization in Symbolic Mathematicscited by 27
- 2023Transformer Working Memory Enables Regular Language Reasoning and Natural Language Length Extrapolationcited by 13
- 2022Benchmarking Compositionality with Formal Languagescited by 12
- 2023Improving Length-Generalization in Transformers via Task Hintingcited by 12
Built on by
Citing papers per year: 2023: 4; 2024: 80; 2025: 66; 2026: 48.
198 papers.
Sort:
By area:
- 2024GSM-Symbolic: Understanding the Limitations of Mathematical Reasoning in Large Language Modelscited by 533
- 2024CRUXEval: A Benchmark for Code Reasoning, Understanding and Executioncited by 294
- 2024Repeat After Me: Transformers are Better than State Space Models at Copyingcited by 208
- 2023What Formal Languages Can Transformers Express? A Surveycited by 120
- 2024Tokenization counts: the impact of tokenization on arithmetic in frontier LLMscited by 112
- 2023Mechanistically analyzing the effects of fine-tuning on procedurally defined taskscited by 110
- 2024Rethinking Interpretability in the Era of Large Language Modelscited by 110
- 2024Physics of Language Models: Part 2.1, Grade-School Math and the Hidden Reasoning Processcited by 107
- 2024Can Mamba Learn How to Learn? A Comparative Study on In-Context Learning Taskscited by 104
- 2024A Primer on the Inner Workings of Transformer-based Language Modelscited by 83
- 2024Transformers Can Achieve Length Generalization But Not Robustlycited by 82
- 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 77
38 more
- 2024Why are Sensitive Functions Hard for Transformers?cited by 74
- 2024Premise Order Matters in Reasoning with Large Language Modelscited by 71
- 2025All Roads Lead to Likelihood: The Value of Reinforcement Learning in Fine-Tuningcited by 58
- 2025Position: Graph Learning Will Lose Relevance Due To Poor Benchmarkscited by 52
- 2024Physics of Language Models: Part 2.2, How to Learn From Mistakes on Grade-School Math Problemscited by 49
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 44
- 2024Neural Redshift: Random Networks are not Random Functionscited by 43
- 2024Number Cookbook: Number Understanding of Language Models and How to Improve Itcited by 41
- 2024The Unreasonable Effectiveness of Easy Training Data for Hard Taskscited by 40
- 2024Counting Like Transformers: Compiling Temporal Counting Logic Into Softmax Transformerscited by 39
- 2024Talking Heads: Understanding Inter-layer Communication in Transformer Language Modelscited by 39
- 2025Between Circuits and Chomsky: Pre-pretraining on Formal Languages Imparts Linguistic Biasescited by 36
- 2024How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpadcited by 35
- 2023Length Extrapolation of Transformers: A Survey from the Perspective of Positional Encodingcited by 32
- 2024DAPE: Data-Adaptive Positional Encoding for Length Extrapolationcited by 30
- 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challengescited by 30
- 2024Separations in the Representational Capabilities of Transformers and Recurrent Architecturescited by 29
- 2024The CLRS-Text Algorithmic Reasoning Language Benchmarkcited by 28
- 2024Out-of-distribution generalization via composition: a lens through induction heads in Transformerscited by 28
- 2025LongProc: Benchmarking Long-Context Language Models on Long Procedural Generationcited by 28
- 2025Lower Bounds for Chain-of-Thought Reasoning in Hard-Attention Transformerscited by 28
- 2024Selective Attention Improves Transformercited by 26
- 2024Language Models Need Inductive Biases to Count Inductivelycited by 25
- 2024Universal Length Generalization with Turing Programscited by 25
- 2024Understanding Reasoning Ability of Language Models From the Perspective of Reasoning Paths Aggregationcited by 22
- 2024On Provable Length and Compositional Generalizationcited by 22
- 2024Position Coupling: Improving Length Generalization of Arithmetic Transformers Using Task Structurecited by 22
- 2023Compositional Capabilities of Autoregressive Transformers: A Study on Synthetic, Interpretable Taskscited by 21
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannotcited by 21
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descentcited by 21
- 2025Implicit Language Models are RNNs: Balancing Parallelization and Expressivitycited by 21
- 2025FoNE: Precise Single-Token Number Embeddings via Fourier Featurescited by 21
- 2024Mixture of Parrots: Experts improve memorization more than reasoningcited by 20
- 2024What Can Transformer Learn with Varying Depth? Case Studies on Sequence Learning Taskscited by 19
- 2024Representation Shattering in Transformers: A Synthetic Study with Knowledge Editingcited by 18
- 2025Long-Context Generalization with Sparse Attentioncited by 18
- 2024A Philosophical Introduction to Language Models - Part II: The Way Forwardcited by 17
- 2025Finite State Automata Inside Transformers with Chain-of-Thought: A Mechanistic Study on State Trackingcited by 17
50 most cited of 198 All 198 (JSON)
- 2026Beyond the Training Horizon: Mechanisms and Limits of Length Generalization in Looped Transformers27 Sep 2026
- 2026Distance generalization in transformers: why bother with positional encoding?10 Sep 2026
- 2026Length Generalization for Transformers via Compression8 Sep 2026
- 2026Universal Transformers for Circuit Computations: Perfect Length Generalization in Tiny Transformers31 Aug 2026
- 2026Where Cognition Lives: Dissecting Emergent from Computed Function in a Minimal Complete Cognitive Architecture23 Aug 2026
- 2026Relative Positions Generalize, Absolute Positions Memorize: An Implicit-Bias Account of Length Generalization in Attention21 Jul 2026
- 2026Planning with Transformers: Chain of Computation and Structured Context Windows20 Jul 2026
- 2026Can Transformers Really Do It All? On the Compatibility of Inductive Biases Across Tasks20 Jul 2026
- 2026Hierarchical Domain Generalization17 Jul 2026
- 2026Stabilizing Extrapolation in Looped Transformers via Learned Stochastic Stopping29 Jun 2026
- 2026A Theoretical Interpretation of In-Context Learning via Probabilistic Modeling27 Jun 2026
- 2026Fine-Tuning Large Language Models for Quantum Reasoning20 Jun 2026
38 more
- 2026A Verifiable Search Is Not a Learnable Chain-of-Thought20 Jun 2026
- 2026Positional versus Symbolic Attention Heads: Learning Dynamics, RoPE Geometry, and Length Generalization29 May 2026
- 2026Learning to Extrapolate to New Tasks: A Relational Approach to Task Extrapolation28 May 2026
- 2026The Importance of Being Statistically Earnest: A Critical Re-evaluation of GSM-Symbolic27 May 2026
- 2026Compositional Generalization in Autoregressive Models via Logit Composition27 May 2026
- 2026Length Generalization with Log-Depth Recurrent Units25 May 2026
- 2026Benchmarking Compositional Generalisation for Machine Learning Interatomic Potentials9 May 2026
- 2026When LLMs Stop Following Steps: A Diagnostic Study of Procedural Execution in Language Models1 May 2026
- 2026Beyond the Training Distribution: Mapping Generalization Boundaries in Neural Program Synthesis30 Apr 2026
- 2026Barriers to Universal Reasoning With Transformers (And How to Overcome Them)28 Apr 2026
- 2026Training Transformers as a Universal Computer28 Apr 2026
- 2026On the Emergence of Syntax by Means of Local Interaction20 Apr 2026
- 2026Recurrent Reasoning on Symbolic Puzzles with Sequence Models19 Apr 2026
- 2026Generalization in LLM Problem Solving: The Case of the Shortest Path16 Apr 2026
- 2026On the Mirage of Long-Range Dependency, with an Application to Integer Multiplication30 Mar 2026
- 2026On the Ability of Transformers to Verify Plans20 Mar 2026
- 2026Tabular LLMs for Interpretable Few-Shot Alzheimer's Disease Prediction with Multimodal Biomedical Data17 Mar 2026
- 2026Transformers Can Learn Rules They've Never Seen: Proof of Computation Beyond Interpolation17 Mar 2026
- 2026Predictive Statistics Shape Emergent World Representations of Grid Walkers17 Mar 2026
- 2026Algorithmic Task Capture, Computational Complexity, and Inductive Bias of Infinite Transformers11 Mar 2026
- 2026LEAD: Breaking the No-Recovery Bottleneck in Long-Horizon Reasoning6 Mar 2026
- 2026Graph Property Inference in Small Language Models: Effects of Representation and Reasoning Strategy24 Feb 2026
- 2026Synthesis and Verification of Transformer Programs (Technical Report)18 Feb 2026
- 2026Seeing to Generalize: How Visual Data Corrects Binding Shortcuts16 Feb 2026
- 2026Universal priors: solving empirical Bayes via Bayesian inference and pretraining16 Feb 2026
- 2026Boule or Baguette? A Study on Task Topology, Length Generalization, and the Benefit of Reasoning Traces16 Feb 2026
- 2026Length Generalization Bounds for Transformers13 Feb 2026
- 2026AI-rithmetic11 Feb 2026
- 2026Positive Distribution Shift as a Framework for Understanding Tractable Learning9 Feb 2026
- 2026Learning Nonlinear Systems In-Context: From Synthetic Data to Real-World Motor Control6 Feb 2026
- 2026On the Role of Computation in Reinforcement Learning5 Feb 2026
- 2026Structural Disentanglement in Bilinear MLPs via Architectural Inductive Bias5 Feb 2026
- 2026Every Bit Counts: A Theoretical Study of Precision-Expressivity Tradeoffs in Quantized Transformers2 Feb 2026
- 2026On the Spatiotemporal Dynamics of Generalization in Neural Networks2 Feb 2026
- 2026Semantic Content Determines Algorithmic Performance29 Jan 2026
- 2026A model of errors in transformers20 Jan 2026
- 2025Adapting, Fast and Slow: On Few-Shot Transportability of Compositions28 Dec 2025
- 2025From Shortcut to Induction Head: How Data Diversity Shapes Algorithm Selection in Transformers21 Dec 2025
50 newest of 198 All 198 (JSON)
- 2024GSM-Symbolic: Understanding the Limitations of Mathematical Reasoning in Large Language Modelscited by 533
- 2024Rethinking Interpretability in the Era of Large Language Modelscited by 110
- 2024Physics of Language Models: Part 2.1, Grade-School Math and the Hidden Reasoning Processcited by 107
- 2024Premise Order Matters in Reasoning with Large Language Modelscited by 71
- 2024Physics of Language Models: Part 2.2, How to Learn From Mistakes on Grade-School Math Problemscited by 49
- 2024The Unreasonable Effectiveness of Easy Training Data for Hard Taskscited by 40
- 2024The CLRS-Text Algorithmic Reasoning Language Benchmarkcited by 28
- 2025Lower Bounds for Chain-of-Thought Reasoning in Hard-Attention Transformerscited by 28
- 2024Understanding Reasoning Ability of Language Models From the Perspective of Reasoning Paths Aggregationcited by 22
- 2025Implicit Language Models are RNNs: Balancing Parallelization and Expressivitycited by 21
- 2025Finite State Automata Inside Transformers with Chain-of-Thought: A Mechanistic Study on State Trackingcited by 17
- 2024Transformers meet Neural Algorithmic Reasonerscited by 12
12 most cited of 26 All 26 (JSON)
- 2026Beyond the Training Horizon: Mechanisms and Limits of Length Generalization in Looped Transformers27 Sep 2026
- 2026Fine-Tuning Large Language Models for Quantum Reasoning20 Jun 2026
- 2026A Verifiable Search Is Not a Learnable Chain-of-Thought20 Jun 2026
- 2026The Importance of Being Statistically Earnest: A Critical Re-evaluation of GSM-Symbolic27 May 2026
- 2026Barriers to Universal Reasoning With Transformers (And How to Overcome Them)28 Apr 2026
- 2026Recurrent Reasoning on Symbolic Puzzles with Sequence Models19 Apr 2026
- 2026LEAD: Breaking the No-Recovery Bottleneck in Long-Horizon Reasoning6 Mar 2026
- 2026Graph Property Inference in Small Language Models: Effects of Representation and Reasoning Strategy24 Feb 2026
- 2026Boule or Baguette? A Study on Task Topology, Length Generalization, and the Benefit of Reasoning Traces16 Feb 2026
- 2025When Do Symbolic Solvers Enhance Reasoning in Large Language Models?2 Dec 2025
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization10 Nov 2025
- 2025The Imitation Game: Turing Machine Imitator is Length Generalizable Reasoner17 Jul 2025
12 newest of 26 All 26 (JSON)
- 2024CRUXEval: A Benchmark for Code Reasoning, Understanding and Executioncited by 294
- 2024Repeat After Me: Transformers are Better than State Space Models at Copyingcited by 208
- 2023What Formal Languages Can Transformers Express? A Surveycited by 120
- 2024Tokenization counts: the impact of tokenization on arithmetic in frontier LLMscited by 112
- 2023Mechanistically analyzing the effects of fine-tuning on procedurally defined taskscited by 110
- 2024A Primer on the Inner Workings of Transformer-based Language Modelscited by 83
- 2024Transformers Can Achieve Length Generalization But Not Robustlycited by 82
- 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 77
- 2024Why are Sensitive Functions Hard for Transformers?cited by 74
- 2025All Roads Lead to Likelihood: The Value of Reinforcement Learning in Fine-Tuningcited by 58
- 2025Position: Graph Learning Will Lose Relevance Due To Poor Benchmarkscited by 52
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 44
12 most cited of 160 All 160 (JSON)
- 2026Distance generalization in transformers: why bother with positional encoding?10 Sep 2026
- 2026Length Generalization for Transformers via Compression8 Sep 2026
- 2026Universal Transformers for Circuit Computations: Perfect Length Generalization in Tiny Transformers31 Aug 2026
- 2026Where Cognition Lives: Dissecting Emergent from Computed Function in a Minimal Complete Cognitive Architecture23 Aug 2026
- 2026Relative Positions Generalize, Absolute Positions Memorize: An Implicit-Bias Account of Length Generalization in Attention21 Jul 2026
- 2026Planning with Transformers: Chain of Computation and Structured Context Windows20 Jul 2026
- 2026Can Transformers Really Do It All? On the Compatibility of Inductive Biases Across Tasks20 Jul 2026
- 2026Hierarchical Domain Generalization17 Jul 2026
- 2026Stabilizing Extrapolation in Looped Transformers via Learned Stochastic Stopping29 Jun 2026
- 2026A Theoretical Interpretation of In-Context Learning via Probabilistic Modeling27 Jun 2026
- 2026Positional versus Symbolic Attention Heads: Learning Dynamics, RoPE Geometry, and Length Generalization29 May 2026
- 2026Learning to Extrapolate to New Tasks: A Relational Approach to Task Extrapolation28 May 2026
12 newest of 160 All 160 (JSON)