SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.04420 · EMNLP · 2023

Data Factors for Better Compositional Generalization

Mohit Bansal, Xiang Zhou, Yichen Jiang

arXiv · PDF · Open in the Atlas

Code that ran

8 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 0 no recorded run), measured 2026-11-22; 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/2311.04420.json · badge: /api/ran/2311.04420.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
owenzx/data4comp canonical (classifier label)
classifier basis: census
8 ran · 0 no recorded run
FunctionStatusWhere it lives
encode Ran
ran; our contract draft was wrong, not the code
owenzx/data4comp/data.py
code served (permissive licence) · get_code("839530fa476fdb3b")
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 list. 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 torch

class SimpleVocab:
    def __init__(self, size=10):
        self.size = size
        self._sos_token = 1
        self._eos_token = 2
    
    def sos(self):
        return self._sos_token
    
    def eos(self):
        return self._eos_token
    
    def encode(self, text):
        # Simple mock encoding: return a list of token ids
        if isinstance(text, str):
            tokens = [3 + (ord(c) % 7) for c in text]
        else:
            tokens = [3, 4, 5]
        return tokens

vocab_x = SimpleVocab(size=10)
vocab_y = SimpleVocab(size=10)

data = [
    ("hello", "world"),
    ("foo", "bar")
]

ARGS = {
    "data": data,
    "vocab_x": vocab_x,
    "vocab_y": vocab_y
}
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 list — a list output has no array shape of its own; none is 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
encode_io Ran
ran, honoured the contract we drafted
owenzx/data4comp/data.py
code served (permissive licence) · get_code("82101630969e5b8e")
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 int; 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
import torch.nn as nn

class SimpleVocab:
    def __init__(self, token_set):
        self.token_set = token_set
        self.token_to_id = {t: i for i, t in enumerate(token_set)}
        self._sos_token = "<SOS>"
        self._eos_token = "<EOS>"
    
    def sos(self):
        return 0  # Special token ID for start-of-sequence
    
    def eos(self):
        return 1  # Special token ID for end-of-sequence
    
    def encode(self, text):
        # Encode text as a list of token IDs
        if isinstance(text, str):
            tokens = text.split()
        else:
            tokens = text
        return [self.token_to_id.get(t, 2) for t in tokens]

# Create two simple vocabularies
vocab_x = SimpleVocab(["<SOS>", "<EOS>", "hello", "world", "foo"])
vocab_y = SimpleVocab(["<SOS>", "<EOS>", "goodbye", "earth", "bar"])

# Create a datum (input, output) pair
datum = ("hello world", "goodbye earth")

ARGS = {
    "datum": datum,
    "vocab_x": vocab_x,
    "vocab_y": vocab_y,
}
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 int — 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
encode_io_with_idx Ran
ran; our contract draft was wrong, not the code
owenzx/data4comp/data.py
code served (permissive licence) · get_code("d1448edb6381cc71")
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. 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 torch
import numpy as np

class SimpleVocab:
    def __init__(self, name):
        self.name = name
        self._sos_token = 0
        self._eos_token = 1
    
    def sos(self):
        return self._sos_token
    
    def eos(self):
        return self._eos_token
    
    def encode(self, text):
        if isinstance(text, str):
            return [ord(c) % 10 + 2 for c in text]
        return [2, 3, 4]

vocab_x = SimpleVocab("vocab_x")
vocab_y = SimpleVocab("vocab_y")

datum = ("hello", "world")

index = 42

