SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2104.07644 · EMNLP · 2021

EXPLAGRAPHS: An Explanation Graph Generation Task for Structured Commonsense Reasoning

Mohit Bansal, Swarnadeep Saha, Prateek Yadav, Lisa Bauer

arXiv · PDF · Open in the Atlas

Code that ran

7 of 11 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; 7 failures of our instrument; 4 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/2104.07644.json · badge: /api/ran/2104.07644.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
swarnaHub/ExplaGraphs canonical (classifier label)
classifier basis: census
7 ran · 4 no recorded run
FunctionStatusWhere it lives
compute_metrics Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
swarnaHub/ExplaGraphs/structured_model/utils_relation.py
code served (permissive licence) · get_code("4d0f185176bdada1")
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)

# Construct arguments for compute_metrics
task_name = 'relation'
preds = np.array([0, 1, 0, 1])
labels = np.array([0, 1, 1, 0])

ARGS = {
    'task_name': task_name,
    'preds': preds,
    'labels': labels,
}
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
convert_examples_to_features Ran
ran; our contract draft was wrong, not the code
swarnaHub/ExplaGraphs/structured_model/utils_joint_model.py
code served (permissive licence) · get_code("03334853b0b4fe82")
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 logging
from collections import namedtuple

logger = logging.getLogger(__name__)

# Create a minimal tokenizer stand-in
class SimpleTokenizer:
    def tokenize(self, word):
        # Split word into subword tokens
        if word.lower() in ['the', 'quick', 'brown', 'fox']:
            return [word.lower()]
        return list(word.lower())
    
    def convert_tokens_to_ids(self, tokens):
        # Simple mapping of tokens to ids
        token_to_id = {
            '[CLS]': 101,
            '[SEP]': 102,
            't': 1,
            'h': 2,
            'e': 3,
            'q': 4,
            'u': 5,
            'i': 6,
            'c': 7,
            'k': 8,
            'b': 9,
            'r': 10,
            'o': 11,
            'w': 12,
            'n': 13,
            'f': 14,
            'x': 15,
        }
        return [token_to_id.get(t, 0) for t in tokens]

# Create example objects
Example = namedtuple('Example', [
    'id', 'belief', 'node_label_internal_belief',
    'argument', 'node_label_internal_argument',
    'external', 'node_label_external',
    'edge_label', 'stance_label'
])

example1 = Example(
    id='ex1',
    belief=['the', 'quick'],
    node_label_internal_belief=['B-N', 'I-N'],
    argument=['brown', 'fox'],
    node_label_internal_argument=['B-N', 'I-N'],
    external=['test'],
    node_label_external=['O'],
    edge_label=[0, 1, 1, 0],  # 2x2 edge labels
    stance_label='support'
)

example2 = Example(
    id='ex2',
    belief=['quick'],
    node_label_internal_belief=['B-N'],
    argument=['brown'],
    node_label_internal_argument=['O'],
    external=['test'],
    node_label_external=['O'],
    edge_label=[0, 1, 1, 0],
    stance_label='oppose'
)

ARGS = {
    'examples': [example1, example2],
    'stance_label_list': ['support', 'oppose', 'neutral'],
    'node_label_list': ['B-N', 'I-N', 'O'],
    'max_seq_length': 16,
    'max_nodes': 2,
    'tokenizer': SimpleTokenizer(),
    'cls_token': '[CLS]',
    'sep_token': '[SEP]'
}
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
convert_examples_to_features Ran
ran; our contract draft was wrong, not the code
swarnaHub/ExplaGraphs/structured_model/utils_relation.py
code served (permissive licence) · get_code("01ce409a43a05ddd")
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 logging
from unittest.mock import Mock

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Create a simple tokenizer mock that has the methods used in the function
class SimpleTokenizer:
    def __init__(self):
        self.vocab = {
            '[CLS]': 101,
            '[SEP]': 102,
            'apple': 1000,
            'banana': 1001,
            'fruit': 1002,
            'yellow': 1003,
        }
    
    def tokenize(self, text):
        # Simple tokenizer that splits on spaces and returns tokens
        words = text.lower().split()
        tokens = []
        for word in words:
            if word in self.vocab:
                tokens.append(word)
            else:
                tokens.append('[UNK]')
        return tokens
    
    def convert_tokens_to_ids(self, tokens):
        # Convert tokens to IDs, using default 0 for unknown tokens
        ids = []
        for token in tokens:
            ids.append(self.vocab.get(token, 0))
        return ids

