cs.CLNov 22, 2026

Grammar Sparsity Sets How Transformers Learn Random Languages

Authors: Edgar Andres Hernandez Moreno, Francesco Cagnetta

Organizations: Universitat de Barcelona · Simplex

Abstract

We study language acquisition by transformers trained on the Random Language Model: a synthetic hierarchical grammar with random production rules, whose sparsity is controlled by a single parameter and whose conditional entropies are known exactly. On depth-two grammars, we find that sparsity sets both the order and the speed of learning. Dense grammars are learnt one level at a time: a token is predicted from its sibling after t∝Vt\propto V steps and from the full context only after t∝V3t\propto V^{3}, so the two stages are separated by a plateau that widens with VV. Sparse grammars are learnt all at once, at t∝Vt\propto\sqrt V, with a smaller exponent than even the first stage of a dense one. The exponents 11 and 1/21/2 already appear at depth one, where we derive them for a linear model trained with Adam.

Figures & tables

Appendix figures & tables8 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Stagewise and interpretable emergence of inside-outside computation in Transformer-based language models

    Nov 10, 2026Jack T. ParleyTransformer Training DynamicsTransformer Interpretability

  2. Learning to Learn a Language

    Oct 5, 2026Lennart Carstens-Behrens, Holger FröhlichLanguage Model PretrainingMeta-Learning