SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2022.findings-emnlp.96 · EMNLP Findings · 2022

MICO: A Multi-alternative Contrastive Learning Framework for Commonsense Knowledge Representation

Tong Zhang, Hkust, Zihao Wang, Yangqiu Song, Hongming Zhang, Tianqing Fang, Ying Su

Open in the Atlas

Code that ran

7 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; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-24; 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/2022.findings-emnlp.96.json · badge: /api/ran/2022.findings-emnlp.96.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
BinWang28/InductivE canonical (classifier label)
classifier basis: census
7 ran · 3 no recorded run
FunctionStatusWhere it lives
get_adj_and_degrees Ran
ran on a synthesized input
BinWang28/InductivE/src/utils.py
code served (permissive licence) · get_code("160c374d23b50018")
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
from scipy.sparse import coo_matrix

# Construct arguments for get_adj_and_degrees
num_nodes = 5
num_rels = 3
triplets = [
    [0, 0, 1],  # subject=0, relation=0, object=1
    [1, 1, 2],  # subject=1, relation=1, object=2
    [2, 2, 3],  # subject=2, relation=2, object=3
    [3, 0, 4],  # subject=3, relation=0, object=4
]

ARGS = {
    "num_nodes": num_nodes,
    "num_rels": num_rels,
    "triplets": triplets,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — 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
get_filtered_ranks Ran
ran on a synthesized input
BinWang28/InductivE/src/evaluation_utils.py
code served (permissive licence) · get_code("973da3b6d17a8a2a")
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 1, dtype family int, shape (2,) 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)

# score: (batch_size, num_entities) - scores for each entity
# target: (batch_size,) - target entity indices
# batch_a: (batch_size,) - first indices for the multi_e2 lookup
# batch_r: (batch_size,) - second indices for the multi_e2 lookup
# e1_to_multi_e2: dict-like mapping (batch_a[i], batch_r[i]) -> set/list of entity indices

batch_size = 2
num_entities = 4

score = torch.randn(batch_size, num_entities)
target = torch.tensor([1, 2])
batch_a = torch.tensor([0, 1])
batch_r = torch.tensor([0, 1])

# e1_to_multi_e2 is a 2D dictionary-like structure
# It maps (batch_a[i], batch_r[i]) to a set/list of entities that includes target[i]
class MultiE2Dict:
    def __init__(self):
        self.data = {}
    
    def __getitem__(self, key):
        return self.data[key]

e1_to_multi_e2 = MultiE2Dict()
# For batch_a[0]=0, batch_r[0]=0, target[0]=1, include 1 in filter_ents
e1_to_multi_e2.data[(0, 0)] = [0, 1, 3]  # includes target[0]=1
# For batch_a[1]=1, batch_r[1]=1, target[1]=2, include 2 in filter_ents
e1_to_multi_e2.data[(1, 1)] = [1, 2, 3]  # includes target[1]=2

ARGS = {
    "score": score,
    "target": target,
    "batch_a": batch_a,
    "batch_r": batch_r,
    "e1_to_multi_e2": e1_to_multi_e2,
}
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 1, dtype family int, shape (2,) — shape (2,) 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
get_relation_id Ran
ran on a synthesized input
BinWang28/InductivE/src/reader_utils.py
code served (permissive licence) · get_code("2597c79e8195b257")
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 int, ndim 0, dtype family int, 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

class MockGraph:
    def __init__(self):
        self.relations = {"relation_0": 0, "relation_1": 1, "relation_2": 2}
    
    def find_relation(self, rel_name):
        if rel_name in self.relations:
            return self.relations[rel_name]
        else:
            return -1

class MockNetwork(nn.Module):
    def __init__(self):
        super().__init__()
        self.graph = MockGraph()
        self.rel2id = {"relation_0": 0, "relation_1": 1, "relation_2": 2, "relation_3": 3}
    
    def forward(self, x):
        return x

torch.manual_seed(0)

train_network = MockNetwork()
rel_name = "relation_0"

ARGS = {
    "rel_name": rel_name,
    "train_network": train_network
}
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 int, ndim 0, dtype family int, 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
get_vocab_idx Ran
ran on a synthesized input
BinWang28/InductivE/src/reader_utils.py
code served (permissive licence) · get_code("5a26e3880ee60f5b")
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 int, ndim 0, dtype family int, 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

