mlsanityData to 7 Oct 2026

Language Models Need Inductive Biases to Count Inductively

arXiv 2405.20131 ↗First posted 30 May 2024cs.LG cs.CLcited by 25

Not on the map. Why?

Abstract (arXiv)

Counting is a fundamental example of generalization, whether viewed through the mathematical lens of Peano's axioms defining the natural numbers or the cognitive science literature for children learning to count. The argument holds for both cases that learning to count means learning to count infinitely. While few papers have tried to distill transformer "reasoning" to the simplest case of counting, investigating length generalization does occur throughout the literature. In the "train short, test long" paradigm of NLP, length refers to the training sentence length. In formal language recognition, length refers to the input sequence length, or the maximum stack size induced by a pushdown automata. In general problem solving, length refers to the number of hops in a deductive reasoning chain or the recursion depth. For all cases, counting is central to task success. And crucially, generalizing counting inductively is central to success on OOD instances. This work provides extensive empirical results on training language models to count. We experiment with architectures ranging from RNNs, Transformers, State-Space Models and RWKV. We present carefully-designed task formats, auxiliary tasks and positional embeddings to avoid limitations in generalization with OOD-position and OOD-vocabulary. We find that while traditional RNNs trivially achieve inductive counting, Transformers have to rely on positional embeddings to count out-of-domain. As counting is the basis for many arguments concerning the expressivity of Transformers, our finding calls for the community to reexamine the application scope of primitive functions defined in formal characterizations. Finally, modern RNNs also largely underperform traditional RNNs in generalizing counting inductively. We discuss how design choices that enable parallelized training of modern RNNs cause them to lose merits of a recurrent nature.

Key facts. Cited by 25 papers in the map (data through 7 Oct 2026). Builds on 46 of its 60 references that are in the map. First posted on arXiv 30 May 2024.

Builds on

46 of 60 references.

References · 46

  1. 2017Attention Is All You Needcited by 59,932
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  3. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
  4. 2021Efficiently Modeling Long Sequences with Structured State Spacescited by 2,424
  5. 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,085
  6. 2023Progress measures for grokking via mechanistic interpretabilitycited by 822
  7. 2023RWKV: Reinventing RNNs for the Transformer Eracited by 814
  8. 2021Combining Recurrent, Convolutional, and Continuous-time Models with Linear State-Space Layerscited by 607
  9. 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 496
  10. 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 319
  11. 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 286
  12. 2022Transformers Learn Shortcuts to Automatacited by 260
34 more
  1. 2019Analyzing the Structure of Attention in a Transformer Language Modelcited by 241
  2. 2022Neural Networks and the Chomsky Hierarchycited by 214
  3. 2022Exploring Length Generalization in Large Language Modelscited by 204
  4. 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
  5. 2023HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolutioncited by 187
  6. 2023Efficient Large Language Models: A Surveycited by 183
  7. 2021Thinking Like Transformerscited by 182
  8. 2024The Illusion of State in State-Space Modelscited by 181
  9. 2024Eagle and Finch: RWKV with Matrix-Valued States and Dynamic Recurrencecited by 155
  10. 2023The Clock and the Pizza: Two Stories in Mechanistic Explanation of Neural Networkscited by 153
  11. 2022Transformer Language Models without Positional Encodings Still Learn Positional Informationcited by 148
  12. 2021Saturated Transformers are Constant-Depth Threshold Circuitscited by 137
  13. 2023Randomized Positional Encodings Boost Length Generalization of Transformerscited by 114
  14. 2021An Attention Free Transformercited by 111
  15. 2022Teaching Algorithmic Reasoning via In-context Learningcited by 111
  16. 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 110
  17. 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
  18. 2022The CLRS Algorithmic Reasoning Benchmarkcited by 103
  19. 2023Tracr: Compiled Transformers as a Laboratory for Interpretabilitycited by 99
  20. 2022Formal Language Recognition by Hard Attention Transformers: Perspectives from Circuit Complexitycited by 92
  21. 2023Testing the General Deductive Reasoning Capacity of Large Language Models Using OOD Examplescited by 84
  22. 2024Transformers Can Achieve Length Generalization But Not Robustlycited by 82
  23. 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 77
  24. 2023Generalization on the Unseen, Logic Reasoning and Degree Curriculumcited by 73
  25. 2022Simplicity Bias in Transformers and their Ability to Learn Sparse Boolean Functionscited by 68
  26. 2019Sequential Neural Networks as Automatacited by 54
  27. 2020How Can Self-Attention Networks Recognize Dyck-n Languages?cited by 51
  28. 2019LSTM Networks Can Perform Dynamic Countingcited by 45
  29. 2024Counting Like Transformers: Compiling Temporal Counting Logic Into Softmax Transformerscited by 39
  30. 2021SHAPE: Shifted Absolute Position Embedding for Transformerscited by 37
  31. 2023Can Transformers Learn to Solve Problems Recursively?cited by 17
  32. 2024On the Resurgence of Recurrent Models for Long Sequences -- Survey and Research Opportunities in the Transformer Eracited by 17
  33. 2020On the Ability and Limitations of Transformers to Recognize Formal Languagescited by 12
  34. 2024Transformers as Transducerscited by 8

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 2; 2025: 10; 2026: 13.

