Counting and Algorithmic Generalization with Transformers
Not on the map. Why?
Abstract (arXiv)
Algorithmic generalization in machine learning refers to the ability to learn the underlying algorithm that generates data in a way that generalizes out-of-distribution. This is generally considered a difficult task for most machine learning algorithms. Here, we analyze algorithmic generalization when counting is required, either implicitly or explicitly. We show that standard Transformers are based on architectural decisions that hinder out-of-distribution performance for such tasks. In particular, we discuss the consequences of using layer normalization and of normalizing the attention weights via softmax. With ablation of the problematic operations, we demonstrate that a modified transformer can exhibit a good algorithmic generalization performance on counting while using a very lightweight architecture.
Key facts. Cited by 11 papers in the map (data through 13 Oct 2026). Builds on 10 of its 17 references that are in the map. First posted on arXiv 12 Oct 2023.
Builds on
10 of 17 references.
References · 10
- 2017Attention Is All You Needcited by 60,106
- 2018Universal Transformerscited by 632
- 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 287
- 2015Neural GPUs Learn Algorithmscited by 120
- 2018On the Practical Computational Power of Finite Precision RNNs for Language Recognitioncited by 117
- 2019LSTM Networks Can Perform Dynamic Countingcited by 45
- 2016Extensions and Limitations of the Neural GPUcited by 7
- 2022Transformers discover an elementary calculation system exploiting local attention and grid-like problem representationcited by 7
- 2022Exploring the Long-Term Generalization of Counting Behavior in RNNscited by 7
- 2017Improving the Neural GPU Architecture for Algorithm Learningcited by 4
Built on by
Citing papers per year: 2024: 3; 2025: 4; 2026: 4.
11 papers.
- 2025Frontier LLMs Still Struggle with Simple Reasoning Taskscited by 20
- 2024Composing Global Solutions to Reasoning Tasks via Algebraic Objects in Neural Netscited by 6
- 2024Counting in Small Transformers: The Delicate Interplay between Attention and Feed-Forward Layerscited by 5
- 2025Sequential Enumeration in Large Language Modelscited by 3
- 2026Parallel Test-Time Scaling with Multi-Sequence Verifierscited by 2
- 2025ECG-aBcDe: Overcoming Model Dependence, Encoding ECG into a Universal Language for Any LLMcited by 1
- 2025Vector Symbolic Algebras for the Abstraction and Reasoning Corpuscited by 1
- 2024System 2 Reasoning for Human-AI Alignment: Generality and Adaptivity via ARC-AGIcited by 0
- 2026Semantic Content Determines Algorithmic Performancecited by 0
- 2026Do Transformers Have the Ability for Periodicity Generalization?cited by 0
- 2026Sparsity Moves Computation: How FFN Architecture Reshapes Attention in Small Transformerscited by 0
- 2026Sparsity Moves Computation: How FFN Architecture Reshapes Attention in Small Transformers10 May 2026
- 2026Parallel Test-Time Scaling with Multi-Sequence Verifiers3 Mar 2026
- 2026Do Transformers Have the Ability for Periodicity Generalization?30 Jan 2026
- 2026Semantic Content Determines Algorithmic Performance29 Jan 2026
- 2025Sequential Enumeration in Large Language Models4 Dec 2025
- 2025Vector Symbolic Algebras for the Abstraction and Reasoning Corpus11 Nov 2025
- 2025ECG-aBcDe: Overcoming Model Dependence, Encoding ECG into a Universal Language for Any LLM16 Sep 2025
- 2025Frontier LLMs Still Struggle with Simple Reasoning Tasks9 Jul 2025
- 2024System 2 Reasoning for Human-AI Alignment: Generality and Adaptivity via ARC-AGI10 Oct 2024
- 2024Composing Global Solutions to Reasoning Tasks via Algebraic Objects in Neural Nets2 Oct 2024
- 2024Counting in Small Transformers: The Delicate Interplay between Attention and Feed-Forward Layers16 Jul 2024