mlsanityData to 7 Oct 2026

On Limitation of Transformer for Learning HMMs

arXiv 2406.04089 ↗First posted 6 Jun 2024cs.LG cs.AIcited by 9

Not on the map. Why?

Abstract (arXiv)

Despite the remarkable success of Transformer-based architectures in various sequential modeling tasks, such as natural language processing, computer vision, and robotics, their ability to learn basic sequential models, like Hidden Markov Models (HMMs), is still unclear. This paper investigates the performance of Transformers in learning HMMs and their variants through extensive experimentation and compares them to Recurrent Neural Networks (RNNs). We show that Transformers consistently underperform RNNs in both training speed and testing accuracy across all tested HMM models. There are even challenging HMM instances where Transformers struggle to learn, while RNNs can successfully do so. Our experiments further reveal the relation between the depth of Transformers and the longest sequence length it can effectively learn, based on the types and the complexity of HMMs. To address the limitation of transformers in modeling HMMs, we demonstrate that a variant of the Chain-of-Thought (CoT), called textitblock CoT in the training phase, can help transformers to reduce the evaluation error and to learn longer sequences at a cost of increasing the training time. Finally, we complement our empirical findings by theoretical results proving the expressiveness of transformers in approximating HMMs with logarithmic depth.

Key facts. Cited by 9 papers in the map (data through 7 Oct 2026). Builds on 32 of its 49 references that are in the map. First posted on arXiv 6 Jun 2024.

Builds on

32 of 49 references.

References · 32

  1. 2017Attention Is All You Needcited by 59,932
  2. 2015Deep Residual Learning for Image Recognitioncited by 51,809
  3. 2020Language Models are Few-Shot Learnerscited by 32,199
  4. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
  5. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
  6. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  7. 2016Gaussian Error Linear Units (GELUs)cited by 3,431
  8. 2023RT-2: Vision-Language-Action Models Transfer Web Knowledge to Robotic Controlcited by 2,993
  9. 2022LaMDA: Language Models for Dialog Applicationscited by 1,218
  10. 2020On Layer Normalization in the Transformer Architecturecited by 906
  11. 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
  12. 2023Progress measures for grokking via mechanistic interpretabilitycited by 822
20 more
  1. 2022Transformers learn in-context by gradient descentcited by 714
  2. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  3. 2021Offline Reinforcement Learning as One Big Sequence Modeling Problemcited by 636
  4. 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 496
  5. 2020Monotonic Value Function Factorisation for Deep Multi-Agent Reinforcement Learningcited by 475
  6. 2015Deep Recurrent Q-Learning for Partially Observable MDPscited by 457
  7. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
  8. 2019Learning Deep Transformer Models for Machine Translationcited by 309
  9. 2023Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspectivecited by 293
  10. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
  11. 2022Transformers Learn Shortcuts to Automatacited by 260
  12. 2018Adaptive Input Representations for Neural Language Modelingcited by 226
  13. 2022Neural Networks and the Chomsky Hierarchycited by 214
  14. 2022Multi-Game Decision Transformerscited by 212
  15. 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
  16. 2019On the Turing Completeness of Modern Neural Network Architecturescited by 129
  17. 2018Deep Reinforcement Learning for Multi-Agent Systems: A Review of Challenges, Solutions and Applicationscited by 122
  18. 2023Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete Functionscited by 62
  19. 2022Planning in Observable POMDPs in Quasipolynomial Timecited by 25
  20. 2020Scaling Hidden Markov Language Modelscited by 22

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 2; 2025: 4; 2026: 3.

9 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025How Transformers Learn Regular Language Recognition: A Theoretical Study on Training Dynamics and Implicit Bias
  2. 2025Speed Always Wins: A Survey on Efficient Architectures for Large Language Models
  3. 2026Transformer-Based Language Models Across Domain Verticals: Architectures, Applications and Critical Assessment
  4. 2026Adaptive Loops and Memory in Transformers: Think Harder or Know More?
  5. 2025Pimba: A Processing-in-Memory Acceleration for Post-Transformer Large Language Model Serving
  6. 2024State-Space Modeling in Long Sequence Processing: A Survey on Recurrence in the Transformer Era
  7. 2024Does Transformer Interpretability Transfer to RNNs?
  8. 2025Is Random Attention Sufficient for Sequence Modeling? Disentangling Trainable Components in the Transformer