SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.05836 · ICLR · 2024

Can Large Language Models Infer Causation from Correlation?

Bernhard Schölkopf, Mrinmaya Sachan, Zhijing Jin, Rada Mihalcea, Jiarui Liu, Zhiheng Lyu, Spencer Poff, Mona Diab

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 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 6 have no contract verdict; 1 failure of our instrument; 2 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/2306.05836.json · badge: /api/ran/2306.05836.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
causalnlp/corr2cause canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
RMSELoss Ran
ran on a synthesized input
causalnlp/corr2cause/code/finetune/utils.py
code served (permissive licence) · get_code("8a3decee5b54d71d")
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 0, dtype family float, shape () 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)

# Create small tensors for predictions and targets
yhat = torch.randn(2, 4)
y = torch.randn(2, 4)

ARGS = {
    "yhat": yhat,
    "y": 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 Tensor, ndim 0, dtype family float, shape () — shape () 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
add_args Ran
ran on a synthesized input
causalnlp/corr2cause/code/finetune/utils.py
code served (permissive licence) · get_code("0125471072372399")
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 Args. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 argparse

torch.manual_seed(0)

class Args:
    def __init__(self):
        self.pretrained_model = 'bert-base-uncased'
        self.feature_size = None
        self.dataparallel = None

ARGS = {
    'args': Args()
}
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 Args — a Args output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Args 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
generate_prompt Ran
ran; our contract draft was wrong, not the code
causalnlp/corr2cause/code/run_alpaca.py
code served (permissive licence) · get_code("d9793b16bbddeedb")
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 torch

# Set random seed for reproducibility
torch.manual_seed(0)

# Define arguments for generate_prompt function
ARGS = {
    'instruction': 'Summarize the following text in one sentence.',
    'input_ctxt': 'The quick brown fox jumps over the lazy dog. This is a classic pangram used in typography and font testing.'
}
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 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
get_model Ran
ran on a synthesized input
causalnlp/corr2cause/code/finetune/models.py
code served (permissive licence) · get_code("e44094bd647b0cdb")
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 MockModel. 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 torch.nn as nn
from unittest.mock import Mock, patch

torch.manual_seed(0)

# Mock the transformers library to avoid actual downloads
class MockModel(nn.Module):
    def __init__(self, *args, **kwargs):
        super().__init__()
        self.linear = nn.Linear(768, 2)
    
    def forward(self, input_ids, attention_mask=None, token_type_ids=None):
        return self.linear(torch.randn(2, 768))

class MockAutoModelForSequenceClassification:
    @staticmethod
    def from_pretrained(model_name, *args, **kwargs):
        return MockModel()

class MockBertModel:
    @staticmethod
    def from_pretrained(model_name, *args, **kwargs):
        return MockModel()

class MockRobertaModel:
    @staticmethod
    def from_pretrained(model_name, *args, **kwargs):
        return MockModel()

class MockLongformerModel:
    @staticmethod
    def from_pretrained(model_name, *args, **kwargs):
        return MockModel()

class MockAutoModel:
    @staticmethod
    def from_pretrained(model_name, *args, **kwargs):
        return MockModel()

# Patch the transformers imports
import sys
transformers_mock = Mock()
transformers_mock.AutoModelForSequenceClassification = MockAutoModelForSequenceClassification
transformers_mock.BertModel = MockBertModel
transformers_mock.RobertaModel = MockRobertaModel
transformers_mock.LongformerModel = MockLongformerModel
transformers_mock.AutoModel = MockAutoModel

sys.modules['transformers'] = transformers_mock

ARGS = {
    'pretrained_model': 'bert-base-uncased',
    'clf': 'binary',
    'num_labels': 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockModel — a MockModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockModel 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
modify_dict_from_dataparallel Ran
ran on a synthesized input
causalnlp/corr2cause/code/finetune/utils.py
code served (permissive licence) · get_code("ac2dc39bbcffe7e7")
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 OrderedDict. 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 torch.nn as nn
from collections import OrderedDict

torch.manual_seed(0)

# Create a small state dict that simulates a DataParallel model
# DataParallel prefixes all keys with "module."
state_dict = OrderedDict()
state_dict["module.layer1.weight"] = torch.randn(4, 3)
state_dict["module.layer1.bias"] = torch.randn(4)
state_dict["module.layer2.weight"] = torch.randn(5, 4)

# Create args class with dataparallel attribute
class Args:
    def __init__(self, dataparallel):
        self.dataparallel = dataparallel

# Test both cases
args_with_dataparallel = Args(dataparallel=True)
args_without_dataparallel = Args(dataparallel=False)

# Use the dataparallel=True case for the main test
ARGS = {
    "state_dict": state_dict,
    "args": args_with_dataparallel
}
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 OrderedDict — a OrderedDict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a OrderedDict 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
num_samples2splits Ran
ran on a synthesized input
causalnlp/corr2cause/code/data_stats.py
code served (permissive licence) · get_code("3e06f2ac8a9909be")
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 dict. 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

torch.manual_seed(0)

# Analyze the function:
# num_samples2splits takes a single parameter: num_samples
# It's used as an integer in arithmetic operations (// division, min, subtraction)
# The function returns a dict with 'test', 'dev', 'train' keys

# Test with a typical case
num_samples = 5000

ARGS = {
    'num_samples': num_samples
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
read_optimizer Ran
ran on a synthesized input
causalnlp/corr2cause/code/finetune/models.py
code served (permissive licence) · get_code("a94fe6e02e03f5dc")
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 Namespace. 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 torch.nn as nn
from argparse import Namespace

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 8)
        self.bias_layer = nn.LayerNorm(8)
        self.linear2 = nn.Linear(8, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.bias_layer(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

args = Namespace(
    optimizer='adamw',
    lr_curr=0.001,
    weight_decay=0.01,
    adamw_epsilon=1e-8,
    adamw_warmup_steps=100,
    n_epochs=3
)

len_train_loader = 50

ARGS = {
    'args': args,
    'model': model,
    'len_train_loader': len_train_loader
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace 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_tokenizer Not yet run
unverified (harvested, no recorded run)
causalnlp/corr2cause/code/finetune/models.py
code served (permissive licence) · get_code("e1018057f98e58a0")
How it ran

no invocation recorded.

subsample Not yet run
unverified (harvested, no recorded run)
causalnlp/corr2cause/code/data_postsampling.py
code served (permissive licence) · get_code("fcc354ce3cc55f43")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 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.

FunctionAlso present inEarliest-datedOthers named
generate_prompt 1 other paper
1 later
2312.04350 (2023-12)
CLADDER: Assessing Causal Reasoning in Language Models

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

Causal inference is one of the hallmarks of human intelligence. While the field of Causal NLP has attracted much interest in the recent years, existing causal inference datasets in NLP primarily rely on discovering causality from empirical knowledge (e.g., commonsense knowledge). In this work, we propose the first benchmark dataset to test the pure causal inference skills of large language models (LLMs). Specifically, we formulate a novel task CORR2CAUSE, which takes a set of correlational statements and determines the causal relationship between the variables. We curate a large-scale dataset of more than 200K samples, on which we evaluate seventeen existing LLMs. Through our experiments, we identify a key shortcoming of LLMs in terms of their causal inference skills, and show that these models achieve almost close to random performance on the task. This shortcoming is somewhat mitigated when we try to re-purpose LLMs for this skill via finetuning, but we find that these models still fail to generalize -they can only perform causal inference in in-distribution settings when variable names and textual expressions used in the queries are similar to those in the training set, but fail in out-of-distribution settings generated by perturbing these queries. CORR2CAUSE is a challenging task for LLMs, and can be helpful in guiding future research on improving LLMs' pure reasoning skills and generalizability. 1 * Equal contribution. † Equal supervision. ‡ Work originated as a Meta AI internship project involving Zhijing, Mona, and Spencer.

For agents

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

get_harvested_code_for_paper("2306.05836")
get_code_for_paper("2306.05836")
have("2306.05836")

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

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

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

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

Connect an agent — have() is free.