Training Neural Networks as Recognizers of Formal Languages
Alexandra Butoi, Ghazal Khalighinejad, Anej Svete, Josef Valvoda, Ryan Cotterell, Brian DuSell
Abstract
Characterizing the computational power of neural network architectures in terms of formal language theory remains a crucial line of research, as it describes lower and upper bounds on the reasoning capabilities of modern AI. However, when empirically testing these bounds, existing work often leaves a discrepancy between experiments and the formal claims they are meant to support. The problem is that formal language theory pertains specifically to recognizers: machines that receive a string as input and classify whether it belongs to a language. On the other hand, it is common instead to evaluate language models on proxy tasks, e.g., language modeling or sequence-to-sequence transduction, that are similar in only an informal sense to the underlying theory. We correct this mismatch by training and evaluating neural networks directly as binary classifiers of strings, using a general method that can be applied to a wide variety of languages. As part of this, we extend an algorithm recently proposed by Snaebjarnarson et al. (2025) for efficient length-controlled sampling of strings from regular languages. We provide results on a variety of languages across the Chomsky hierarchy for three neural architectures: a simple RNN, an LSTM, and a causally-masked transformer. We find that the RNN and LSTM often outperform the transformer, and that auxiliary training objectives such as language modeling can help, although no single objective uniformly improves performance across languages and architectures. Our contributions will facilitate theoretically sound empirical testing of language recognition claims in future work. We have released our datasets as a benchmark called FLaRe 1 (Formal Language Recognition), along with our code. 2
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
15 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Characterizing the Expressivity of Fixed-Precision Transformer Language Models cites Neural Networks and the Chomsky Hierarchy
- Discovering Interpretable Algorithms by Decompiling Transformers to RASP cites Characterizing the Expressivity of Fixed-Precision Transformer Language Models
- Separations in the Representational Capabilities of Transformers and Recurrent Architectures cites Repeat After Me: Transformers are Better than State Space Models at Copying
- Separations in the Representational Capabilities of Transformers and Recurrent Architectures cites Neural Networks and the Chomsky Hierarchy
- Repeat After Me: Transformers are Better than State Space Models at Copying cites Inductive Biases and Variable Creation in Self-Attention Mechanisms
- Repeat After Me: Transformers are Better than State Space Models at Copying cites Neural Networks and the Chomsky Hierarchy
- Revisiting Padded Transformer Expressivity: Which Architectural Choices Matter and Which Don't cites Characterizing the Expressivity of Fixed-Precision Transformer Language Models
- Revisiting Padded Transformer Expressivity: Which Architectural Choices Matter and Which Don't cites On the Reasoning Abilities of Masked Diffusion Language Models
- Revisiting Padded Transformer Expressivity: Which Architectural Choices Matter and Which Don't cites Neural Networks and the Chomsky Hierarchy
Cited by top-tier papers15
- Characterizing the Expressivity of Fixed-Precision Transformer Language ModelsJiaoda Li, Ryan CotterellNeurIPS 2025 · 18 citations
- On the Reasoning Abilities of Masked Diffusion Language ModelsAnej Svete, Ashish SabharwalICLR 2026 · 8 citations
- Information Locality as an Inductive Bias for Neural Language ModelsTaiga Someya, Anej Svete, Brian DuSell, Timothy J. O'Donnell et al.ACL 2025 · 6 citations
- Discovering Interpretable Algorithms by Decompiling Transformers to RASPXinting Huang, Aleksandra Bakalova, Satwik Bhattamishra, William Merrill et al.ICML 2026 · 3 citations
- Revisiting Padded Transformer Expressivity: Which Architectural Choices Matter and Which Don'tAnej Svete, William Merrill, Ryan Cotterell, Ashish SabharwalICML 2026 · 3 citations
Builds on18
- Repeat After Me: Transformers are Better than State Space Models at CopyingSamy Jelassi, David Brandfonbrener, Sham M. Kakade, Eran MalachICML 2024 · 176 citations
- Inductive Biases and Variable Creation in Self-Attention MechanismsBenjamin L. Edelman, Surbhi Goel, Sham M. Kakade, Cyril ZhangICML 2022 · 154 citations
- In-Context Language Learning: Architectures and AlgorithmsEkin Akyürek, Bailin Wang, Yoon Kim, Jacob AndreasICML 2024 · 91 citations
- Neural Networks and the Chomsky HierarchyGrégoire Delétang, Anian Ruoss, Jordi Grau-Moya, Tim Genewein et al.ICLR 2023 · 45 citations
- Separations in the Representational Capabilities of Transformers and Recurrent ArchitecturesSatwik Bhattamishra, Michael Hahn, Phil Blunsom, Varun KanadeNeurIPS 2024 · 36 citations
Related papers
- Bridging the Empirical-Theoretical Gap in Neural Network Formal Language Learning Using Minimum Description LengthNur Geffen Lan, Emmanuel Chemla, Roni KatzirACL 2024 · 1 citation
- Transparency at the Source: Evaluating and Interpreting Language Models With Access to the True DistributionJaap Jumelet, Willem H. ZuidemaEMNLP Findings 2023
- What Languages are Easy to Language-Model? A Perspective from Learning Probabilistic Regular LanguagesNadav Borenstein, Anej Svete, Robin Chan, Josef Valvoda et al.ACL 2024
- Tighter Bounds on the Expressivity of Transformer EncodersDavid Chiang, Peter Cholak, Anand PillayICML 2023 · 80 citations
- An Algebraic View of the Expressivity of Recurrent Language ModelsFranz Nowak, Ryan Cotterell, Reda BoumasmoudICML 2026 · 1 citation