# Construct a vocabulary dictionary
vocab = {
    'hello': 0,
    'world': 1,
    'python': 2,
    'test': 3,
    'UNK': 4
}

# Construct arguments for get_vocab_idx
ARGS = {
    'vocab': vocab,
    'token': 'hello'
}
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 int, ndim 0, dtype family int, 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
prepare_batch_dgl Ran
ran on a synthesized input
BinWang28/InductivE/src/reader_utils.py
code served (permissive licence) · get_code("4888009f0620467f")
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

class Node:
    def __init__(self, name):
        self.name = name

class Relation:
    def __init__(self, name):
        self.name = name

class Edge:
    def __init__(self, src, tgt, relation, label):
        self.src = src
        self.tgt = tgt
        self.relation = relation
        self.label = label

class Graph:
    def __init__(self, edges):
        self.edges = edges
        self.relations = {}
    
    def iter_edges(self):
        return iter(self.edges)
    
    def find_relation(self, rel_name):
        return self.relations.get(rel_name, -1)

class Network:
    def __init__(self, graph, rel2id):
        self.graph = graph
        self.rel2id = rel2id

# Create test network
test_edges = [
    Edge(Node("alice"), Node("bob"), Relation("knows"), 1),
    Edge(Node("bob"), Node("charlie"), Relation("likes"), 0),
]
test_graph = Graph(test_edges)
test_network = Network(test_graph, {})

# Create train network
train_edges = [
    Edge(Node("alice"), Node("bob"), Relation("knows"), 1),
]
train_graph = Graph(train_edges)
train_graph.relations = {"knows": 0, "likes": 1}
train_network = Network(train_graph, {"knows": 0, "likes": 1})

# Create vocab
vocab = {
    "alice": 0,
    "bob": 1,
    "charlie": 2,
    "UNK": 3,
}

ARGS = {
    "vocab": vocab,
    "test_network": test_network,
    "train_network": train_network,
}
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
ranking_and_hits Ran
ran on a synthesized input
BinWang28/InductivE/src/evaluation_utils.py
code served (permissive licence) · get_code("2a81b8ecdea5409f")
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 torch
import numpy as np
from collections import defaultdict

torch.manual_seed(0)

# Build a minimal graph structure
class Node:
    def __init__(self, node_id, name):
        self.id = node_id
        self.name = name

class Relation:
    def __init__(self, rel_id, name):
        self.id = rel_id
        self.name = name

class Graph:
    def __init__(self, num_nodes=6, num_rels=3):
        self.nodes = {i: Node(i, f"node_{i}") for i in range(num_nodes)}
        self.relations = {i: Relation(i, f"rel_{i}") for i in range(num_rels)}

class Network:
    def __init__(self, num_nodes=6, num_rels=3):
        self.graph = Graph(num_nodes, num_rels)

# Build a minimal model
class MinimalModel(torch.nn.Module):
    def __init__(self, num_nodes=6, num_rels=3, embedding_dim=4):
        super().__init__()
        self.num_nodes = num_nodes
        self.num_rels = num_rels
        self.embedding_dim = embedding_dim
        self.node_embeddings = torch.nn.Embedding(num_nodes, embedding_dim)
        self.rel_embeddings = torch.nn.Embedding(num_rels * 2, embedding_dim)
    
    def forward(self, e1, rel):
        # e1: [batch_size], rel: [batch_size]
        # Output: [batch_size, num_nodes] scores
        e1_emb = self.node_embeddings(e1)  # [batch_size, embedding_dim]
        rel_emb = self.rel_embeddings(rel)  # [batch_size, embedding_dim]
        combined = e1_emb + rel_emb  # [batch_size, embedding_dim]
        all_node_emb = self.node_embeddings.weight  # [num_nodes, embedding_dim]
        scores = torch.mm(combined, all_node_emb.t())  # [batch_size, num_nodes]
        return scores

# Create arguments
num_nodes = 6
num_rels = 3
num_ent = num_nodes
num_rel_types = num_rels