25 papers.

Sort:

By area:

  1. 2026When Models Manipulate Manifolds: The Geometry of a Counting Taskcited by 43
  2. 2025Why Prompt Design Matters and Works: A Complexity Analysis of Prompt Search Space in LLMscited by 29
  3. 2024When Can Transformers Count to n?cited by 22
  4. 2026Large Language Model Reasoning Failurescited by 20
  5. 2024A Survey on Compositional Learning of AI Models: Theoretical and Experimental Practicescited by 15
  6. 2025Tokenization Constraints in LLMs: A Study of Symbolic and Arithmetic Reasoning Limitscited by 9
  7. 2025Prompt-Based One-Shot Exact Length-Controlled Generation with LLMscited by 4
  8. 2025Language Models, Graph Searching, and Supervision Adulteration: When More Supervision is Less and How to Make More Morecited by 3
  9. 2025From Sub-Ability Diagnosis to Human-Aligned Generation: Bridging the Gap for Text Length Control via MARKERGENcited by 2
  10. 2025Is In-Context Learning Learning?cited by 2
  11. 2025Review of Hallucination Understanding in Large Language and Vision Modelscited by 2
  12. 2025Causality neq Decodability, and Vice Versa: Lessons from Interpreting Counting ViTscited by 2
13 more
  1. 2025Sequential Enumeration in Large Language Modelscited by 2
  2. 2026On the "Induction Bias" in Sequence Modelscited by 2
  3. 2026Reproducing Recurrent Transformers: The CoTFormercited by 1
  4. 2025Learning Model Successorscited by 0
  5. 2026A Vision for Multisensory Intelligence: Sensing, Science, and Synergycited by 0
  6. 2026Semantic Content Determines Algorithmic Performancecited by 0
  7. 2026Do Transformers Have the Ability for Periodicity Generalization?cited by 0
  8. 2026Improved state mixing in higher-order and block diagonal linear recurrent networkscited by 0
  9. 2026Beyond Accuracy: Diagnosing Algebraic Reasoning Failures in LLMs Across Nine Complexity Dimensionscited by 0
  10. 2026Inductive Generalization for Robotic Manipulationcited by 0
  11. 2026The FIL Hypothesis: Inductive Biases Help with Kernel Engineeringcited by 0
  12. 2026When Does Reward Teach State? A Hidden-Automaton Instrument and a Group-Language Warning Signalcited by 0
  13. 2026List Counting Failures Are Not One Phenomenoncited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2024Counting Ability of Large Language Models and Impact of Tokenization
  2. 2024LLM The Genius Paradox: A Linguistic and Math Expert's Struggle with Simple Word-based Counting Problems
  3. 2026Where Induction Runs Out: Description-Length Difficulty and the Memorisation Gap in Integer-Sequence Benchmarks
  4. 2026Mechanistic Interpretability of Large-Scale Counting in LLMs through a System-2 Strategy
  5. 2023Conditions for Length Generalization in Learning Reasoning Skills
  6. 2025Code-driven Number Sequence Calculation: Enhancing the inductive Reasoning Abilities of Large Language Models
  7. 2024Can Large Language Models put 2 and 2 together? Probing for Entailed Arithmetical Relationships
  8. 2024Universal Length Generalization with Turing Programs