Transformers on Markov Data: Constant Depth Suffices
Not on the map. Why?
Abstract (arXiv)
Attention-based transformers have been remarkably successful at modeling generative processes across various domains and modalities. In this paper, we study the behavior of transformers on data drawn from kth Markov processes, where the conditional distribution of the next symbol in a sequence depends on the previous k symbols observed. We observe a surprising phenomenon empirically which contradicts previous findings: when trained for sufficiently long, a transformer with a fixed depth and 1 head per layer is able to achieve low test loss on sequences drawn from kth Markov sources, even as k grows. Furthermore, this low test loss is achieved by the transformer's ability to represent and learn the in-context conditional empirical distribution. On the theoretical side, our main result is that a transformer with a single head and three layers can represent the in-context conditional empirical distribution for kth Markov sources, concurring with our empirical observations. Along the way, we prove that textitattention-only transformers with O(log2(k)) layers can represent the in-context conditional empirical distribution by composing induction heads to track the previous k symbols in the sequence. These results provide more insight into our current understanding of the mechanisms by which transformers learn to capture context, by understanding their behavior on Markov sources.
Key facts. Cited by 26 papers in the map (data through 7 Oct 2026). Builds on 20 of its 29 references that are in the map. First posted on arXiv 25 Jul 2024.
Builds on
20 of 29 references.
References · 20
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Masked Autoencoders Are Scalable Vision Learnerscited by 7,339
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
- 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
- 2023Looped Transformers as Programmable Computerscited by 224
- 2021Thinking Like Transformerscited by 182
- 2023Localizing Model Behavior with Path Patchingcited by 182
- 2023Birth of a Transformer: A Memory Viewpointcited by 154
8 more
- 2023Representational Strengths and Limitations of Transformerscited by 132
- 2024The Evolution of Statistical Induction Heads: In-Context Learning Markov Chainscited by 115
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 114
- 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 101
- 2023A Theoretical Understanding of Shallow Vision Transformers: Learning, Generalization, and Sample Complexitycited by 77
- 2023On the Role of Attention in Prompt-tuningcited by 49
- 2024Attention with Markov: A Framework for Principled Analysis of Transformers via Markov Chainscited by 39
- 2024Toward a Theory of Tokenization in LLMscited by 28
Built on by
Citing papers per year: 2024: 4; 2025: 15; 2026: 7.
26 papers.
Sort:
By area:
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Pointscited by 15
- 2025From Markov to Laplace: How Mamba In-Context Learns Markov Chainscited by 9
- 2024Transformers Handle Endogeneity in In-Context Linear Regressioncited by 8
- 2024How Transformers Get Rich: Approximation and Dynamics Analysiscited by 7
- 2024KV Shifting Attention Enhances Language Modelingcited by 7
- 2025Selective Induction Heads: How Transformers Select Causal Structures In Contextcited by 7
- 2025Pre-trained Large Language Models Learn Hidden Markov Models In-contextcited by 4
- 2025In-Context Occam's Razor: How Transformers Prefer Simpler Hypotheses on the Flycited by 4
- 2025Provable In-Context Learning of Nonlinear Regression with Transformerscited by 4
- 2025Latent Concept Disentanglement in Transformer-based Language Modelscited by 3
- 2025Facts in Stats: Impacts of Pretraining Diversity on Language Model Generalizationcited by 3
- 2024An Information-Theoretic Approach to Understanding Transformers' In-Context Learning of Variable-Order Markov Chainscited by 2
14 more
- 2025Benchmarking graph construction by large language models for coherence-driven inferencecited by 2
- 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Informationcited by 2
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledgecited by 2
- 2025In-Context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-Separationcited by 1
- 2026Hierarchical Latent Structures in Data Generation Process Unify Mechanistic Phenomena across Scalecited by 1
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descentcited by 1
- 2026Effective Context in Transformers: An Analysis of Fragmentation and Tokenizationcited by 1
- 2025Decomposing Prediction Mechanisms for In-Context Recallcited by 0
- 2025Coherence-driven inference for cybersecuritycited by 0
- 2025Performance-Efficiency Tradeoffs in Transformers: An Approximation Theory Perspectivecited by 0
- 2025Optimality and NP-Hardness of Transformers in Learning Markovian Dynamical Functionscited by 0
- 2026Gaussian Match-and-Copy: A Minimalist Benchmark for Studying Transformer Inductioncited by 0
- 2026Position: Let's Develop Data Probes to Fundamentally Understand How Data Affects LLM Performancecited by 0
- 2026Induction Heads Interpolate N-Gramscited by 0
- 2026Induction Heads Interpolate N-Grams2 Jul 2026
- 2026Effective Context in Transformers: An Analysis of Fragmentation and Tokenization13 May 2026
- 2026Position: Let's Develop Data Probes to Fundamentally Understand How Data Affects LLM Performance11 May 2026
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descent12 Apr 2026
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledge21 Mar 2026
- 2026Gaussian Match-and-Copy: A Minimalist Benchmark for Studying Transformer Induction7 Feb 2026
- 2026Hierarchical Latent Structures in Data Generation Process Unify Mechanistic Phenomena across Scale4 Feb 2026
- 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Information29 Oct 2025
- 2025Optimality and NP-Hardness of Transformers in Learning Markovian Dynamical Functions21 Oct 2025
- 2025Facts in Stats: Impacts of Pretraining Diversity on Language Model Generalization17 Oct 2025
- 2025Performance-Efficiency Tradeoffs in Transformers: An Approximation Theory Perspective4 Oct 2025
- 2025Coherence-driven inference for cybersecurity23 Sep 2025
14 more
- 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
- 2025Provable In-Context Learning of Nonlinear Regression with Transformers28 Jul 2025
- 2025Decomposing Prediction Mechanisms for In-Context Recall2 Jul 2025
- 2025In-Context Occam's Razor: How Transformers Prefer Simpler Hypotheses on the Fly24 Jun 2025
- 2025Latent Concept Disentanglement in Transformer-based Language Models20 Jun 2025
- 2025Pre-trained Large Language Models Learn Hidden Markov Models In-context8 Jun 2025
- 2025Benchmarking graph construction by large language models for coherence-driven inference19 Feb 2025
- 2025From Markov to Laplace: How Mamba In-Context Learns Markov Chains14 Feb 2025
- 2025In-Context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-Separation12 Feb 2025
- 2024KV Shifting Attention Enhances Language Modeling29 Nov 2024
- 2024How Transformers Get Rich: Approximation and Dynamics Analysis15 Oct 2024
- 2024An Information-Theoretic Approach to Understanding Transformers' In-Context Learning of Variable-Order Markov Chains7 Oct 2024
- 2024Transformers Handle Endogeneity in In-Context Linear Regression2 Oct 2024
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Pointscited by 15
- 2024Transformers Handle Endogeneity in In-Context Linear Regressioncited by 8
- 2024How Transformers Get Rich: Approximation and Dynamics Analysiscited by 7
- 2024KV Shifting Attention Enhances Language Modelingcited by 7
- 2025Selective Induction Heads: How Transformers Select Causal Structures In Contextcited by 7
- 2025Pre-trained Large Language Models Learn Hidden Markov Models In-contextcited by 4
- 2025In-Context Occam's Razor: How Transformers Prefer Simpler Hypotheses on the Flycited by 4
- 2025Provable In-Context Learning of Nonlinear Regression with Transformerscited by 4
- 2025Latent Concept Disentanglement in Transformer-based Language Modelscited by 3
- 2025Facts in Stats: Impacts of Pretraining Diversity on Language Model Generalizationcited by 3
- 2024An Information-Theoretic Approach to Understanding Transformers' In-Context Learning of Variable-Order Markov Chainscited by 2
- 2025Benchmarking graph construction by large language models for coherence-driven inferencecited by 2
12 most cited of 24 All 24 (JSON)
- 2026Induction Heads Interpolate N-Grams2 Jul 2026
- 2026Effective Context in Transformers: An Analysis of Fragmentation and Tokenization13 May 2026
- 2026Position: Let's Develop Data Probes to Fundamentally Understand How Data Affects LLM Performance11 May 2026
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descent12 Apr 2026
- 2026Gaussian Match-and-Copy: A Minimalist Benchmark for Studying Transformer Induction7 Feb 2026
- 2026Hierarchical Latent Structures in Data Generation Process Unify Mechanistic Phenomena across Scale4 Feb 2026
- 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Information29 Oct 2025
- 2025Optimality and NP-Hardness of Transformers in Learning Markovian Dynamical Functions21 Oct 2025
- 2025Facts in Stats: Impacts of Pretraining Diversity on Language Model Generalization17 Oct 2025
- 2025Performance-Efficiency Tradeoffs in Transformers: An Approximation Theory Perspective4 Oct 2025
- 2025Coherence-driven inference for cybersecurity23 Sep 2025
- 2025Selective Induction Heads: How Transformers Select Causal Structures In Context9 Sep 2025
12 newest of 24 All 24 (JSON)