Exploring the Long-Term Generalization of Counting Behavior in RNNs
Not on the map. Why?
Abstract (arXiv)
In this study, we investigate the generalization of LSTM, ReLU and GRU models on counting tasks over long sequences. Previous theoretical work has established that RNNs with ReLU activation and LSTMs have the capacity for counting with suitable configuration, while GRUs have limitations that prevent correct counting over longer sequences. Despite this and some positive empirical results for LSTMs on Dyck-1 languages, our experimental results show that LSTMs fail to learn correct counting behavior for sequences that are significantly longer than in the training data. ReLUs show much larger variance in behavior and in most cases worse generalization. The long sequence generalization is empirically related to validation loss, but reliable long sequence generalization seems not practically achievable through backpropagation with current techniques. We demonstrate different failure modes for LSTMs, GRUs and ReLUs. In particular, we observe that the saturation of activation functions in LSTMs and the correct weight setting for ReLUs to generalize counting behavior are not achieved in standard training regimens. In summary, learning generalizable counting behavior is still an open problem and we discuss potential approaches for further research.
Key facts. Cited by 7 papers in the map (data through 7 Oct 2026). Builds on 8 of its 16 references that are in the map. First posted on arXiv 29 Nov 2022.
Builds on
8 of 16 references.
References · 8
- 2017Attention Is All You Needcited by 59,932
- 2014Adam: A Method for Stochastic Optimizationcited by 36,960
- 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,970
- 2015A Simple Way to Initialize Recurrent Networks of Rectified Linear Unitscited by 130
- 2018On the Practical Computational Power of Finite Precision RNNs for Language Recognitioncited by 117
- 2020A Formal Hierarchy of RNN Architecturescited by 61
- 2019LSTM Networks Can Perform Dynamic Countingcited by 45
- 2020On the Linguistic Capacity of Real-Time Counter Automatacited by 16
Built on by
Citing papers per year: 2023: 3; 2024: 1; 2025: 1; 2026: 2.
7 papers.
- 2024Bridging the Empirical-Theoretical Gap in Neural Network Formal Language Learning Using Minimum Description Lengthcited by 14
- 2023Counting and Algorithmic Generalization with Transformerscited by 11
- 2025Which Word Orders Facilitate Length Generalization in LMs? An Investigation with GCG-Based Artificial Languagescited by 4
- 2023Theoretical Conditions and Empirical Failure of Bracket Counting on Long Sequences with Linear Recurrent Networkscited by 3
- 2023Benchmarking Neural Network Generalization for Grammar Inductioncited by 3
- 2026On the Spatiotemporal Dynamics of Generalization in Neural Networkscited by 3
- 2026What Kind of Language is Easy to Language-Model Under Curriculum Learning?cited by 0
- 2026What Kind of Language is Easy to Language-Model Under Curriculum Learning?29 Apr 2026
- 2026On the Spatiotemporal Dynamics of Generalization in Neural Networks2 Feb 2026
- 2025Which Word Orders Facilitate Length Generalization in LMs? An Investigation with GCG-Based Artificial Languages14 Oct 2025
- 2024Bridging the Empirical-Theoretical Gap in Neural Network Formal Language Learning Using Minimum Description Length15 Feb 2024
- 2023Counting and Algorithmic Generalization with Transformers12 Oct 2023
- 2023Benchmarking Neural Network Generalization for Grammar Induction16 Aug 2023
- 2023Theoretical Conditions and Empirical Failure of Bracket Counting on Long Sequences with Linear Recurrent Networks7 Apr 2023