mlsanityData to 7 Oct 2026

What Can Transformer Learn with Varying Depth? Case Studies on Sequence Learning Tasks

arXiv 2404.01601 ↗First posted 2 Apr 2024cs.LGcited by 19

Not on the map. Why?

Abstract (arXiv)

We study the capabilities of the transformer architecture with varying depth. Specifically, we designed a novel set of sequence learning tasks to systematically evaluate and comprehend how the depth of transformer affects its ability to perform memorization, reasoning, generalization, and contextual generalization. We show a transformer with only one attention layer can excel in memorization but falls short in other tasks. Then, we show that exhibiting reasoning and generalization ability requires the transformer to have at least two attention layers, while context generalization ability may necessitate three attention layers. Additionally, we identify a class of simple operations that a single attention layer can execute, and show that the complex tasks can be approached as the combinations of these simple operations and thus can be resolved by stacking multiple attention layers. This sheds light on studying more practical and complex tasks beyond our design. Numerical experiments corroborate our theoretical findings.

Key facts. Cited by 19 papers in the map (data through 7 Oct 2026). Builds on 36 of its 41 references that are in the map. First posted on arXiv 2 Apr 2024.

Builds on

36 of 41 references.

References · 36

  1. 2017Attention Is All You Needcited by 59,932
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  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. 2022Training language models to follow instructions with human feedbackcited by 15,712
  6. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  7. 2020Scaling Laws for Neural Language Modelscited by 6,411
  8. 2021On the Opportunities and Risks of Foundation Modelscited by 3,961
  9. 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
  10. 2022Emergent Abilities of Large Language Modelscited by 2,483
  11. 2016Understanding deep learning requires rethinking generalizationcited by 1,657
  12. 2021Decision Transformer: Reinforcement Learning via Sequence Modelingcited by 1,528
24 more
  1. 2016Optimization Methods for Large-Scale Machine Learningcited by 1,140
  2. 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 994
  3. 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
  4. 2022Galactica: A Large Language Model for Sciencecited by 736
  5. 2022Transformers learn in-context by gradient descentcited by 714
  6. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  7. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
  8. 2023Trained Transformers Learn Linear Models In-Contextcited by 331
  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. 2024Chain of Thought Empowers Transformers to Solve Inherently Serial Problemscited by 256
  13. 2023Looped Transformers as Programmable Computerscited by 224
  14. 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
  15. 2021Thinking Like Transformerscited by 182
  16. 2023Tracr: Compiled Transformers as a Laboratory for Interpretabilitycited by 99
  17. 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 72
  18. 2023Are Transformers with One Layer Self-Attention Using Low-Rank Weight Matrices Universal Approximators?cited by 46
  19. 2023Learning Transformer Programscited by 40
  20. 2023Memorization Capacity of Multi-Head Attention in Transformerscited by 39
  21. 2023What can a Single Attention Layer Learn? A Study Through the Random Features Lenscited by 39
  22. 2023Approximation and Estimation Ability of Transformers for Sequence-to-Sequence Functions with Infinite Dimensional Inputcited by 32
  23. 2023When can transformers reason with abstract symbols?cited by 23
  24. 2022Adapting Self-Supervised Vision Transformers by Probing Attention-Conditioned Masking Consistencycited by 11

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 7; 2025: 9; 2026: 3.

19 papers.

Sort:

By area:

  1. 2025Reasoning with Latent Thoughts: On the Power of Looped Transformerscited by 223
  2. 2026LoopFormer: Elastic-Depth Looped Transformers for Latent Reasoning via Shortcut Modulationcited by 48
  3. 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 36
  4. 2024Out-of-distribution generalization via composition: a lens through induction heads in Transformerscited by 28
  5. 2025Encode, Think, Decode: Scaling test-time reasoning with recursive latent thoughtscited by 23
  6. 2024Mixture of Parrots: Experts improve memorization more than reasoningcited by 20
  7. 2025Towards Understanding Fine-Tuning Mechanisms of LLMs via Circuit Analysiscited by 20
  8. 2024Understanding the Language Model to Solve the Symbolic Multi-Step Reasoning Problem from the Perspective of Buffer Mechanismcited by 15
  9. 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regressioncited by 13
  10. 2024On the Optimal Memorization Capacity of Transformerscited by 10
  11. 2024How Transformers Get Rich: Approximation and Dynamics Analysiscited by 7
  12. 2025Transformers Can Overcome the Curse of Dimensionality: A Theoretical Study from an Approximation Perspectivecited by 5
7 more
  1. 2025On the Robustness of Transformers against Context Hijacking for Linear Classificationcited by 4
  2. 2026Sparse Growing Transformer: Training-Time Sparse Depth Allocation via Progressive Attention Loopingcited by 3
  3. 2025Towards Theoretical Understanding of Transformer Test-Time Computing: Investigation on In-Context Linear Regressioncited by 1
  4. 2025Dynamic Reasoning Chains through Depth-Specialized Mixture-of-Experts in Transformer Architecturescited by 1
  5. 2025Limit Analysis for Symbolic Multi-step Reasoning Tasks with Information Propagation Rules Based on Transformerscited by 0
  6. 2025Performance-Efficiency Tradeoffs in Transformers: An Approximation Theory Perspectivecited by 0
  7. 2026Distributed Multi-Layer Editing for Rule-Level Knowledge in Large Language Modelscited by 0