SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2308.06912 · ICLR · 2024

CausalLM is not optimal for in-context learning

Sebastian Goodman, Nan Ding, Radu Soricut, Tomer Levinboim, Jialin Wu

arXiv · PDF · Open in the Atlas

Code that ran

8 of 13 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; 2 honoured the contract we drafted, 1 violated it and 1 has no contract verdict; 4 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/2308.06912.json · badge: /api/ran/2308.06912.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
google-research/causallm_icl canonical (classifier label)
classifier basis: census
8 ran · 5 no recorded run
FunctionStatusWhere it lives
dot_product_attention Ran
ran; our contract draft was wrong, not the code
google-research/causallm_icl/self_attention_patch.py
code served (permissive licence) · get_code("25ce8c68e697049c")
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 jax
import jax.numpy as jnp
from jax import random

# Set seed for reproducibility
key = random.PRNGKey(0)

# Define dimensions with distinct values
batch_size = 2
q_length = 3
kv_length = 4
num_heads = 2
qk_depth_per_head = 5
v_depth_per_head = 6

# Create query, key, value arrays
# Shape: [batch..., length, num_heads, depth_per_head]
query = jnp.ones((batch_size, q_length, num_heads, qk_depth_per_head), dtype=jnp.float32)
key = jnp.ones((batch_size, kv_length, num_heads, qk_depth_per_head), dtype=jnp.float32)
value = jnp.ones((batch_size, kv_length, num_heads, v_depth_per_head), dtype=jnp.float32)

# Optional bias: shape [batch..., num_heads, q_length, kv_length]
bias = jnp.zeros((batch_size, num_heads, q_length, kv_length), dtype=jnp.float32)

# Optional mask: shape [batch..., num_heads, q_length, kv_length]
mask = jnp.ones((batch_size, num_heads, q_length, kv_length), dtype=bool)

# Dropout RNG key
dropout_rng = random.PRNGKey(1)

