Transformers Can Represent n-gram Language Models
Not on the map. Why?
Abstract (arXiv)
Existing work has analyzed the representational capacity of the transformer architecture by means of formal models of computation. However, the focus so far has been on analyzing the architecture in terms of language acceptance. We contend that this is an ill-suited problem in the study of language models (LMs), which are definitionally probability distributions over strings. In this paper, we focus on the relationship between transformer LMs and n-gram LMs, a simple and historically relevant class of language models. We show that transformer LMs using the hard or sparse attention mechanisms can exactly represent any n-gram LM, giving us a concrete lower bound on their probabilistic representational capacity. This provides a first step towards understanding the mechanisms that transformer LMs can use to represent probability distributions over strings.
Key facts. Cited by 31 papers in the map (data through 7 Oct 2026). Builds on 22 of its 50 references that are in the map. First posted on arXiv 23 Apr 2024.
Builds on
22 of 50 references.
References · 22
- 2017Attention Is All You Needcited by 59,932
- 2022In-context Learning and Induction Headscited by 930
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
- 2016From Softmax to Sparsemax: A Sparse Model of Attention and Multi-Label Classificationcited by 337
- 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 286
- 2022The Parallelism Tradeoff: Limitations of Log-Precision Transformerscited by 191
- 2021Thinking Like Transformerscited by 182
- 2017Breaking the Softmax Bottleneck: A High-Rank RNN Language Modelcited by 147
- 2021Saturated Transformers are Constant-Depth Threshold Circuitscited by 137
- 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 110
- 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
- 2022Formal Language Recognition by Hard Attention Transformers: Perspectives from Circuit Complexitycited by 92
10 more
- 2022A Logic for Expressing Log-Precision Transformerscited by 67
- 2023Tighter Bounds on the Expressivity of Transformer Encoderscited by 65
- 2020A Formal Hierarchy of RNN Architecturescited by 61
- 2020RNNs can generate bounded hierarchical languages with optimal memorycited by 59
- 2019Sequential Neural Networks as Automatacited by 54
- 2022A Measure-Theoretic Characterization of Tight Language Modelscited by 32
- 2023Transformers are uninterpretable with myopic methods: a case study with bounded Dyck grammarscited by 30
- 2022Extracting Finite Automata from RNNs Using State Mergingcited by 17
- 2018Context-Free Transductions with Neural Stackscited by 14
- 2017Subregular Complexity and Deep Learningcited by 5
Built on by
Citing papers per year: 2024: 10; 2025: 13; 2026: 8.
31 papers.
Sort:
By area:
- 2024On the Representational Capacity of Neural Language Models with Chain-of-Thought Reasoningcited by 26
- 2024Understanding Transformers via N-gram Statisticscited by 23
- 2024What Languages are Easy to Language-Model? A Perspective from Learning Probabilistic Regular Languagescited by 20
- 2025Learning curves theory for hierarchically compositional data with power-law distributed featurescited by 17
- 2024Simulating Hard Attention Using Soft Attentioncited by 15
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Pointscited by 15
- 2025Characterizing the Expressivity of Fixed-Precision Transformer Language Modelscited by 14
- 2024Beyond Scaling Laws: Understanding Transformer Performance with Associative Memorycited by 12
- 2024Can Transformers Learn n-gram Language Models?cited by 11
- 2025Unique Hard Attention: A Tale of Two Sidescited by 10
- 2025Evolution of Concepts in Language Model Pre-Trainingcited by 8
- 2025Selective Induction Heads: How Transformers Select Causal Structures In Contextcited by 7
19 more
- 2025Bigram Subnetworks: Mapping to Next Tokens in Transformer Language Modelscited by 5
- 2025Scaling Laws and Representation Learning in Simple Hierarchical Languages: Transformers vs. Convolutional Architecturescited by 5
- 2024Jet Expansions of Residual Computationcited by 4
- 2024Neural Networks Generalize on Low Complexity Datacited by 3
- 2025Language Models, Graph Searching, and Supervision Adulteration: When More Supervision is Less and How to Make More Morecited by 3
- 2024A Transformer with Stack Attentioncited by 2
- 2025Probability Distributions Computed by Autoregressive Transformerscited by 2
- 2024Representing Rule-based Chatbots with Transformerscited by 1
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learningcited by 1
- 2025From n-gram to Attention: How Model Architectures Learn and Propagate Bias in Language Modelingcited by 1
- 2025Towards Understanding Transformers in Learning Random Walkscited by 1
- 2026PixRec: Leveraging Visual Context for Next-Item Prediction in Sequential Recommendationcited by 1
- 2026Incremental Learning of Sparse Attention Patterns in Transformerscited by 1
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descentcited by 1
- 2026An expressivity analysis of hierarchical modelling in deep transformers via bounded-depth grammarscited by 1
- 2026Space-Efficient Language Generation in the Limitcited by 1
- 2026A theoretical model for task routing in mixture-of-expert transformerscited by 0
- 2026Induction Heads Interpolate N-Gramscited by 0
- 2026Disentangling the Expressivity of RoPEcited by 0
- 2026Disentangling the Expressivity of RoPE12 Aug 2026
- 2026Induction Heads Interpolate N-Grams2 Jul 2026
- 2026Space-Efficient Language Generation in the Limit24 Jun 2026
- 2026An expressivity analysis of hierarchical modelling in deep transformers via bounded-depth grammars16 Jun 2026
- 2026A theoretical model for task routing in mixture-of-expert transformers12 Jun 2026
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descent12 Apr 2026
- 2026Incremental Learning of Sparse Attention Patterns in Transformers22 Feb 2026
- 2026PixRec: Leveraging Visual Context for Next-Item Prediction in Sequential Recommendation10 Jan 2026
- 2025Towards Understanding Transformers in Learning Random Walks28 Nov 2025
- 2025Probability Distributions Computed by Autoregressive Transformers31 Oct 2025
- 2025Evolution of Concepts in Language Model Pre-Training21 Sep 2025
- 2025Selective Induction Heads: How Transformers Select Causal Structures In Context9 Sep 2025
19 more
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Points18 Aug 2025
- 2025Characterizing the Expressivity of Fixed-Precision Transformer Language Models29 May 2025
- 2025From n-gram to Attention: How Model Architectures Learn and Propagate Bias in Language Modeling18 May 2025
- 2025Scaling Laws and Representation Learning in Simple Hierarchical Languages: Transformers vs. Convolutional Architectures11 May 2025
- 2025Learning curves theory for hierarchically compositional data with power-law distributed features11 May 2025
- 2025Bigram Subnetworks: Mapping to Next Tokens in Transformer Language Models21 Apr 2025
- 2025Unique Hard Attention: A Tale of Two Sides18 Mar 2025
- 2025Language Models, Graph Searching, and Supervision Adulteration: When More Supervision is Less and How to Make More More13 Mar 2025
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learning6 Jan 2025
- 2024Simulating Hard Attention Using Soft Attention13 Dec 2024
- 2024Jet Expansions of Residual Computation8 Oct 2024
- 2024Can Transformers Learn n-gram Language Models?3 Oct 2024
- 2024Neural Networks Generalize on Low Complexity Data19 Sep 2024
- 2024Representing Rule-based Chatbots with Transformers15 Jul 2024
- 2024Understanding Transformers via N-gram Statistics30 Jun 2024
- 2024On the Representational Capacity of Neural Language Models with Chain-of-Thought Reasoning20 Jun 2024
- 2024What Languages are Easy to Language-Model? A Perspective from Learning Probabilistic Regular Languages6 Jun 2024
- 2024Beyond Scaling Laws: Understanding Transformer Performance with Associative Memory14 May 2024
- 2024A Transformer with Stack Attention7 May 2024
- 2024Understanding Transformers via N-gram Statisticscited by 23
- 2024What Languages are Easy to Language-Model? A Perspective from Learning Probabilistic Regular Languagescited by 20
- 2025Learning curves theory for hierarchically compositional data with power-law distributed featurescited by 17
- 2024Simulating Hard Attention Using Soft Attentioncited by 15
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Pointscited by 15
- 2025Characterizing the Expressivity of Fixed-Precision Transformer Language Modelscited by 14
- 2024Beyond Scaling Laws: Understanding Transformer Performance with Associative Memorycited by 12
- 2024Can Transformers Learn n-gram Language Models?cited by 11
- 2025Unique Hard Attention: A Tale of Two Sidescited by 10
- 2025Evolution of Concepts in Language Model Pre-Trainingcited by 8
- 2025Selective Induction Heads: How Transformers Select Causal Structures In Contextcited by 7
- 2025Bigram Subnetworks: Mapping to Next Tokens in Transformer Language Modelscited by 5
12 most cited of 28 All 28 (JSON)
- 2026Disentangling the Expressivity of RoPE12 Aug 2026
- 2026Induction Heads Interpolate N-Grams2 Jul 2026
- 2026Space-Efficient Language Generation in the Limit24 Jun 2026
- 2026An expressivity analysis of hierarchical modelling in deep transformers via bounded-depth grammars16 Jun 2026
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descent12 Apr 2026
- 2026Incremental Learning of Sparse Attention Patterns in Transformers22 Feb 2026
- 2026PixRec: Leveraging Visual Context for Next-Item Prediction in Sequential Recommendation10 Jan 2026
- 2025Towards Understanding Transformers in Learning Random Walks28 Nov 2025
- 2025Probability Distributions Computed by Autoregressive Transformers31 Oct 2025
- 2025Evolution of Concepts in Language Model Pre-Training21 Sep 2025
- 2025Selective Induction Heads: How Transformers Select Causal Structures In Context9 Sep 2025
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Points18 Aug 2025
12 newest of 28 All 28 (JSON)