# Create minimal args object
class Args:
    def __init__(self, num_rels):
        self.num_rels = num_rels

args = Args(num_rels=num_rel_types)

# Create model
model = MinimalModel(num_nodes=num_ent, num_rels=num_rel_types, embedding_dim=4)

# Create test triplets: [batch_size, 3] with (e1, rel, e2)
test_triplets = torch.LongTensor([
    [0, 0, 1],
    [1, 1, 2],
    [2, 2, 3],
    [3, 0, 4],
])

# Create e1_to_multi_e2: dictionary mapping (e1, rel) -> list of possible e2s
e1_to_multi_e2 = defaultdict(lambda: [0])
for i in range(num_ent):
    for j in range(num_rel_types * 2):
        e1_to_multi_e2[(i, j)] = [i, (i + 1) % num_ent]

# Create network
network = Network(num_nodes=num_ent, num_rels=num_rel_types)

ARGS = {
    'args': args,
    'model': model,
    'test_triplets': test_triplets,
    'e1_to_multi_e2': e1_to_multi_e2,
    'network': network,
    'write_results': False,
    'debug': True,
}
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 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
sort_and_rank Ran
ran on a synthesized input
BinWang28/InductivE/src/evaluation_utils.py
code served (permissive licence) · get_code("8353984688641dab")
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 1, dtype family int, shape (2,) 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)

# score: tensor that will be sorted along dim=1
# The function sorts scores descending and finds positions matching target values
score = torch.randn(2, 4)

# target: tensor of target indices to find in the sorted positions
# Should have shape (batch_size,) = (2,)
target = torch.tensor([1, 2])

ARGS = {
    "score": score,
    "target": target,
}
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 1, dtype family int, shape (2,) — shape (2,) 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
aggregrate Not yet run
unverified (harvested, no recorded run)
BinWang28/InductivE/src/utils.py
code served (permissive licence) · get_code("c51f0efcd581cb88")
How it ran

no invocation recorded.

load_pre_computed_feat Not yet run
unverified (harvested, no recorded run)
BinWang28/InductivE/src/utils.py
code served (permissive licence) · get_code("795730ff983882bc")
How it ran

no invocation recorded.

parse_args Not yet run
unverified (harvested, no recorded run)
BinWang28/InductivE/src/parse_args.py
code served (permissive licence) · get_code("72080ab26fd2dffe")
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, 3 are also present in other papers whose code we hold (3 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.

FunctionAlso present inEarliest-datedOthers named
get_filtered_ranks 1 other paper
1 dated earlier
1910.02915 (2019-10)
Commonsense Knowledge Base Completion with Structural and Semantic Context
get_vocab_idx 1 other paper
1 dated earlier
1910.02915 (2019-10)
Commonsense Knowledge Base Completion with Structural and Semantic Context
sort_and_rank 1 other paper
1 dated earlier
1910.02915 (2019-10)
Commonsense Knowledge Base Completion with Structural and Semantic Context

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-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Commonsense reasoning tasks such as commonsense knowledge graph completion and commonsense question answering require powerful representation learning. In this paper, we propose to learn commonsense knowledge representation by MICO, a Multi-alternative con-trastIve learning framework on COmmonsense knowledge graphs (MICO). MICO generates the commonsense knowledge representation by contextual interaction between entity nodes and relations with multi-alternative contrastive learning. In MICO, the head and tail entities in an (h, r, t) knowledge triple are converted to two relation-aware sequence pairs (a premise and an alternative) in the form of natural language. Semantic representations generated by MICO can benefit the following two tasks by simply comparing the distance score between the representations: 1) zero-shot commonsense question answering task; 2) inductive commonsense knowledge graph completion task. Extensive experiments show the effectiveness of our method.

For agents

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

get_harvested_code_for_paper("2022.findings-emnlp.96")
get_code_for_paper("2022.findings-emnlp.96")
have("2022.findings-emnlp.96")

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

curl https://syntology.ai/api/ran/2022.findings-emnlp.96.json

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

[![Syntology run record](https://syntology.ai/api/ran/2022.findings-emnlp.96.svg)](https://syntology.ai/paper/2022.findings-emnlp.96)

Connect an agent — have() is free.