Explicitly Encoding Structural Symmetry is Key to Length Generalization in Arithmetic Tasks
On the map: LLM reasoning → Mathematical reasoning
Abstract (arXiv)
Despite the success of Transformers on language understanding, code generation, and logical reasoning, they still fail to generalize over length on basic arithmetic tasks such as addition and multiplication. A major reason behind this failure is the vast difference in structure between numbers and text; For example, the numbers are typically parsed from right to left, and there is a correspondence between digits at the same position across different numbers. In contrast, for text, such symmetries are quite unnatural. In this work, we propose to encode these semantics explicitly into the model via modified number formatting and custom positional encodings. Empirically, our method allows a Transformer trained on numbers with at most 5-digits for addition and multiplication to generalize up to 50-digit numbers, without using additional data for longer sequences. We further demonstrate that traditional absolute positional encodings (APE) fail to generalize to longer sequences, even when trained with augmented data that captures task symmetries. To elucidate the importance of explicitly encoding structure, we prove that explicit incorporation of structure via positional encodings is necessary for out-of-distribution generalization. Finally, we pinpoint other challenges inherent to length generalization beyond capturing symmetries, in particular complexity of the underlying task, and propose changes in the training distribution to address them.
Key facts. Cited by 10 papers in the map (data through 7 Oct 2026). Placed in Mathematical reasoning, one of 17 directions in LLM reasoning. Builds on 38 of its 45 references that are in the map. First posted on arXiv 4 Jun 2024.
Builds on
38 of 45 references.
Closest ancestors · 1
Same direction, newest first
Other references · 37
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,898
- 2022Emergent Abilities of Large Language Modelscited by 2,483
- 2018Self-Attention with Relative Position Representationscited by 1,112
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,085
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
- 2022Transformers learn in-context by gradient descentcited by 714
25 more
- 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 496
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 319
- 2022Transformers Learn Shortcuts to Automatacited by 260
- 2016A Decomposable Attention Model for Natural Language Inferencecited by 214
- 2022Exploring Length Generalization in Large Language Modelscited by 204
- 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 168
- 2019Do NLP Models Know Numbers? Probing Numeracy in Embeddingscited by 157
- 2022Impact of Pretraining Term Frequencies on Few-Shot Reasoningcited by 142
- 2020Injecting Numerical Reasoning Skills into Language Modelscited by 133
- 2023Teaching Arithmetic to Small Transformerscited by 121
- 2023Randomized Positional Encodings Boost Length Generalization of Transformerscited by 114
- 2023Linear attention is (maybe) all you need (to understand transformer optimization)cited by 97
- 2022Vision Transformers provably learn spatial structurecited by 92
- 2021Representing Numbers in NLP: a Survey and a Visioncited by 83
- 2023Exposing Attention Glitches with Flip-Flop Language Modelingcited by 74
- 2023Generalization on the Unseen, Logic Reasoning and Degree Curriculumcited by 73
- 2023GPT Can Solve Mathematical Problems Without a Calculatorcited by 68
- 2023Length Generalization in Arithmetic Transformerscited by 64
- 2023Positional Description Matters for Transformers Arithmeticcited by 56
- 2022Neurocompositional computing: From the Central Paradox of Cognition to a new generation of AI systemscited by 44
- 2023Understanding Addition in Transformerscited by 34
- 2022Towards Better Out-of-Distribution Generalization of Neural Algorithmic Reasoning Taskscited by 29
- 2022Systematic Generalization and Emergent Structures in Transformers Trained on Structured Taskscited by 19
- 2021Exploring Generalization Ability of Pretrained Language Models on Arithmetic and Logical Reasoningcited by 17
Built on by
Citing papers per year: 2024: 1; 2025: 6; 2026: 3.
10 papers.
- 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challengescited by 30
- 2025Lower Bounds for Chain-of-Thought Reasoning in Hard-Attention Transformerscited by 28
- 2025Extrapolation by Association: Length Generalization Transfer in Transformerscited by 13
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalizationcited by 12
- 2024DAPE V2: Process Attention Score as Feature Map for Length Extrapolationcited by 10
- 2025The Role of Sparsity for Length Generalization in Transformerscited by 8
- 2025h1: Bootstrapping LLMs to Reason over Longer Horizons via Reinforcement Learningcited by 8
- 2026Arithmetic OOD Failure Unfolds in Stages in Minimal GPTscited by 0
- 2026Relative Positions Generalize, Absolute Positions Memorize: An Implicit-Bias Account of Length Generalization in Attentioncited by 0
- 2026Beyond the Training Horizon: Mechanisms and Limits of Length Generalization in Looped Transformerscited by 0
- 2026Beyond the Training Horizon: Mechanisms and Limits of Length Generalization in Looped Transformers27 Sep 2026
- 2026Relative Positions Generalize, Absolute Positions Memorize: An Implicit-Bias Account of Length Generalization in Attention21 Jul 2026
- 2026Arithmetic OOD Failure Unfolds in Stages in Minimal GPTs27 Mar 2026
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization10 Nov 2025
- 2025h1: Bootstrapping LLMs to Reason over Longer Horizons via Reinforcement Learning8 Oct 2025
- 2025Extrapolation by Association: Length Generalization Transfer in Transformers10 Jun 2025
- 2025The Role of Sparsity for Length Generalization in Transformers24 Feb 2025
- 2025Lower Bounds for Chain-of-Thought Reasoning in Hard-Attention Transformers4 Feb 2025
- 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challenges3 Feb 2025
- 2024DAPE V2: Process Attention Score as Feature Map for Length Extrapolation7 Oct 2024
Similar, not cited
Close in wording, no citation either way
- 2024Unraveling Arithmetic in Large Language Models: The Role of Algebraic Structures
- 2024Principled Understanding of Generalization for Generative Transformer Models in Arithmetic Reasoning Tasks
- 2025Do Large Language Models Truly Grasp Addition? A Rule-Focused Diagnostic Using Two-Integer Arithmetic
- 2024Tokenization counts: the impact of tokenization on arithmetic in frontier LLMs
- 2024Universal Length Generalization with Turing Programs
- 2026Value-Aware Numerical Representations for Transformer Language Models
- 2025Efficient numeracy in language models through single-token number embeddings
- 2024Language Models Do Hard Arithmetic Tasks Easily and Hardly Do Easy Arithmetic Tasks