# Create simple example objects with required attributes
class Example:
    def __init__(self, id, concept1, concept2, relation):
        self.id = id
        self.concept1 = concept1
        self.concept2 = concept2
        self.relation = relation

# Create example data
examples = [
    Example(id='ex1', concept1='apple', concept2='banana', relation='similar'),
    Example(id='ex2', concept1='fruit', concept2='yellow', relation='different'),
]

# Create relation label list
relation_label_list = ['similar', 'different', 'related']

# Create tokenizer
tokenizer = SimpleTokenizer()

# Set up ARGS dict with all parameters
ARGS = {
    'examples': examples,
    'relation_label_list': relation_label_list,
    'max_seq_length': 32,
    'tokenizer': tokenizer,
    'cls_token': '[CLS]',
    'sep_token': '[SEP]',
}
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
get_dfs_ordering Ran
ran; our contract draft was wrong, not the code
swarnaHub/ExplaGraphs/metrics/create_ea_data.py
code served (permissive licence) · get_code("842852f49ade917d")
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 networkx as nx

# The function expects a graph_string parameter that represents a directed graph
# in a specific format: (node1; relation; node2)(node3; relation; node4)...
# The function parses this string, builds a networkx DiGraph, finds nodes with
# in_degree 0 as start nodes, performs DFS, and returns a reordered string.

# Let's create a valid graph_string for a simple DAG:
# A -> B, A -> C, B -> D
# This represents: A points to B with relation "rel1", A points to C with relation "rel2", B points to D with relation "rel3"

graph_string = "(A; rel1; B)(A; rel2; C)(B; rel3; D)"