ARGS = {
    "datum": datum,
    "vocab_x": vocab_x,
    "vocab_y": vocab_y,
    "index": index
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
fn Ran
ran; our contract draft was wrong, not the code
owenzx/data4comp/hlog.py
code served (permissive licence) · get_code("7cb6c55af2773820")
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 function. 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 logging
import threading
import time

# Set up logging to avoid warnings
logging.basicConfig(level=logging.INFO)

# Initialize thread-local state with path list
state = threading.local()
state.path = []

# Define a simple test function to wrap
def test_function(x, y):
    """A simple function that takes two arguments."""
    time.sleep(0.01)  # Small delay to measure
    return x + y

ARGS = {
    'name': 'test_operation',
    'timer': True,
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
get_root_and_suffix Ran
ran; our contract draft was wrong, not the code
owenzx/data4comp/src/aug_batch_generator.py
code served (permissive licence) · get_code("34967128f43b5d23")
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 1, 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

def get_root_and_suffix(s):
    j = len(s) - 1
    while str.isnumeric(s[j]):
        j -= 1
    return (s[:j + 1], s[j + 1:])

ARGS = {
    "s": "layer123"
}
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 1, 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
group Ran
ran; our contract draft was wrong, not the code
owenzx/data4comp/hlog.py
code served (permissive licence) · get_code("f672aab27d220c13")
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 _GeneratorContextManager. 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 logging
import threading
import time
from contextlib import contextmanager

logger = logging.getLogger('hlog')
state = threading.local()

# Initialize the threading.local state with an empty path list
state.path = []

@contextmanager
def task(name, timer=True):
    state.path.append(str(name))
    begin = time.time()
    yield
    end = time.time()
    if timer:
        logger.info('%s{%0.2fs}' % ('/'.join(state.path), end - begin))
    state.path.pop()

def group(name):
    return task(name, timer=False)

ARGS = {
    'name': 'test_group'
}
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 _GeneratorContextManager — a _GeneratorContextManager output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a _GeneratorContextManager 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
nll_to_prob Ran
ran; our contract draft was wrong, not the code
owenzx/data4comp/meta_wrapper.py
code served (permissive licence) · get_code("3f05f00a5c1cfa2f")
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 Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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)

# The function takes nll (negative log likelihood) and converts it to probability
# by computing exp(-nll). The input should be a tensor of NLL values.
nll_tensor = torch.randn(2, 4)  # Small tensor: batch_size=2, dim=4

ARGS = {
    "nll": nll_tensor
}
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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
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
update_substitutor Ran
ran; our contract draft was wrong, not the code
owenzx/data4comp/src/aug_batch_generator.py
code served (permissive licence) · get_code("673a896708c7238b")
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 1, 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
import numpy as np

class MockVocab:
    def __init__(self, contents, pad="<PAD>", sos="<SOS>", eos="<EOS>", 
                 copy="<COPY>", unk="<UNK>", mask="<MASK>"):
        self._contents = contents
        self.PAD = pad
        self.SOS = sos
        self.EOS = eos
        self.COPY = copy
        self.UNK = unk
        self.MASK = mask

# Create vocab_x with some tokens and special tokens
vocab_x_contents = {
    "<PAD>": 0,
    "<SOS>": 1,
    "<EOS>": 2,
    "<COPY>": 3,
    "<UNK>": 4,
    "<MASK>": 5,
    "verb": 6,
    "verb1": 7,
    "verb2": 8,
    "noun": 9,
    "noun3": 10,
}

vocab_x = MockVocab(vocab_x_contents)

# Create vocab_y with some tags
vocab_y_contents = {
    "action": 0,
    "action1": 1,
    "action2": 2,
    "entity": 3,
    "entity3": 4,
}

vocab_y = MockVocab(vocab_y_contents)

# Create token2tag mapping (initial)
token2tag = {
    "verb": "action",
    "noun": "entity",
}

# Create tag2token mapping (initial)
tag2token = {
    "action": ["verb"],
    "entity": ["noun"],
}

ARGS = {
    "token2tag": token2tag,
    "tag2token": tag2token,
    "vocab_x": vocab_x,
    "vocab_y": vocab_y,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, 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

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, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 0 later) and 4 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.

FunctionAlso present inEarliest-datedOthers named
encode 1 other paper
1 dated earlier
2106.03993 (2021-06)
Lexicon Learning for Few-Shot Neural Sequence Modeling
encode_io 1 other paper
1 dated earlier
2106.03993 (2021-06)
Lexicon Learning for Few-Shot Neural Sequence Modeling
fn 1 other paper
1 dated earlier
2106.03993 (2021-06)
Lexicon Learning for Few-Shot Neural Sequence Modeling
group 1 other paper
1 dated earlier
2106.03993 (2021-06)
Lexicon Learning for Few-Shot Neural Sequence Modeling

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-22.

Repositories linked to this paper

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

Abstract

Recent diagnostic datasets on compositional generalization, such as SCAN (Lake and Baroni, 2018) and COGS (Kim and Linzen, 2020), expose severe problems in models trained from scratch on these datasets. However, in contrast to this poor performance, state-of-the-art models trained on larger and more general datasets show better generalization ability. In this work, to reconcile this inconsistency, we conduct an empirical analysis by training Transformer models on a variety of training sets with different data factors, including dataset scale, pattern complexity, example difficulty, etc. First, we show that increased dataset complexity can lead to better generalization behavior on multiple different generalization challenges. To further understand this improvement, we show two axes of the benefit from more complex datasets: they provide more diverse examples so compositional understanding becomes more effective, and they also prevent ungeneralizable memorization of the examples due to reduced example repetition frequency. Finally, we explore how training examples of different difficulty levels influence generalization differently. On synthetic datasets, simple examples invoke stronger compositionality than hard examples do. On larger-scale real language datasets, while hard examples become more important potentially to ensure decent data coverage, a balanced mixture of simple and hard examples manages to induce the strongest generalizability. 1

For agents

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

get_harvested_code_for_paper("2311.04420")
get_code_for_paper("2311.04420")
have("2311.04420")

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

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

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

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

Connect an agent — have() is free.