SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.05785 · NeurIPS · 2024

Limits of Transformer Language Models on Learning to Compose Algorithms

Bernhard Schölkopf, Michael Hersche, Abbas Rahimi, Jonathan Thomm, Giacomo Camposampiero, Aleksandar Terzic

arXiv · PDF · Open in the Atlas

Code that ran

3 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 5 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2402.05785.json · badge: /api/ran/2402.05785.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
ibm/limitations-lm-algorithmic-compositional-learning canonical (classifier label)
classifier basis: census
3 ran · 5 no recorded run
FunctionStatusWhere it lives
generate_text_gemini Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ibm/limitations-lm-algorithmic-compositional-learning/prompting_experiment_utils/prompt_llm.py
code served (permissive licence) · get_code("a838c0231008f30a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import time

# Mock the vertexai module and its dependencies
class MockGenerativeModel:
    def __init__(self, model_name):
        self.model_name = model_name
    
    def generate_content(self, prompt, generation_config=None, stream=False):
        return MockResponse()

class MockResponse:
    def to_dict(self):
        return {
            'candidates': [
                {
                    'content': {
                        'parts': [
                            {'text': 'This is a mock generated response from Gemini.'}
                        ]
                    }
                }
            ]
        }

class MockVertexAI:
    @staticmethod
    def init(project, location):
        pass

# Mock the vertexai module
import sys
from unittest.mock import MagicMock

vertexai_mock = MagicMock()
vertexai_mock.init = MockVertexAI.init
vertexai_mock.preview.generative_models.GenerativeModel = MockGenerativeModel

sys.modules['vertexai'] = vertexai_mock
sys.modules['vertexai.preview'] = MagicMock()
sys.modules['vertexai.preview.generative_models'] = MagicMock()
sys.modules['vertexai.preview.generative_models'].GenerativeModel = MockGenerativeModel

# Define arguments for the function
ARGS = {
    'prompt': 'What is the capital of France?',
    'project_id': 'test-project-123',
    'location': 'us-central1'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
vertexai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
solve_pen Ran
ran; our contract draft was wrong, not the code
ibm/limitations-lm-algorithmic-compositional-learning/prompting_experiment_utils/prompt_builder_pen.py
code served (permissive licence) · get_code("f2db033ab6f2498d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Analyzing the function solve_pen:
# - It takes a single parameter `s` which is a string
# - The function processes a string by:
#   1. Removing 'answer:' prefix and splitting by ':'
#   2. Taking the last part and stripping whitespace
#   3. Splitting into words
#   4. Determining a word length threshold (3 or 2)
#   5. Iterating through words, building an answer by finding words
#      that start with the last l characters of the current word

# Constructing a valid test string:
# The function expects a string with words where each word can lead to the next
# by matching the last l characters.

# Example: "answer: abc bcd cde" 
# - words = ["abc", "bcd", "cde"]
# - l = 3 (since len("abc") == 3)
# - Start at index 0 ("abc"), add words[1] ("bcd")
# - Find next word starting with "bcd"[-3:] = "bcd" -> "cde" at index 2
# - Find next word starting with "cde"[-3:] = "cde" -> None found
# - Result: "bcd cde"

s = "answer: abc bcd cde"

ARGS = {
    "s": s
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
solve_perm Ran
ran; our contract draft was wrong, not the code
ibm/limitations-lm-algorithmic-compositional-learning/prompting_experiment_utils/prompt_builder_perm.py
code served (permissive licence) · get_code("c5d98864dc78e01d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    's': 'answer: apple ant table art | apple'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
build_prompt Not yet run
unverified (harvested, no recorded run)
ibm/limitations-lm-algorithmic-compositional-learning/prompting_experiment_utils/prompt_builder_perm.py
code served (permissive licence) · get_code("7bfe356714c7bb6d")
How it ran

no invocation recorded.

generate_text Not yet run
unverified (harvested, no recorded run)
ibm/limitations-lm-algorithmic-compositional-learning/prompting_experiment_utils/prompt_llm.py
code served (permissive licence) · get_code("95228c89a9638a61")
How it ran

no invocation recorded.

generate_text_openai Not yet run
unverified (harvested, no recorded run)
ibm/limitations-lm-algorithmic-compositional-learning/prompting_experiment_utils/prompt_llm.py
code served (permissive licence) · get_code("5988ae55ce1db95e")
How it ran

no invocation recorded.

get_green_matching_words Not yet run
unverified (harvested, no recorded run)
ibm/limitations-lm-algorithmic-compositional-learning/prompting_experiment_utils/prompt_builder_pen.py
code served (permissive licence) · get_code("075965a867f2f9fc")
How it ran

no invocation recorded.

transform_sample_to_triplets Not yet run
unverified (harvested, no recorded run)
ibm/limitations-lm-algorithmic-compositional-learning/prompting_experiment_utils/prompt_builder_pen.py
code served (permissive licence) · get_code("b2d0b639fff8a846")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2402.05785")
get_code_for_paper("2402.05785")
have("2402.05785")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2402.05785.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2402.05785.svg)](https://syntology.ai/paper/2402.05785)

Connect an agent — have() is free.