ARGS = {
    'query': query,
    'key': key,
    'value': value,
    'bias': bias,
    'mask': mask,
    'broadcast_dropout': True,
    'dropout_rng': dropout_rng,
    'dropout_rate': 0.1,
    'deterministic': False,
    'dtype': jnp.float32,
    'precision': None,
    'return_attention': False,
    'disable_softmax': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
flax, jax — 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
dot_product_attention_weights Ran
ran; our contract draft was wrong, not the code
google-research/causallm_icl/self_attention_patch.py
code served (permissive licence) · get_code("9023ce088127d9ce")
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 ArrayImpl, ndim 4, 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 jax
import jax.numpy as jnp
from jax import random

# Set seed for reproducibility
key = random.PRNGKey(0)

# Define tensor shapes following the docstring requirements:
# query: [batch..., q_length, num_heads, qk_depth_per_head]
# key: [batch..., kv_length, num_heads, qk_depth_per_head]

batch_size = 2
q_length = 3
kv_length = 4
num_heads = 2
qk_depth_per_head = 5

# Create query and key tensors
query = jnp.ones((batch_size, q_length, num_heads, qk_depth_per_head), dtype=jnp.float32)
key = jnp.ones((batch_size, kv_length, num_heads, qk_depth_per_head), dtype=jnp.float32)

# Optional bias with shape broadcastable to [batch..., num_heads, q_length, kv_length]
bias = jnp.zeros((batch_size, num_heads, q_length, kv_length), dtype=jnp.float32)

# Optional mask with shape broadcastable to [batch..., num_heads, q_length, kv_length]
mask = jnp.ones((batch_size, num_heads, q_length, kv_length), dtype=bool)

# Dropout-related parameters
dropout_rng = random.PRNGKey(1)
dropout_rate = 0.1

ARGS = {
    "query": query,
    "key": key,
    "bias": bias,
    "mask": mask,
    "broadcast_dropout": True,
    "dropout_rng": dropout_rng,
    "dropout_rate": dropout_rate,
    "deterministic": False,
    "dtype": jnp.float32,
    "precision": None,
    "disable_softmax": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 4, dtype family float — no output shape is stated: observe_signature.py could not observe it (import:TimeoutError)
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
extract_y Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
google-research/causallm_icl/predictor_flax.py
code served (permissive licence) · get_code("335bd7f77a12cdf9")
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 ArrayImpl, ndim 3, dtype family float, shape (2, 5, 1) 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 jax.numpy as jnp
import numpy as np

# Create a small input tensor with shape (batch_size, seq_length, hidden_size)
# Using distinct dimensions: batch=2, seq_length=5, hidden_size=4
seq = jnp.ones((2, 5, 4))

# Define arguments for extract_y function
ARGS = {
    "seq": seq,
    "offset": 0,
    "num_classes": 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 3, dtype family float, shape (2, 5, 1) — shape (2, 5, 1) 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
l2_loss Ran
ran, violated the contract we drafted
google-research/causallm_icl/predictor_flax.py
code served (permissive licence) · get_code("b5919b0f35895f63")
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 ArrayImpl, ndim 1, dtype family float, shape (2,) 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 jax.numpy as jnp
import numpy as np

# Create small test arrays
y1 = jnp.array([[1.0, 2.0, 3.0, 4.0],
                 [5.0, 6.0, 7.0, 8.0]])

y2 = jnp.array([[0.5, 1.5, 2.5, 3.5],
                 [4.5, 5.5, 6.5, 7.5]])

ARGS = {
    "y1": y1,
    "y2": y2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family float, shape (2,) — shape (2,) 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
logistic_loss Ran
ran, honoured the contract we drafted
google-research/causallm_icl/predictor_flax.py
code served (permissive licence) · get_code("52590a86263d6fbf")
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 ArrayImpl, ndim 1, dtype family float, shape (2,) 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 jax.numpy as jnp
import numpy as np

# Set seed for reproducibility
np.random.seed(0)

# Create small test arrays
y1 = jnp.array([[0.5, -0.3, 0.2, 0.1],
                 [0.8, -0.5, 0.4, -0.2]])

y2 = jnp.array([[0.2, 0.8, 0.3, 0.7],
                 [0.6, 0.4, 0.9, 0.1]])

ARGS = {
    "y1": y1,
    "y2": y2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family float, shape (2,) — shape (2,) 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
map_func Ran
ran; our contract draft was wrong, not the code
google-research/causallm_icl/sampler_lib.py
code served (permissive licence) · get_code("a3413d734b445c7a")
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 numpy as np

ARGS = {
    'name': 'linear'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
set_seed Ran
ran, honoured the contract we drafted
google-research/causallm_icl/utils.py
code served (permissive licence) · get_code("fec430a564c9c333")
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, ndim 1, 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 random
from typing import Any, Callable, List, Union
import numpy as np

# The function set_seed takes a single parameter: seed (int)
# It uses this seed to initialize random.seed() and np.random.seed()
# It returns a list containing the seed

ARGS = {
    "seed": 42
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list 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
trh Ran
ran on a synthesized input
google-research/causallm_icl/utils.py
code served (permissive licence) · get_code("2e70786d045620a8")
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 ArrayImpl, ndim 1, dtype family float, shape (2,) 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 jax
import jax.numpy as jnp
import numpy as np

# Set seed for reproducibility
np.random.seed(0)

# Create a simple loss function that takes x and hid as arguments
def loss_fn(x, hid):
    """Simple quadratic loss function"""
    # Square the input and sum, scaled by hid parameter
    return jnp.sum(x ** 2) * (1.0 + hid * 0.1)

# Create input array (batch_size=2, feature_dim=4)
x = jnp.array([[1.0, 2.0, 3.0, 4.0],
               [0.5, 1.5, 2.5, 3.5]])

# Hidden layer id (scalar integer)
hid = 1

# Number of samples for Hutchinson method
nsamples = 5

ARGS = {
    "loss_fn": loss_fn,
    "x": x,
    "hid": hid,
    "nsamples": nsamples
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family float, shape (2,) — shape (2,) 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
save_checkpoint Not yet run
unverified (harvested, no recorded run)
google-research/causallm_icl/model_trainer.py
code served (permissive licence) · get_code("6f0e9bed65917eba")
How it ran

no invocation recorded.

str_to_distribution_fn Not yet run
unverified (harvested, no recorded run)
google-research/causallm_icl/sampler_lib.py
code served (permissive licence) · get_code("18a0f3cf92558fad")
How it ran

no invocation recorded.

str_to_gmm_mix_fn Not yet run
unverified (harvested, no recorded run)
google-research/causallm_icl/sampler_lib.py
code served (permissive licence) · get_code("585d0af2bc39c312")
How it ran

no invocation recorded.

train_step Not yet run
unverified (harvested, no recorded run)
google-research/causallm_icl/model_trainer.py
code served (permissive licence) · get_code("db573bba4a35a0c9")
How it ran

no invocation recorded.

y_x_fn Not yet run
unverified (harvested, no recorded run)
google-research/causallm_icl/utils.py
code served (permissive licence) · get_code("be4179e9fe9ec75c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 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 13 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

Recent empirical evidence indicates that transformer based in-context learning performs better when using a prefix language model (prefixLM), in which incontext samples can all attend to each other, compared to causal language models (causalLM), which use auto-regressive attention that prohibits in-context samples to attend to future samples. While this result is intuitive, it is not understood from a theoretical perspective. In this paper we take a theoretical approach and analyze the convergence behavior of prefixLM and causalLM under a certain parameter construction. Our analysis shows that both LM types converge to their stationary points at a linear rate, but that while prefixLM converges to the optimal solution of linear regression, causalLM convergence dynamics follows that of an online gradient descent algorithm, which is not guaranteed to be optimal even as the number of samples grows infinitely. We supplement our theoretical claims with empirical experiments over synthetic and real tasks and using various types of transformers. Our experiments verify that causalLM consistently underperforms prefixLM in all settings.

For agents

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

get_harvested_code_for_paper("2308.06912")
get_code_for_paper("2308.06912")
have("2308.06912")

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

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

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

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

Connect an agent — have() is free.