Limits of Transformer Language Models on Learning to Compose Algorithms
Jonathan Thomm, Giacomo Camposampiero, Aleksandar Terzic, Michael Hersche, Bernhard Schölkopf, Abbas Rahimi
Abstract
We analyze the capabilities of Transformer language models in learning compositional discrete tasks. To this end, we evaluate training LLaMA models and prompting GPT-4 and Gemini on four tasks demanding to learn a composition of several discrete sub-tasks. In particular, we measure how well these models can reuse primitives observable in the sub-tasks to learn the composition task. Our results indicate that compositional learning in state-of-the-art Transformer language models is highly sample inefficient: LLaMA requires more data samples than relearning all sub-tasks from scratch to learn the compositional task; in-context prompting with few samples is unreliable and fails at executing the sub-tasks or correcting the errors in multi-round code generation. Further, by leveraging complexity theory, we support these findings with a theoretical analysis focused on the sample inefficiency of gradient descent in memorizing feedforward models. We open source our code at https://github.com/IBM/limitations-lm-algorithmic-compositional-learning.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
6 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Memorization Without Overfitting: Analyzing the Training Dynamics of Large Language Models cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Lost in Transmission: When and Why LLMs Fail to Reason Globally cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Lost in Transmission: When and Why LLMs Fail to Reason Globally cites Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspective
- Lost in Transmission: When and Why LLMs Fail to Reason Globally cites Faith and Fate: Limits of Transformers on Compositionality
- Compositional-ARC: Assessing Systematic Generalization in Abstract Spatial Reasoning cites Measuring Compositional Generalization: A Comprehensive Method on Realistic Data
- Compositional-ARC: Assessing Systematic Generalization in Abstract Spatial Reasoning cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Compositional-ARC: Assessing Systematic Generalization in Abstract Spatial Reasoning cites Faith and Fate: Limits of Transformers on Compositionality
- Continuous Chain of Thought Enables Parallel Exploration and Reasoning cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Continuous Chain of Thought Enables Parallel Exploration and Reasoning cites Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspective
- Continuous Chain of Thought Enables Parallel Exploration and Reasoning cites Faith and Fate: Limits of Transformers on Compositionality
- Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspective cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Faith and Fate: Limits of Transformers on Compositionality cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Cited by top-tier papers6
- Continuous Chain of Thought Enables Parallel Exploration and ReasoningHalil Alperen Gozeten, Muhammed Emrullah Ildiz, Xuechen Zhang, Hrayr Harutyunyan et al.ICLR 2026 · 40 citations
- Lost in Transmission: When and Why LLMs Fail to Reason GloballyTobias Schnabel, Kiran Tomlinson, Adith Swaminathan, Jennifer NevilleNeurIPS 2025 · 9 citations
- Behavioural vs. Representational Systematicity in End-to-End Models: An Opinionated SurveyIvan Vegner, Sydelle de Souza, Valentin Forch, Martha Lewis et al.ACL 2025 · 3 citations
- Compositional-ARC: Assessing Systematic Generalization in Abstract Spatial ReasoningPhilipp Mondorf, Shijia Zhou, Monica Riedler, Barbara PlankICLR 2026 · 3 citations
- Scalable Evaluation and Neural Models for Compositional GeneralizationGiacomo Camposampiero, Pietro Barbiero, Michael Hersche, Roger Wattenhofer et al.NeurIPS 2025 · 3 citations
Builds on22
- Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
- Faith and Fate: Limits of Transformers on CompositionalityNouha Dziri, Ximing Lu, Melanie Sclar, Xiang Lorraine Li et al.NeurIPS 2023 · 728 citations
- Towards Revealing the Mystery behind Chain of Thought: A Theoretical PerspectiveGuhao Feng, Bohang Zhang, Yuntian Gu, Haotian Ye et al.NeurIPS 2023 · 470 citations
- Measuring Compositional Generalization: A Comprehensive Method on Realistic DataDaniel Keysers, Nathanael Schärli, Nathan Scales, Hylke Buisman et al.ICLR 2020 · 401 citations
- Memorization Without Overfitting: Analyzing the Training Dynamics of Large Language ModelsKushal Tirumala, Aram H. Markosyan, Luke Zettlemoyer, Armen AghajanyanNeurIPS 2022 · 304 citations
Related papers
- Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete FunctionsSatwik Bhattamishra, Arkil Patel, Phil Blunsom, Varun KanadeICLR 2024 · 77 citations
- ExeDec: Execution Decomposition for Compositional Generalization in Neural Program SynthesisKensen Shi, Joey Hong, Yinlin Deng, Pengcheng Yin et al.ICLR 2024 · 21 citations
- What Makes Large Language Models Reason in (Multi-Turn) Code Generation?Kunhao Zheng, Juliette Decugis, Jonas Gehring, Taco Cohen et al.ICLR 2025
- Better & Faster Large Language Models via Multi-token PredictionFabian Gloeckle, Badr Youbi Idrissi, Baptiste Rozière, David Lopez-Paz et al.ICML 2024 · 286 citations
- Understanding the Generalization of In-Context Learning in Transformers: An Empirical StudyXingxuan Zhang, Haoran Wang, Jiansheng Li, Yuan Xue et al.ICLR 2025