ARGS = {
    "graph_string": graph_string
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx — 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_ordered_nodes Ran
ran; our contract draft was wrong, not the code
swarnaHub/ExplaGraphs/structured_model/run_joint_model.py
code served (permissive licence) · get_code("37df5c72a313ced5")
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 2, 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.

class DevExample:
    def __init__(self, belief, node_label_internal_belief, argument, node_label_internal_argument, external, node_label_external):
        self.belief = belief
        self.node_label_internal_belief = node_label_internal_belief
        self.argument = argument
        self.node_label_internal_argument = node_label_internal_argument
        self.external = external
        self.node_label_external = node_label_external

dev_example_1 = DevExample(
    belief=['The', 'quick', 'brown', 'fox'],
    node_label_internal_belief=['B-N', 'I-N', 'O', 'O'],
    argument=['jumps', 'over', 'the', 'fence'],
    node_label_internal_argument=['B-N', 'O', 'O', 'B-N'],
    external=['a', 'lazy', 'dog'],
    node_label_external=['O', 'B-N', 'I-N']
)

dev_example_2 = DevExample(
    belief=['cat', 'sits', 'on', 'mat'],
    node_label_internal_belief=['B-N', 'O', 'O', 'B-N'],
    argument=['here', 'now', 'there'],
    node_label_internal_argument=['B-N', 'I-N', 'O'],
    external=['silent', 'black', 'creature'],
    node_label_external=['B-N', 'I-N', 'I-N']
)

dev_examples = [dev_example_1, dev_example_2]

ARGS = {
    'dev_examples': dev_examples
}
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 2, 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
get_word_start_indices Ran
ran; our contract draft was wrong, not the code
swarnaHub/ExplaGraphs/structured_model/utils_joint_model.py
code served (permissive licence) · get_code("2129f6ffd65a1a1c")
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. 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 transformers import AutoTokenizer

torch.manual_seed(0)

# Define a minimal Example class that has 'belief' and 'argument' attributes
class Example:
    def __init__(self, belief, argument):
        self.belief = belief
        self.argument = argument

# Create a minimal tokenizer stand-in that has a tokenize method
class MinimalTokenizer:
    def tokenize(self, word):
        # Simple tokenization: split on common boundaries
        # Return a list of tokens
        if word == "hello":
            return ["hel", "lo"]
        elif word == "world":
            return ["world"]
        elif word == "test":
            return ["test"]
        elif word == "example":
            return ["ex", "am", "ple"]
        else:
            return [word] if word else []

# Create example instances
example1 = Example(
    belief=["hello", "world"],
    argument=["test", "example"]
)

example2 = Example(
    belief=["foo", "bar"],
    argument=["baz"]
)

examples = [example1, example2]

# Create tokenizer
tokenizer = MinimalTokenizer()

# Define tokens
cls_token = "[CLS]"
sep_token = "[SEP]"

ARGS = {
    "examples": examples,
    "tokenizer": tokenizer,
    "cls_token": cls_token,
    "sep_token": sep_token
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list 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
merge_nodes Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
swarnaHub/ExplaGraphs/structured_model/inference.py
code served (permissive licence) · get_code("fee75f7824a0d78e")
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 numpy as np

# Construct arguments for merge_nodes function
# The function takes 4 parameters:
# 1. no_edge_prob: 2D numpy array (will be indexed/deleted along axes 0,1)
# 2. max_edge_prob: 2D numpy array (will be indexed/deleted along axes 0,1)
# 3. max_edge_index: 2D numpy array (will be indexed/deleted along axes 0,1)
# 4. ordered_nodes: list of nodes (values that can be compared for membership)

# Create a scenario where some nodes are duplicated to trigger the removal logic
# We'll have 4 nodes total, with node 2 appearing twice (at indices 1 and 3)
ordered_nodes = [0, 2, 1, 2]

# Create 2D arrays with shape (4, 4) - will be reduced to (3, 3) after removing index 3
no_edge_prob = np.array([
    [0.1, 0.2, 0.3, 0.4],
    [0.2, 0.1, 0.25, 0.35],
    [0.3, 0.25, 0.1, 0.3],
    [0.4, 0.35, 0.3, 0.1]
], dtype=np.float32)

max_edge_prob = np.array([
    [0.9, 0.8, 0.7, 0.6],
    [0.8, 0.9, 0.75, 0.65],
    [0.7, 0.75, 0.9, 0.7],
    [0.6, 0.65, 0.7, 0.9]
], dtype=np.float32)

max_edge_index = np.array([
    [1, 2, 3, 4],
    [2, 1, 5, 6],
    [3, 5, 1, 7],
    [4, 6, 7, 1]
], dtype=np.int32)

ARGS = {
    "no_edge_prob": no_edge_prob,
    "max_edge_prob": max_edge_prob,
    "max_edge_index": max_edge_index,
    "ordered_nodes": ordered_nodes
}
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 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
compute_metrics Not yet run
unverified (harvested, no recorded run)
swarnaHub/ExplaGraphs/src/utils_stance_pred.py
code served (permissive licence) · get_code("efbd217b0bee225c")
How it ran

no invocation recorded.

simple_accuracy Not yet run
unverified (harvested, no recorded run)
swarnaHub/ExplaGraphs/structured_model/utils_joint_model.py
code served (permissive licence) · get_code("3c241ecfe3749a6d")
How it ran

no invocation recorded.

solve_LP Not yet run
unverified (harvested, no recorded run)
swarnaHub/ExplaGraphs/structured_model/inference.py
code served (permissive licence) · get_code("c60db90202654db9")
How it ran

no invocation recorded.

solve_LP_no_connectivity Not yet run
unverified (harvested, no recorded run)
swarnaHub/ExplaGraphs/structured_model/inference.py
code served (permissive licence) · get_code("2115b04d3c3dbd22")
How it ran

no invocation recorded.

Also present in other papers' code

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

FunctionAlso present inEarliest-datedOthers named
simple_accuracy 59 other papers
26 dated earlier, 2 the same month, 31 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

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

Recent commonsense-reasoning tasks are typically discriminative in nature, where a model answers a multiple-choice question for a certain context. Discriminative tasks are limiting because they fail to adequately evaluate the model's ability to reason and explain predictions with underlying commonsense knowledge. They also allow such models to use reasoning shortcuts and not be "right for the right reasons". In this work, we present EX-PLAGRAPHS, a new generative and structured commonsense-reasoning task (and an associated dataset) of explanation graph generation for stance prediction. Specifically, given a belief and an argument, a model has to predict if the argument supports or counters the belief and also generate a commonsense-augmented graph that serves as non-trivial, complete, and unambiguous explanation for the predicted stance. We collect explanation graphs through a novel Create-Verify-And-Refine graph collection framework that improves the graph quality (up to 90%) via multiple rounds of verification and refinement. A significant 79% of our graphs contain external commonsense nodes with diverse structures and reasoning depths. Next, we propose a multi-level evaluation framework, consisting of automatic metrics and human evaluation, that check for the structural and semantic correctness of the generated graphs and their degree of match with ground-truth graphs. Finally, we present several structured, commonsense-augmented, and text generation models as strong starting points for this explanation graph generation task, and observe that there is a large gap with human performance, thereby encouraging future work for this new challenging task. 1

For agents

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

get_harvested_code_for_paper("2104.07644")
get_code_for_paper("2104.07644")
have("2104.07644")

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

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

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

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

Connect an agent — have() is free.