Unraveling Syntax: How Language Models Learn Context-Free Grammars
Laura Ying Schulz, Daniel Mitropolsky, Tomaso Poggio
ICLR 2026 submission
Abstract. We introduce a new approach to understanding how language models acquire syntax. While large models achieve impressive results, little is known about their learning dynamics. Our approach starts with the observation that most domains of interest -- such as natural language syntax, coding languages, arithmetic problems -- are captured by context-free grammars (CFGs). In this work we initiate the study of how language modeling for CFGs behaves with respect to the substructure of CFGs, namely the notion of a ``subgrammar". We define subgrammars, and prove a suite of fundamental results showing that the loss of language modeling obeys recurrences with respect to subgrammars. We show empirically that small transformers learn subgrammars in parallel, unlike children-- who first master simple substructures before progressing to more complex constructions. We further explore whether curriculum learning using an inductive bias, by pretraining on a subgrammar, can improve performance, and use alignment analysis to show definitively that such pre-training results in internal representations that are more aligned with the grammar's substructure. Finally we demonstrate that models struggle with deeper recursive structures (a limitation even of large language models), revealing fundamental challenges in how neural networks represent hierarchical syntax.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperadd · history
Loading the discussion…