Limits of Transformer Language Models on Learning to Compose Algorithms

Jonathan Thomm, Giacomo Camposampiero, Aleksandar Terzic, Michael Hersche, Bernhard Schölkopf +1 more
2/3/2026

No official code found. Best implementation: IBM/limitations-lm-algorithmic-compositional-learning (4 stars, Apache-2.0, last commit 2025-09-29).

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.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Python implementation of the paper "Limits of Transformer Language Models on Learning to Compose Algorithms", NeurIPS 2024.

41PythonOct 3, 20241 years agoApache-2.0

Similar Papers

Cite this paper

@article{thomm2026limits,
  title  = {Limits of Transformer Language Models on Learning to Compose Algorithms},
  author = {Jonathan Thomm and Giacomo Camposampiero and Aleksandar Terzic and Michael Hersche and Bernhard Schölkopf and Abbas Rahimi},
  year   = {2026},
  eprint = {2402.05785},
  archivePrefix = {arXiv},
  doi    = {10.52202/079017-0245},
  url    = {https://arxiv.org/abs/2402.05785},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.05785.svg)](https://codeofpaper.com/paper/2402.05785)

Discussion