SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.07665 · 2023

Deep Backtracking Counterfactuals for Causally Compliant Explanations

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 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; 4 failures of our instrument; 3 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/2310.07665.json · badge: /api/ran/2310.07665.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
rudolfwilliam/deepbc canonical (classifier label)
classifier basis: census
4 ran · 3 no recorded run
FunctionStatusWhere it lives
bc_loss Ran
ran; our contract draft was wrong, not the code
rudolfwilliam/deepbc/src/deepbc/optim/backtrack.py
code served (permissive licence) · get_code("03018b4279ef7731")
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
import torch.nn as nn

torch.manual_seed(0)

# Build a minimal SCM model that implements decode_flat
class MinimalSCM(nn.Module):
    def __init__(self, num_vars=3, flat_dim=4):
        super().__init__()
        self.num_vars = num_vars
        self.flat_dim = flat_dim
        # Simple linear layer to decode flat representation
        self.decoder = nn.Linear(flat_dim, num_vars)
    
    def decode_flat(self, us_pr_flat):
        # us_pr_flat shape: (batch_size, flat_dim)
        # Output should be a dict with keys for each variable
        decoded = self.decoder(us_pr_flat)  # (batch_size, num_vars)
        return {
            'var_0': decoded[:, 0:1],  # (batch_size, 1)
            'var_1': decoded[:, 1:2],  # (batch_size, 1)
            'var_2': decoded[:, 2:3],  # (batch_size, 1)
        }

# Create instances
scm = MinimalSCM(num_vars=3, flat_dim=4)

# Batch size = 2, flat_dim = 4
batch_size = 2
flat_dim = 4

# Create tensors
us_pr_flat = torch.randn(batch_size, flat_dim)  # Predicted flat representation
us_flat = torch.randn(batch_size, flat_dim)     # Ground truth flat representation

# us dict: maps variable names to their tensor representations
us = {
    'var_0': torch.randn(batch_size, 2),  # 2 features for var_0
    'var_1': torch.randn(batch_size, 1),  # 1 feature for var_1
    'var_2': torch.randn(batch_size, 1),  # 1 feature for var_2
}

# Other arguments
vars_ = ['var_0', 'var_1', 'var_2']
vals_ast = torch.randn(batch_size, 3)  # Target values for each variable
lambda_ = 1.0
weights_flat = torch.ones(flat_dim)
custom_dist = None

ARGS = {
    'scm': scm,
    'vars_': vars_,
    'vals_ast': vals_ast,
    'lambda_': lambda_,
    'us_pr_flat': us_pr_flat,
    'us_flat': us_flat,
    'dist_fun': 'l2',
    'weights_flat': weights_flat,
    'custom_dist': custom_dist,
    'us': us,
}
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
freeze_model Ran
ran; our contract draft was wrong, not the code
rudolfwilliam/deepbc/src/deepbc/utils.py
code served (permissive licence) · get_code("e20448cca1573ade")
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 SimpleModel. 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

torch.manual_seed(0)

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

model = SimpleModel()

ARGS = {
    "model": model
}
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 SimpleModel — a SimpleModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleModel 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_checkpoint_callback Ran
ran; our contract draft was wrong, not the code
rudolfwilliam/deepbc/src/deepbc/utils.py
code served (permissive licence) · get_code("61ded7f89d716301")
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 ModelCheckpoint. 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 pytorch_lightning.callbacks import ModelCheckpoint

torch.manual_seed(0)

# Define ARGS dict with all parameters for generate_checkpoint_callback
ARGS = {
    "model_name": "test_model",
    "dir_path": "/tmp/checkpoints"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pytorch_lightning, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ModelCheckpoint — a ModelCheckpoint output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ModelCheckpoint 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_early_stopping_callback Ran
ran; our contract draft was wrong, not the code
rudolfwilliam/deepbc/src/deepbc/utils.py
code served (permissive licence) · get_code("a3559acb11cbd04f")
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 EarlyStopping. 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
from pytorch_lightning.callbacks import EarlyStopping

torch.manual_seed(0)

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

no invocation recorded.

backtrack_linearize Not yet run
unverified (harvested, no recorded run)
rudolfwilliam/deepbc/src/deepbc/optim/backtrack.py
code served (permissive licence) · get_code("7e5d06e4f64e59ce")
How it ran

no invocation recorded.

langevin_mc Not yet run
unverified (harvested, no recorded run)
rudolfwilliam/deepbc/src/deepbc/sampling/sample.py
code served (permissive licence) · get_code("4fcd981ea9374b01")
How it ran

no invocation recorded.

Also present in other papers' code

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

Counterfactuals answer questions of what would have been observed under altered circumstances and can therefore offer valuable insights. Whereas the classical interventional interpretation of counterfactuals has been studied extensively, backtracking constitutes a less studied alternative where all causal laws are kept intact. In the present work, we introduce a practical method called deep backtracking counterfactuals (DeepBC) for computing backtracking counterfactuals in structural causal models that consist of deep generative components. We propose two distinct versions of our method--one utilizing Langevin Monte Carlo sampling and the other employing constrained optimization--to generate counterfactuals for high-dimensional data. As a special case, our formulation reduces to methods in the field of counterfactual explanations. Compared to these, our approach represents a causally compliant, versatile and modular alternative. We demonstrate these properties experimentally on a modified version of MNIST and CelebA.

For agents

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

get_harvested_code_for_paper("2310.07665")
get_code_for_paper("2310.07665")
have("2310.07665")

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

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

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

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

Connect an agent — have() is free.