Unveiling Transformers with LEGO: a synthetic reasoning task
Not on the map. Why?
Abstract (arXiv)
We propose a synthetic reasoning task, LEGO (Learning Equality and Group Operations), that encapsulates the problem of following a chain of reasoning, and we study how the Transformer architectures learn this task. We pay special attention to data effects such as pretraining (on seemingly unrelated NLP tasks) and dataset composition (e.g., differing chain length at training and test time), as well as architectural variants such as weight-tied layers or adding convolutional components. We study how the trained models eventually succeed at the task, and in particular, we manage to understand some of the attention heads as well as how the information flows in the network. In particular, we have identified a novel association pattern that globally attends only to identical tokens. Based on these observations we propose a hypothesis that here pretraining helps for LEGO tasks due to certain structured attention patterns, and we experimentally verify this hypothesis. We also observe that in some data regime the trained transformer finds ``shortcut" solutions to follow the chain of reasoning, which impedes the model's robustness, and moreover we propose ways to prevent it. Motivated by our findings on structured attention patterns, we propose the LEGO attention module, a drop-in replacement for vanilla attention heads. This architectural change significantly reduces Flops and maintains or even improves the model's performance at large-scale pretraining.
Key facts. Cited by 105 papers in the map (data through 7 Oct 2026). Builds on 48 of its 67 references that are in the map. First posted on arXiv 9 Jun 2022.
Builds on
48 of 67 references.
References · 48
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,084
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,082
- 2022Hierarchical Text-Conditional Image Generation with CLIP Latentscited by 6,539
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
- 2021Measuring Mathematical Problem Solving With the MATH Datasetcited by 5,203
- 2016SQuAD: 100,000+ Questions for Machine Comprehension of Textcited by 4,115
- 2022A ConvNet for the 2020scited by 3,545
36 more
- 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,464
- 2022Training Compute-Optimal Large Language Modelscited by 2,927
- 2019ALBERT: A Lite BERT for Self-supervised Learning of Language Representationscited by 2,772
- 2016Xception: Deep Learning with Depthwise Separable Convolutionscited by 2,320
- 2021Decision Transformer: Reinforcement Learning via Sequence Modelingcited by 1,528
- 2022LaMDA: Language Models for Dialog Applicationscited by 1,218
- 2021Scaling Language Models: Methods, Analysis & Insights from Training Gophercited by 1,199
- 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 994
- 2016Deep Networks with Stochastic Depthcited by 973
- 2021GLaM: Efficient Scaling of Language Models with Mixture-of-Expertscited by 890
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
- 2019Right for the Wrong Reasons: Diagnosing Syntactic Heuristics in Natural Language Inferencecited by 864
- 2019Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Prunedcited by 844
- 2020A Primer in BERTology: What we know about how BERT workscited by 807
- 2022A Generalist Agentcited by 802
- 2018Annotation Artifacts in Natural Language Inference Datacited by 656
- 2021CoAtNet: Marrying Convolution and Attention for All Data Sizescited by 566
- 2022Using DeepSpeed and Megatron to Train Megatron-Turing NLG 530B, A Large-Scale Generative Language Modelcited by 557
- 2019On the Relationship between Self-Attention and Convolutional Layerscited by 299
- 2019Measuring Compositional Generalization: A Comprehensive Method on Realistic Datacited by 280
- 2019Compositionality decomposed: how do neural networks generalise?cited by 264
- 2019Adaptively Sparse Transformerscited by 154
- 2022Formal Mathematics Statement Curriculum Learningcited by 141
- 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
- 2020ConvBERT: Improving BERT with Span-based Dynamic Convolutioncited by 88
- 2020Bongard-LOGO: A New Benchmark for Human-Level Concept Learning and Reasoningcited by 63
- 2020Robustness to Spurious Correlations via Human Annotationscited by 62
- 2021The Neural Data Router: Adaptive Control Flow in Transformers Improves Systematic Generalizationcited by 62
- 2020PRover: Proof Generation for Interpretable Reasoning over Rulescited by 53
- 2021LIME: Learning Inductive Bias for Primitives of Mathematical Reasoningcited by 46
- 2020Fixed Encoder Self-Attention Patterns in Transformer-Based Machine Translationcited by 42
- 2020Hard-Coded Gaussian Attention for Neural Machine Translationcited by 42
- 2021Latent Execution for Neural Program Synthesiscited by 35
- 2021Pointer Value Retrieval: A new benchmark for understanding the limits of neural network generalizationcited by 29
- 2022Revisiting the Compositional Generalization Abilities of Neural Sequence Modelscited by 20
- 2021Analyzing the Nuances of Transformers' Polynomial Simplification Abilitiescited by 9
Built on by
Citing papers per year: 2022: 13; 2023: 32; 2024: 37; 2025: 15; 2026: 8.
105 papers.
Sort:
By area:
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,579
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 496
- 2023Hyena Hierarchy: Towards Larger Convolutional Language Modelscited by 388
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 319
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
- 2022Transformers Learn Shortcuts to Automatacited by 260
- 2022Neural Networks and the Chomsky Hierarchycited by 214
- 2022Exploring Length Generalization in Large Language Modelscited by 204
- 2023Birth of a Transformer: A Memory Viewpointcited by 154
- 2022LIFT: Language-Interfaced Fine-Tuning for Non-Language Machine Learning Taskscited by 146
- 2023A Toy Model of Universality: Reverse Engineering How Networks Learn Group Operationscited by 141
38 more
- 2023Looped Transformers are Better at Learning Learning Algorithmscited by 135
- 2023Skill-it! A Data-Driven Skills Framework for Understanding and Training Language Modelscited by 120
- 2023Linear attention is (maybe) all you need (to understand transformer optimization)cited by 97
- 2023How Do Transformers Learn Topic Structure: Towards a Mechanistic Understandingcited by 85
- 2022Same Pre-training Loss, Better Downstream: Implicit Bias Matters for Language Modelscited by 84
- 2023Transformers as Decision Makers: Provable In-Context Reinforcement Learning via Supervised Pretrainingcited by 82
- 2024Transformers Can Achieve Length Generalization But Not Robustlycited by 82
- 2024Transformers, parallel computation, and logarithmic depthcited by 75
- 2023Exposing Attention Glitches with Flip-Flop Language Modelingcited by 74
- 2023Generalization on the Unseen, Logic Reasoning and Degree Curriculumcited by 73
- 2023Length Generalization in Arithmetic Transformerscited by 64
- 2024Understanding Transformer Reasoning Capabilities via Graph Algorithmscited by 64
- 2023Positional Description Matters for Transformers Arithmeticcited by 56
- 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMscited by 54
- 2023Mimetic Initialization of Self-Attention Layerscited by 52
- 2022Learning threshold neurons via the "edge of stability"cited by 50
- 2023The Closeness of In-Context Learning and Weight Shifting for Softmax Regressioncited by 41
- 2023What can a Single Attention Layer Learn? A Study Through the Random Features Lenscited by 39
- 2024How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpadcited by 35
- 2023Transformers are uninterpretable with myopic methods: a case study with bounded Dyck grammarscited by 30
- 2022Towards Better Out-of-Distribution Generalization of Neural Algorithmic Reasoning Taskscited by 29
- 2023A Mathematical Abstraction for Balancing the Trade-off Between Creativity and Reality in Large Language Modelscited by 29
- 2024Out-of-distribution generalization via composition: a lens through induction heads in Transformerscited by 28
- 2023The Crucial Role of Normalization in Sharpness-Aware Minimizationcited by 26
- 2024Universal Length Generalization with Turing Programscited by 25
- 2025Quantitative Clustering in Mean-Field Transformer Modelscited by 23
- 2024Position Coupling: Improving Length Generalization of Arithmetic Transformers Using Task Structurecited by 22
- 2024Mixture of Parrots: Experts improve memorization more than reasoningcited by 20
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?cited by 20
- 2023Mapping of attention mechanisms to a generalized Potts modelcited by 19
- 2023Learning to Extrapolate: A Transductive Approachcited by 19
- 2025How Do Transformers Learn Variable Binding in Symbolic Programs?cited by 19
- 2024ALPINE: Unveiling the Planning Capability of Autoregressive Learning in Language Modelscited by 18
- 2023Can Transformers Learn to Solve Problems Recursively?cited by 17
- 2024Spatio-Spectral Graph Neural Networkscited by 17
- 2024A Review of the Applications of Deep Learning-Based Emergent Communicationcited by 17
- 2022Understanding the Covariance Structure of Convolutional Filterscited by 16
- 2024On the Surprising Effectiveness of Attention Transfer for Vision Transformerscited by 16
50 most cited of 105 All 105 (JSON)
- 2026Transformers Stop Thinking Too Early, and a Tiny LoRA Fixes It29 Sep 2026
- 2026Depth-Staggered Fibonacci Spacing for Sparse Attention: Static Schedules Beat Learned Dilation and Extrapolate Where Dense Attention Fails26 Jun 2026
- 2026Assign and Add: A Mechanistic Study of Compositional Arithmetic29 May 2026
- 2026Why Do Reasoning Models Lose Coverage? The Role of Data and Forks in the Road16 May 2026
- 2026Shortcut Solutions Learned by Transformers Impair Continual Compositional Reasoning6 May 2026
- 2026Discrete Diffusion Models Exploit Asymmetry to Solve Lookahead Planning Tasks23 Feb 2026
- 2026Seeing to Generalize: How Visual Data Corrects Binding Shortcuts16 Feb 2026
- 2026Mimetic Initialization of MLPs6 Feb 2026
- 2025From Shortcut to Induction Head: How Data Diversity Shapes Algorithm Selection in Transformers21 Dec 2025
- 2025In-Context Algebra18 Dec 2025
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization10 Nov 2025
- 2025Small transformer architectures for task switching6 Aug 2025
38 more
- 2025CompoST: A Benchmark for Analyzing the Ability of LLMs To Compositionally Interpret Questions in a QALD Setting28 Jul 2025
- 2025Beyond Statistical Learning: Exact Learning Is Essential for General Intelligence30 Jun 2025
- 2025How Do Transformers Learn Variable Binding in Symbolic Programs?27 May 2025
- 2025Structured Initialization for Vision Transformers26 May 2025
- 2025Quantitative Clustering in Mean-Field Transformer Models20 Apr 2025
- 2025Large Language and Reasoning Models are Shallow Disjunctive Reasoners30 Mar 2025
- 2025Beyond In-Distribution Success: Scaling Curves of CoT Granularity for Language Model Generalization25 Feb 2025
- 2025Random Scaling of Emergent Capabilities24 Feb 2025
- 2025The Role of Sparsity for Length Generalization in Transformers24 Feb 2025
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?19 Feb 2025
- 2025On the Query Complexity of Verifier-Assisted Language Generation17 Feb 2025
- 2024Benchmarking and Understanding Compositional Relational Reasoning of LLMs17 Dec 2024
- 2024An In-depth Investigation of Sparse Rate Reduction in Transformer-like Models26 Nov 2024
- 2024On the Surprising Effectiveness of Attention Transfer for Vision Transformers14 Nov 2024
- 2024Compositional simulation-based inference for time series5 Nov 2024
- 2024Provable Length Generalization in Sequence Prediction via Spectral Filtering1 Nov 2024
- 2024Mixture of Parrots: Experts improve memorization more than reasoning24 Oct 2024
- 2024Mesa-Extrapolation: A Weave Position Encoding Method for Enhanced Extrapolation in LLMs21 Oct 2024
- 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMs17 Oct 2024
- 2024MathGAP: Out-of-Distribution Evaluation on Problems with Arbitrarily Complex Proofs17 Oct 2024
- 2024Low-Dimension-to-High-Dimension Generalization And Its Implications for Length Generalization11 Oct 2024
- 2024Chain-of-Sketch: Enabling Global Visual Reasoning10 Oct 2024
- 2024Task Diversity Shortens the ICL Plateau7 Oct 2024
- 2024Out-of-distribution generalization via composition: a lens through induction heads in Transformers18 Aug 2024
- 2024Your Context Is Not an Array: Unveiling Random Access Limitations in Transformers10 Aug 2024
- 2024Systematic Relational Reasoning With Epistemic Graph Neural Networks24 Jul 2024
- 2024Validating Mechanistic Interpretations: An Axiomatic Approach18 Jul 2024
- 2024Representing Rule-based Chatbots with Transformers15 Jul 2024
- 2024Universal Length Generalization with Turing Programs3 Jul 2024
- 2024A Review of the Applications of Deep Learning-Based Emergent Communication3 Jul 2024
- 2024Reasoning in Large Language Models: A Geometric Perspective2 Jul 2024
- 2024Do LLMs dream of elephants (when told not to)? Latent concept association and associative memory in transformers26 Jun 2024
- 2024How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpad10 Jun 2024
- 2024On the Minimal Degree Bias in Generalization on the Unseen for non-Boolean Functions10 Jun 2024
- 2024Distributional Associations vs In-Context Reasoning: A Study of Feed-forward and Attention Layers5 Jun 2024
- 2024LOLAMEME: Logic, Language, Memory, Mechanistic Framework31 May 2024
- 2024Position Coupling: Improving Length Generalization of Arithmetic Transformers Using Task Structure31 May 2024
- 2024Contextual Counting: A Mechanistic Study of Transformers on a Quantitative Task30 May 2024
50 newest of 105 All 105 (JSON)
- 2024Understanding Transformer Reasoning Capabilities via Graph Algorithmscited by 64
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?cited by 20
- 2024Distributional Associations vs In-Context Reasoning: A Study of Feed-forward and Attention Layerscited by 12
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalizationcited by 12
- 2025On the Query Complexity of Verifier-Assisted Language Generationcited by 10
- 2023Conditions for Length Generalization in Learning Reasoning Skillscited by 7
- 2025Beyond Statistical Learning: Exact Learning Is Essential for General Intelligencecited by 6
- 2024Reasoning in Large Language Models: A Geometric Perspectivecited by 4
- 2024Benchmarking and Understanding Compositional Relational Reasoning of LLMscited by 4
- 2026Why Do Reasoning Models Lose Coverage? The Role of Data and Forks in the Roadcited by 4
- 2024Chain-of-Sketch: Enabling Global Visual Reasoningcited by 3
- 2025Large Language and Reasoning Models are Shallow Disjunctive Reasonerscited by 3
- 2026Why Do Reasoning Models Lose Coverage? The Role of Data and Forks in the Road16 May 2026
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization10 Nov 2025
- 2025Beyond Statistical Learning: Exact Learning Is Essential for General Intelligence30 Jun 2025
- 2025Large Language and Reasoning Models are Shallow Disjunctive Reasoners30 Mar 2025
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?19 Feb 2025
- 2025On the Query Complexity of Verifier-Assisted Language Generation17 Feb 2025
- 2024Benchmarking and Understanding Compositional Relational Reasoning of LLMs17 Dec 2024
- 2024Chain-of-Sketch: Enabling Global Visual Reasoning10 Oct 2024
- 2024Reasoning in Large Language Models: A Geometric Perspective2 Jul 2024
- 2024Distributional Associations vs In-Context Reasoning: A Study of Feed-forward and Attention Layers5 Jun 2024
- 2024Understanding Transformer Reasoning Capabilities via Graph Algorithms28 May 2024
- 2023Conditions for Length Generalization in Learning Reasoning Skills22 Nov 2023
- 2023Can LLMs Capture Human Preferences?cited by 6
- 2023Can LLMs Capture Human Preferences?4 May 2023
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,579
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 496
- 2023Hyena Hierarchy: Towards Larger Convolutional Language Modelscited by 388
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 319
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
- 2022Transformers Learn Shortcuts to Automatacited by 260
- 2022Neural Networks and the Chomsky Hierarchycited by 214
- 2022Exploring Length Generalization in Large Language Modelscited by 204
- 2023Birth of a Transformer: A Memory Viewpointcited by 154
- 2022LIFT: Language-Interfaced Fine-Tuning for Non-Language Machine Learning Taskscited by 146
- 2023A Toy Model of Universality: Reverse Engineering How Networks Learn Group Operationscited by 141
12 most cited of 88 All 88 (JSON)
- 2026Transformers Stop Thinking Too Early, and a Tiny LoRA Fixes It29 Sep 2026
- 2026Depth-Staggered Fibonacci Spacing for Sparse Attention: Static Schedules Beat Learned Dilation and Extrapolate Where Dense Attention Fails26 Jun 2026
- 2026Assign and Add: A Mechanistic Study of Compositional Arithmetic29 May 2026
- 2026Shortcut Solutions Learned by Transformers Impair Continual Compositional Reasoning6 May 2026
- 2026Mimetic Initialization of MLPs6 Feb 2026
- 2025From Shortcut to Induction Head: How Data Diversity Shapes Algorithm Selection in Transformers21 Dec 2025
- 2025In-Context Algebra18 Dec 2025
- 2025Small transformer architectures for task switching6 Aug 2025
- 2025CompoST: A Benchmark for Analyzing the Ability of LLMs To Compositionally Interpret Questions in a QALD Setting28 Jul 2025
- 2025How Do Transformers Learn Variable Binding in Symbolic Programs?27 May 2025
- 2025Structured Initialization for Vision Transformers26 May 2025
- 2025Quantitative Clustering in Mean-Field Transformer Models20 Apr 2025
12 newest of 88 All 88 (JSON)