SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2604.16763 · 2026

LLM-Extracted Covariates for Clinical Causal Inference: Rethinking Integration Strategies

Jialin Chen, Lei Liu, Kathy Macropol

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 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; 8 failures of our instrument; 1 no recorded run), measured 2026-11-23; 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/2604.16763.json · badge: /api/ran/2604.16763.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
fpxlei/LLM-Covariates-Causal canonical (classifier label)
classifier basis: census
9 ran · 1 no recorded run
FunctionStatusWhere it lives
ate_ipw Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
fpxlei/LLM-Covariates-Causal/analysis/ate_estimator.py
code served (permissive licence) · get_code("1838f3bc82204828")
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 numpy as np
import pandas as pd
from scipy import stats

# Create a small synthetic dataframe with required columns
np.random.seed(42)
n_samples = 20

df = pd.DataFrame({
    'treatment': np.random.binomial(1, 0.5, n_samples),
    'mortality_28d': np.random.binomial(1, 0.3, n_samples),
    'ipw_weight': np.random.uniform(0.5, 2.0, n_samples)
})

ARGS = {
    'df': df,
    'outcome': 'mortality_28d',
    'label': 'IPW',
    'n_boot': 500
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, scipy — 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
ate_matched Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
fpxlei/LLM-Covariates-Causal/analysis/ate_estimator.py
code served (permissive licence) · get_code("e14e135d2d9c11e7")
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 numpy as np
import pandas as pd
from scipy import stats

# Create a small synthetic dataframe for the ate_matched function
np.random.seed(0)

# Generate synthetic data with treatment and outcome columns
n_samples = 100
df = pd.DataFrame({
    'treatment': np.random.binomial(1, 0.5, n_samples),
    'mortality_28d': np.random.normal(0.3, 0.1, n_samples)
})

# Ensure we have both treatment and control groups
df.loc[:50, 'treatment'] = 1
df.loc[51:, 'treatment'] = 0

ARGS = {
    'df': df,
    'outcome': 'mortality_28d',
    'label': 'matched_analysis'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, scipy — 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
compute_e_values Ran
ran; our contract draft was wrong, not the code
fpxlei/LLM-Covariates-Causal/analysis/sensitivity.py
code served (permissive licence) · get_code("eca5845a0a1a15a0")
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 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 numpy as np

# Construct ate_results: a list of dicts with 'ate', 'ci_low', 'ci_high', 'method' keys
ate_results = [
    {
        'method': 'method_a',
        'ate': 0.05,
        'ci_low': 0.02,
        'ci_high': 0.08
    },
    {
        'method': 'method_b',
        'ate': -0.03,
        'ci_low': -0.07,
        'ci_high': -0.01
    },
    {
        'method': 'method_c',
        'ate': 0.12,
        'ci_low': 0.08,
        'ci_high': 0.15
    }
]

baseline_risk = 0.18

ARGS = {
    'ate_results': ate_results,
    'baseline_risk': baseline_risk
}
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 float — 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
compute_ipw Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
fpxlei/LLM-Covariates-Causal/models/matching.py
code served (permissive licence) · get_code("97b500646e20227d")
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 DataFrame. 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
import pandas as pd

# Create a small dataframe with propensity scores and treatment assignments
np.random.seed(0)
n_samples = 20

df = pd.DataFrame({
    'ps': np.random.uniform(0.1, 0.9, n_samples),
    'treatment': np.random.binomial(1, 0.5, n_samples),
    'outcome': np.random.normal(0, 1, n_samples)
})

ARGS = {
    'df': df,
    'trim_pctile': (1, 99)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
e_value Ran
ran, honoured the contract we drafted
fpxlei/LLM-Covariates-Causal/analysis/sensitivity.py
code served (permissive licence) · get_code("668e9628a94e401f")
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 float64, ndim 0, 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 numpy as np

# The function e_value takes a single parameter: rr (risk ratio)
# It should be a numeric value (float or int) that can be compared with 1
# and used in arithmetic operations with numpy functions

ARGS = {
    "rr": 1.5
}
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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
format_chat Ran
ran; our contract draft was wrong, not the code
fpxlei/LLM-Covariates-Causal/finetune/train_lora.py
code served (permissive licence) · get_code("47a898dc72bb2bce")
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

# Create a minimal tokenizer stand-in class
class MockTokenizer:
    def apply_chat_template(self, messages, tokenize=False, add_generation_prompt=False):
        """Mock implementation that formats messages into a string."""
        formatted_text = ""
        for msg in messages:
            role = msg.get('role', 'user')
            content = msg.get('content', '')
            formatted_text += f"{role}: {content}\n"
        return formatted_text

# Create example data with messages
example = {
    'messages': [
        {'role': 'user', 'content': 'Hello, how are you?'},
        {'role': 'assistant', 'content': 'I am doing well, thank you!'},
        {'role': 'user', 'content': 'What is the weather like?'}
    ]
}

# Create tokenizer instance
tokenizer = MockTokenizer()

# Define ARGS mapping
ARGS = {
    'example': example,
    'tokenizer': tokenizer
}
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
llm_match_and_estimate Ran
ran; our contract draft was wrong, not the code
fpxlei/LLM-Covariates-Causal/arm7_llm_analyst.py
code served (permissive licence) · get_code("27e772af638bd751")
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 json
import time
import numpy as np
from unittest.mock import Mock, MagicMock


def create_mock_client():
    """Create a mock OpenAI client that returns valid JSON responses."""
    client = Mock()
    
    # Create a mock response that returns valid JSON
    mock_response = Mock()
    mock_message = Mock()
    mock_message.content = json.dumps({
        "best_match_id": 2,
        "match_confidence": "high",
        "key_confounders": ["SOFA score", "lactate level", "comorbidities", "age"],
        "effect_direction": "beneficial",
        "effect_magnitude": -0.08,
        "reasoning": "Patient 2 had similar severity and baseline characteristics. Early vasopressor likely reduced mortality by improving perfusion."
    })
    mock_response.choices = [mock_message]
    
    client.chat.completions.create = Mock(return_value=mock_response)
    return client


def create_treated_text():
    """Create sample treated patient text."""
    return """TREATED PATIENT (Early Vasopressor)
ID: PT_001
Age: 65 years
SOFA Score: 8
Lactate: 4.2 mmol/L
Comorbidities: Hypertension, Type 2 Diabetes
Clinical Note Excerpt: "65-year-old with sepsis from pneumonia, admitted with hypotension (SBP 85). Early vasopressor initiated within 2 hours. Patient required mechanical ventilation. Outcome: Alive at 28 days."
28-day Mortality: No (0)"""


def create_candidates_text():
    """Create sample candidate control patients."""
    candidates = [
        """Candidate 0 (No Early Vasopressor)
ID: PT_102
Age: 72 years
SOFA Score: 5
Lactate: 2.1 mmol/L
Comorbidities: Hypertension
Clinical Note: "72-year-old with UTI-related sepsis, mild hypotension managed with fluids alone. Outcome: Alive at 28 days."
28-day Mortality: No (0)""",
        
        """Candidate 1 (No Early Vasopressor)
ID: PT_103
Age: 64 years
SOFA Score: 9
Lactate: 5.8 mmol/L
Comorbidities: Hypertension, Type 2 Diabetes, CKD
Clinical Note: "64-year-old with septic shock from aspiration pneumonia, presented in profound shock. DNR status. Outcome: Deceased at day 5."
28-day Mortality: Yes (1)""",
        
        """Candidate 2 (No Early Vasopressor)
ID: PT_104
Age: 66 years
SOFA Score: 8
Lactate: 4.0 mmol/L
Comorbidities: Hypertension, Type 2 Diabetes, CAD
Clinical Note: "66-year-old with community-acquired pneumonia and sepsis, SBP 88 on admission. Managed with aggressive fluid resuscitation, vasopressor withheld per patient preference. Required intubation. Outcome: Alive at 28 days."
28-day Mortality: No (0)""",
        
        """Candidate 3 (No Early Vasopressor)
ID: PT_105
Age: 58 years
SOFA Score: 6
Lactate: 3.1 mmol/L
Comorbidities: Asthma
Clinical Note: "58-year-old with intra-abdominal infection post-surgical complication. Moderate hypotension, responded to fluids. Outcome: Alive at 28 days."
28-day Mortality: No (0)""",
        
        """Candidate 4 (No Early Vasopressor)
ID: PT_106
Age: 68 years
SOFA Score: 8
Lactate: 4.5 mmol/L
Comorbidities: Hypertension, Type 2 Diabetes, CHF
Clinical Note: "68-year-old with urosepsis and acute decompensated heart failure, severely ill on presentation. Vasopressor avoided due to CHF concerns. Required dialysis. Outcome: Alive at 28 days."
28-day Mortality: No (0)"""
    ]
    return candidates


ARGS = {
    'client': create_mock_client(),
    'treated_text': create_treated_text(),
    'candidates_text': create_candidates_text()
}
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 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
load_jsonl Ran
ran; our contract draft was wrong, not the code
fpxlei/LLM-Covariates-Causal/finetune/train_lora.py
code served (permissive licence) · get_code("1bfdd49cdba2faac")
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 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 json
import tempfile
import os

# Create a temporary JSONL file with test data
temp_dir = tempfile.mkdtemp()
jsonl_path = os.path.join(temp_dir, "test.jsonl")

# Write test data to JSONL file
test_records = [
    {"id": 1, "text": "hello world", "value": 42},
    {"id": 2, "text": "foo bar", "value": 99},
    {"id": 3, "text": "test data", "value": 7}
]

with open(jsonl_path, 'w', encoding='utf-8') as f:
    for record in test_records:
        f.write(json.dumps(record) + '\n')

ARGS = {
    "path": jsonl_path
}
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 list, ndim 1, dtype family float — 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
subgroup_cate Ran
ran; our contract draft was wrong, not the code
fpxlei/LLM-Covariates-Causal/analysis/hte_discovery.py
code served (permissive licence) · get_code("3599a59500c471f2")
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 DataFrame. 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 pandas as pd
import numpy as np


class MockCausalForest:
    """Mock causal forest model with effect_inference method."""
    
    def effect_inference(self, X):
        """Return mock inference object with point_estimate and conf_int methods."""
        n_samples = X.shape[0]
        return MockInference(n_samples)


class MockInference:
    """Mock inference object that returns point estimates and confidence intervals."""
    
    def __init__(self, n_samples):
        self.n_samples = n_samples
        # Point estimate: flatten-able array
        self.point_estimate = np.random.randn(n_samples, 1)
    
    def conf_int(self, alpha=0.05):
        """Return tuple of (ci_low, ci_high) arrays."""
        ci_low = self.point_estimate - 0.2
        ci_high = self.point_estimate + 0.2
        return (ci_low, ci_high)


# Create mock dataframe with dummy columns and group column
df_clean = pd.DataFrame({
    'age_group_young': [1, 0, 1, 0],
    'age_group_old': [0, 1, 0, 1],
    'education_high': [1, 1, 0, 0],
    'education_low': [0, 0, 1, 1],
    'age_group': ['young', 'old', 'young', 'old'],
})

x_dummy_cols = ['age_group_young', 'age_group_old', 'education_high', 'education_low']
group_col = 'age_group'
cf = MockCausalForest()

ARGS = {
    'cf': cf,
    'df_clean': df_clean,
    'x_dummy_cols': x_dummy_cols,
    'group_col': group_col,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
variable_importance Not yet run
unverified (harvested, no recorded run)
fpxlei/LLM-Covariates-Causal/analysis/hte_discovery.py
code served (permissive licence) · get_code("68451a4d46d98d2d")
How it ran

no invocation recorded.

Also present in other papers' code

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

Causal inference from electronic health records (EHR) is fundamentally limited by unmeasured confounding: critical clinical states such as frailty, goals of care, and mental status are documented in free-text notes but absent from structured data. Large language models can extract these latent confounders as interpretable, structured covariates, yet how to effectively integrate them into causal estimation pipelines has not been systematically studied. Using the MIMIC-IV database with 21,859 sepsis patients, we compare seven covariate-integration strategies for estimating the effect of early vasopressor initiation on 28-day mortality, spanning tabular-only baselines, traditional NLP representations, and three LLM-augmented approaches. A central finding is that not all integration strategies are equally effective: directly augmenting the propensity score model with LLM covariates achieves the best performance, while dual-caliper matching on text-derived categorical distances restricts the donor pool and degrades estimation. In semi-synthetic experiments with known ground-truth effects, LLM-augmented propensity scores reduce estimation bias from 0.0143 to 0.0003 relative to tabular-only methods, and this advantage persists under substantial simulated extraction error. On real data, incorporating LLM-extracted covariates reduces the estimated treatment effect from 0.055 to 0.027, directionally consistent with the CLOVERS randomized trial, and a doubly robust estimator yielding 0.031 confirms the robustness of this finding. Our results offer practical guidance on when and how text-derived covariates improve causal estimation in critical care. Our code is available at https://github.com/fpxlei/LLM-Covariates-Causal.

For agents

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

get_harvested_code_for_paper("2604.16763")
get_code_for_paper("2604.16763")
have("2604.16763")

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

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

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

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

Connect an agent — have() is free.