SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1910.02915 · 2019

Commonsense Knowledge Base Completion with Structural and Semantic Context

arXiv · PDF · Open in the Atlas

Code that ran

10 of 12 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 9 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-24; 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/1910.02915.json · badge: /api/ran/1910.02915.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
allenai/commonsense-kg-completion community (classifier label)
classifier basis not recorded on the link
10 ran · 2 no recorded run
FunctionStatusWhere it lives
accuracy Ran
ran, honoured the contract we drafted
allenai/commonsense-kg-completion/lm_finetuning/simple_lm_finetuning.py
code served (permissive licence) · get_code("eb725d5794b15f6b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned int64, 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 numpy as np

# Create sample outputs from a model (e.g., logits for 2 samples, 5 classes)
out = np.array([
    [0.1, 0.3, 0.8, 0.2, 0.1],  # argmax = 2
    [0.9, 0.1, 0.2, 0.3, 0.05]  # argmax = 0
])

# Create corresponding labels
labels = np.array([2, 0])

ARGS = {
    'out': out,
    'labels': labels
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int64, 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
camel_case_split Ran
ran on a synthesized input
allenai/commonsense-kg-completion/src/bert_feature_extractor.py
code served (permissive licence) · get_code("420406b2e12799ee")
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 re

def camel_case_split(identifier):
    matches = re.finditer('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)', identifier)
    return ' '.join([m.group(0) for m in matches]).lower()

ARGS = {
    'identifier': 'myVariableNameExample'
}
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 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
convert_edges_to_examples Ran
ran on a synthesized input
allenai/commonsense-kg-completion/src/bert_feature_extractor.py
code served (permissive licence) · get_code("f6b73f652e22a0f7")
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 torch
import re

torch.manual_seed(0)

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

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

class Graph:
    def __init__(self):
        self.nodes = {
            0: Node("Alice"),
            1: Node("Bob"),
            2: Node("Charlie")
        }
        self.relations = {
            0: Relation("knowsWell"),
            1: Relation("worksWith")
        }

class Network:
    def __init__(self):
        self.graph = Graph()

edges = torch.tensor([
    [0, 0, 1],
    [1, 1, 2]
], dtype=torch.long)

labels = torch.tensor([1, 0], dtype=torch.long)

network = Network()

ARGS = {
    "edges": edges,
    "labels": labels,
    "network": 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 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_example_to_features Ran
ran on a synthesized input
allenai/commonsense-kg-completion/lm_finetuning/simple_lm_finetuning.py
code served (permissive licence) · get_code("e44321eb9fe5de7a")
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 InputFeatures. 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 logging
import random

# Set seed for reproducibility
random.seed(0)

# Create a minimal tokenizer stand-in class
class MinimalTokenizer:
    def __init__(self):
        # vocab: token string -> id mapping
        self.vocab = {
            '[CLS]': 101,
            '[SEP]': 102,
            '[MASK]': 103,
            '[UNK]': 100,
            'hello': 1,
            'world': 2,
            'this': 3,
            'is': 4,
            'a': 5,
            'test': 6,
            'sample': 7,
            'sentence': 8,
        }
    
    def convert_tokens_to_ids(self, tokens):
        """Convert list of tokens to list of token IDs"""
        ids = []
        for token in tokens:
            if token in self.vocab:
                ids.append(self.vocab[token])
            else:
                ids.append(self.vocab['[UNK]'])
        return ids

# Create a minimal InputExample stand-in class
class InputExample:
    def __init__(self, guid, tokens_a, tokens_b, is_next):
        self.guid = guid
        self.tokens_a = tokens_a
        self.tokens_b = tokens_b
        self.is_next = is_next

# Create example data
example = InputExample(
    guid=1,
    tokens_a=['hello', 'world', 'this'],
    tokens_b=['is', 'a', 'test'],
    is_next=1
)

tokenizer = MinimalTokenizer()
max_seq_length = 16

ARGS = {
    'example': example,
    'max_seq_length': max_seq_length,
    'tokenizer': tokenizer,
}
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 InputFeatures — a InputFeatures output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a InputFeatures 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
create_vocab Ran
ran on a synthesized input
allenai/commonsense-kg-completion/src/reader_utils.py
code served (permissive licence) · get_code("4916801754517961")
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, 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 torch
import numpy as np

# Create a minimal graph-like object with iter_nodes() method
class Node:
    def __init__(self, name):
        self.name = name

class Graph:
    def __init__(self, nodes):
        self.nodes = nodes
    
    def iter_nodes(self):
        return iter(self.nodes)

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

# Create sample nodes with distinct names
nodes = [
    Node("word1"),
    Node("word2"),
    Node("word1"),  # Duplicate to test frequency counting
    Node("word3"),
]

graph = Graph(nodes)
network = Network(graph)

ARGS = {
    "network": network
}
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 tuple, ndim 1, dtype family float — a tuple 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
create_word_vocab Ran
ran on a synthesized input
allenai/commonsense-kg-completion/src/reader_utils.py
code served (permissive licence) · get_code("6c5d6cb16e3275c2")
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, 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 torch
import torch.nn as nn

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

class MockGraph:
    def __init__(self, nodes):
        self.nodes = nodes
    
    def iter_nodes(self):
        return iter(self.nodes)

class MockNetwork(nn.Module):
    def __init__(self):
        super().__init__()
        self.graph = MockGraph([
            MockNode("hello world"),
            MockNode("hello python"),
            MockNode("world of networks"),
            MockNode("test node"),
        ])

network = MockNetwork()

ARGS = {
    'network': 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 tuple, ndim 1, dtype family float — a tuple 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_filtered_ranks Ran
ran on a synthesized input
allenai/commonsense-kg-completion/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_vocab_idx Ran
ran on a synthesized input
allenai/commonsense-kg-completion/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
random_word Ran
ran on a synthesized input
allenai/commonsense-kg-completion/lm_finetuning/simple_lm_finetuning.py
code served (permissive licence) · get_code("c247b25173d2c822")
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, 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.

import random
import logging

logger = logging.getLogger(__name__)

class MockTokenizer:
    def __init__(self):
        self.vocab = {
            '[MASK]': 0,
            '[UNK]': 1,
            'hello': 2,
            'world': 3,
            'test': 4,
            'token': 5,
        }

random.seed(42)

tokens = ['hello', 'world', 'test']
tokenizer = MockTokenizer()

ARGS = {
    'tokens': tokens,
    'tokenizer': tokenizer,
}
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 tuple, ndim 2, dtype family float — a tuple 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
sort_and_rank Ran
ran on a synthesized input
allenai/commonsense-kg-completion/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
convert_examples_to_features Not yet run
unverified (harvested, no recorded run)
allenai/commonsense-kg-completion/src/bert_feature_extractor.py
code served (permissive licence) · get_code("8670d7299e3756ce")
How it ran

no invocation recorded.

perturb_and_get_rank Not yet run
unverified (harvested, no recorded run)
allenai/commonsense-kg-completion/src/evaluation_utils.py
code served (permissive licence) · get_code("fc6caabfdb1a495d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 4 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 1 the same month, 4 later) and 8 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
accuracy 21 other papers
15 dated earlier, 1 the same month, 5 later
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1901.08746 (2019-01)
BioBERT: a pre-trained biomedical language representation model for biomedical text mining
1904.03323 (2019-04)
Publicly Available Clinical BERT Embeddings
and 18 more not named here
get_filtered_ranks 1 other paper
1 later
2022.findings-emnlp.96 (2022 (year only))
MICO: A Multi-alternative Contrastive Learning Framework for Commonsense Knowledge Representation
get_vocab_idx 1 other paper
1 later
2022.findings-emnlp.96 (2022 (year only))
MICO: A Multi-alternative Contrastive Learning Framework for Commonsense Knowledge Representation
sort_and_rank 1 other paper
1 later
2022.findings-emnlp.96 (2022 (year only))
MICO: A Multi-alternative Contrastive Learning Framework for Commonsense Knowledge Representation

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

Automatic KB completion for commonsense knowledge graphs (e.g., ATOMIC and ConceptNet) poses unique challenges compared to the much studied conventional knowledge bases (e.g., Freebase). Commonsense knowledge graphs use free-form text to represent nodes, resulting in orders of magnitude more nodes compared to conventional KBs (18x more nodes in ATOMIC compared to Freebase (FB15K-237)). Importantly, this implies significantly sparser graph structures - a major challenge for existing KB completion methods that assume densely connected graphs over a relatively smaller set of nodes. In this paper, we present novel KB completion models that can address these challenges by exploiting the structural and semantic context of nodes. Specifically, we investigate two key ideas: (1) learning from local graph structure, using graph convolutional networks and automatic graph densification and (2) transfer learning from pre-trained language models to knowledge graphs for enhanced contextual representation of knowledge. We describe our method to incorporate information from both these sources in a joint model and provide the first empirical results for KB completion on ATOMIC and evaluation with ranking metrics on ConceptNet. Our results demonstrate the effectiveness of language model representations in boosting link prediction performance and the advantages of learning from local graph structure (+1.5 points in MRR for ConceptNet) when training on subgraphs for computational efficiency. Further analysis on model predictions shines light on the types of commonsense knowledge that language models capture well.

For agents

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

get_harvested_code_for_paper("1910.02915")
get_code_for_paper("1910.02915")
have("1910.02915")

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

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

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

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

Connect an agent — have() is free.