SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2103.10415 · NeurIPS · 2021

Refining Language Models with Compositional Explanations

Xisen Jin, Xiang Ren, Huihan Yao, Ying Chen, Qinyuan Ye

arXiv · PDF · Open in the Atlas

Code that ran

3 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 2 failures of our instrument; 2 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/2103.10415.json · badge: /api/ran/2103.10415.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
ink-usc/expl-refinement canonical (classifier label)
classifier basis: classifier_2025
2 ran · 1 no recorded run
INK-USC/expl-refinement marked official in Papers with Code
Papers with Code archive
1 ran · 1 no recorded run
FunctionStatusWhere it lives
_SamplingAndOcclusionBaseAlgo Ran
ran on a synthesized input · constructed an object; no result was computed
INK-USC/expl-refinement/expl-reg/hiex/soc_algo.py
code served (permissive licence) · get_code("a42ef5d950b7cf42")
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 an instance of its own class, _SamplingAndOcclusionBaseAlgo: the run constructed the object and did not call it, so no result was computed. 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
from unittest.mock import Mock

torch.manual_seed(0)

# Create a minimal mock model
class MinimalModel(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = torch.nn.Linear(4, 2)
    
    def forward(self, input_ids, attention_mask=None, token_type_ids=None):
        return torch.randn(2, 2)

# Create a minimal tokenizer
class MinimalTokenizer:
    def __init__(self):
        self.pad_token = "<pad>"
        self.encoder = {
            "<pad>": 0,
            "hello": 1,
            "world": 2,
            "[CLS]": 101,
            "[SEP]": 102,
        }
        self.vocab = {
            "<pad>": 0,
            "hello": 1,
            "world": 2,
            "[CLS]": 101,
            "[SEP]": 102,
        }

# Create a minimal config
class MinimalConfig:
    def __init__(self):
        self.max_seq_length = 20
        self.batch_size = 2
        self.nb_range = 2
        self.base_model = "bert"

model = MinimalModel()
tokenizer = MinimalTokenizer()
output_path = "/tmp"
configs = MinimalConfig()

ARGS = {
    "model": model,
    "tokenizer": tokenizer,
    "output_path": output_path,
    "configs": configs,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, skimage, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type _SamplingAndOcclusionBaseAlgo — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a _SamplingAndOcclusionBaseAlgo 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
acc_and_f1 Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ink-usc/expl-refinement/expl-reg/run_model.py
code served (permissive licence) · get_code("8e2029fe34283e24")
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) 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 torch

torch.manual_seed(0)

# Create predictions (binary classification)
preds = np.array([0, 1, 1, 0, 1, 1])

# Create labels (binary classification)
labels = np.array([0, 1, 0, 0, 1, 1])

# Create prediction probabilities (2 classes)
pred_probs = np.array([
    [0.9, 0.1],
    [0.2, 0.8],
    [0.7, 0.3],
    [0.8, 0.2],
    [0.3, 0.7],
    [0.1, 0.9]
])

ARGS = {
    'preds': preds,
    'labels': labels,
    'pred_probs': pred_probs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, sklearn, 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
compute_fprd Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ink-usc/expl-refinement/expl-reg/run_model.py
code served (permissive licence) · get_code("3e02f7733fe044f3")
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) 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

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

# Create sample data
batch_size = 8

# preds: binary predictions (0 or 1)
preds = np.array([0, 1, 1, 0, 1, 1, 0, 0])

# labels: ground truth binary labels (0 or 1)
labels = np.array([0, 1, 0, 0, 1, 1, 1, 0])

# pred_probs: prediction probabilities (not used in the function body, but required as parameter)
pred_probs = np.random.rand(batch_size)

# subgroups: list of index arrays for different subgroups
# Each subgroup is a boolean mask or index array
subgroups = [
    np.array([0, 1, 2, 3]),  # first subgroup
    np.array([4, 5, 6, 7]),  # second subgroup
    np.array([1, 3, 5, 7]),  # third subgroup
]

ARGS = {
    'preds': preds,
    'labels': labels,
    'pred_probs': pred_probs,
    'subgroups': subgroups,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, sklearn — 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
_SamplingAndOcclusionAlgo Not yet run
unverified (harvested, no recorded run)
INK-USC/expl-refinement/expl-reg/hiex/soc_algo.py
code served (permissive licence) · get_code("23f929ee51fb3360")
How it ran

no invocation recorded.

simple_accuracy Not yet run
unverified (harvested, no recorded run)
ink-usc/expl-refinement/expl-reg/run_model.py
code served (permissive licence) · get_code("3c241ecfe3749a6d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 1 later) and 3 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
simple_accuracy 59 other papers
25 dated earlier, 34 later
1506.05865 (2015-06)
LCSTS: A Large Scale Chinese Short Text Summarization Dataset
1509.01626 (2015-09)
Character-level Convolutional Networks for Text Classification *
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
and 56 more not named here
acc_and_f1 1 other paper
1 dated earlier
2005.02439 (2020-05)
Contextualizing Hate Speech Classifiers with Post-hoc Explanation

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

Pre-trained language models have been successful on text classification tasks, but are prone to learning spurious correlations from biased datasets, and are thus vulnerable when making inferences in a new domain. Prior work reveals such spurious patterns via post-hoc explanation algorithms which compute the importance of input features. Further, the model is regularized to align the importance scores with human knowledge, so that the unintended model behaviors are eliminated. However, such a regularization technique lacks flexibility and coverage, since only importance scores towards a pre-defined list of features are adjusted, while more complex human knowledge such as feature interaction and pattern generalization can hardly be incorporated. In this work, we propose to refine a learned language model for a target domain by collecting human-provided compositional explanations regarding observed biases. By parsing these explanations into executable logic rules, the human-specified refinement advice from a small set of explanations can be generalized to more training examples. We additionally introduce a regularization term allowing adjustments for both importance and interaction of features to better rectify model behavior. We demonstrate the effectiveness of the proposed approach on two text classification tasks by showing improved performance in target domain as well as improved model fairness after refinement 1 .

For agents

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

get_harvested_code_for_paper("2103.10415")
get_code_for_paper("2103.10415")
have("2103.10415")

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

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

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

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

Connect an agent — have() is free.