SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.09048 · 2023

CodeKGC: Code Language Model for Generative Knowledge Graph Construction

arXiv · PDF · Open in the Atlas

Code that ran

14 of 16 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 12 have 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/2304.09048.json · badge: /api/ran/2304.09048.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
zjunlp/DeepKE canonical (classifier label)
classifier basis: census
14 ran · 2 no recorded run
FunctionStatusWhere it lives
chunks Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/relation_extraction/document/prepro.py
code served (permissive licence) · get_code("b6545335b7f399a2")
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 int; 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

torch.manual_seed(0)

# The function chunks() takes a list l and splits it into chunks of size n.
# It asserts that each chunk has exactly length n.
# For this to work without assertion errors, len(l) must be divisible by n.

l = [1, 2, 3, 4, 5, 6, 7, 8]  # length 8
n = 2  # chunk size; 8 is divisible by 2

ARGS = {
    "l": l,
    "n": n,
}
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 2, dtype family int — 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
collate_fn Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/relation_extraction/document/utils.py
code served (permissive licence) · get_code("20c8771d9d2aae90")
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 torch

torch.manual_seed(0)

# Build a batch of sample data
# Each item in the batch is a dict with 'input_ids', 'entity_pos', 'labels', 'hts'
batch = [
    {
        'input_ids': [101, 2054, 2003],
        'entity_pos': [[0, 1], [2, 3]],
        'labels': [1, 0],
        'hts': [[0, 1], [1, 2]]
    },
    {
        'input_ids': [101, 2054],
        'entity_pos': [[0, 2]],
        'labels': [2],
        'hts': [[0, 1]]
    }
]

ARGS = {
    'batch': batch
}
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 — 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
collate_fn_sample Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/relation_extraction/document/utils.py
code served (permissive licence) · get_code("53be30fa2bb69d92")
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 torch
import random

torch.manual_seed(0)
random.seed(0)

# Create sample batch items
# Each item needs: input_ids, entity_pos, pos_hts, pos_labels, neg_hts, neg_labels
batch_item_1 = {
    'input_ids': [101, 2054, 2003],
    'entity_pos': [[0, 1], [2, 3]],
    'pos_hts': [(0, 1)],
    'pos_labels': [1],
    'neg_hts': [(0, 2), (1, 2), (0, 3), (1, 3)] * 10,
    'neg_labels': [0] * 40,
}

batch_item_2 = {
    'input_ids': [101, 2054, 2003, 2000],
    'entity_pos': [[0, 1], [2, 3]],
    'pos_hts': [(1, 2)],
    'pos_labels': [2],
    'neg_hts': [(0, 1), (0, 2), (1, 1), (2, 3)] * 12,
    'neg_labels': [0] * 48,
}

batch = [batch_item_1, batch_item_2]

ARGS = {
    'batch': batch,
}
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 — 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
find_head_idx Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/triple_extraction/PRGC/dataloader_utils.py
code served (permissive licence) · get_code("6adefb5e4abb5be2")
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

torch.manual_seed(0)

# The function find_head_idx searches for a target sequence within a source sequence
# and returns the index where target is found, or -1 if not found.
# Both parameters should be sequences (lists, tuples, or similar) that support:
# - len() operation
# - slicing with [i:j]
# - equality comparison with ==

# Create simple list-based test data
source = [1, 2, 3, 4, 5, 6, 7, 8]
target = [4, 5, 6]

ARGS = {
    "source": source,
    "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 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
gen_train_facts Ran
ran; our contract draft was wrong, not the code
zjunlp/DeepKE/src/deepke/relation_extraction/document/evaluation.py
pointer only (licence: MIT); the stored copy get_code serves, from wzhouad/ATLOP, is pointer only (licence: NONE) · get_code("705aa67db81dcc32")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from wzhouad/ATLOP, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_labels Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/relation_extraction/few_shot/generate_k_shot.py
code served (permissive licence) · get_code("0858952626966671")
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 tempfile
import os

# Create a temporary directory and file for testing
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test_labels.txt")

# Write sample data to the file
# The function uses eval() on each line, so we write Python-evaluable strings
with open(temp_file, 'w') as f:
    f.write("{'label': 'relation_type_1', 'id': 0}\n")
    f.write("{'label': 'relation_type_2', 'id': 1}\n")
    f.write("{'label': 'no_relation', 'id': 2}\n")

# Define the arguments dictionary
ARGS = {
    'path': temp_dir,
    'name': 'test_labels.txt',
    'negative_label': 'no_relation'
}
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_metrics Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/triple_extraction/PRGC/evaluate.py
code served (permissive licence) · get_code("626bdc34ef9914c2")
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

torch.manual_seed(0)

# The function get_metrics takes three numeric parameters and computes
# precision, recall, and F1 score metrics.
# It uses only basic arithmetic operations on the inputs.

correct_num = 45
predict_num = 50
gold_num = 60

ARGS = {
    'correct_num': correct_num,
    'predict_num': predict_num,
    'gold_num': gold_num
}
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 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
multilabel_categorical_crossentropy Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/relation_extraction/document/losses.py
code served (permissive licence) · get_code("9f47bb60899af064")
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 float, 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)

# Create small tensors for multilabel classification
# batch_size=2, num_classes=4
batch_size = 2
num_classes = 4

# y_true: binary labels (0 or 1), shape (batch_size, num_classes)
y_true = torch.tensor([
    [1, 0, 1, 0],
    [0, 1, 1, 0]
], dtype=torch.float32)

# y_pred: raw predictions (no activation), shape (batch_size, num_classes)
y_pred = torch.randn(batch_size, num_classes, dtype=torch.float32)

ARGS = {
    'y_true': y_true,
    'y_pred': y_pred
}
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 float, 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
official_evaluate Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/relation_extraction/document/evaluation.py
code served (permissive licence) · get_code("fd5637cef4c93295")
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 os
import json
import tempfile
import shutil

# Create a temporary directory for the test
temp_dir = tempfile.mkdtemp()

# Create the 'ref' directory
ref_dir = os.path.join(temp_dir, 'ref')
os.makedirs(ref_dir, exist_ok=True)

# Create train_annotated.json
train_annotated_data = [
    {
        'vertexSet': [
            [{'name': 'entity1'}],
            [{'name': 'entity2'}]
        ],
        'labels': [
            {
                'h': 0,
                't': 1,
                'r': 'relation1',
                'evidence': [0]
            }
        ]
    }
]
train_annotated_path = os.path.join(temp_dir, 'train_annotated.json')
with open(train_annotated_path, 'w') as f:
    json.dump(train_annotated_data, f)

# Create train_distant.json
train_distant_data = [
    {
        'vertexSet': [
            [{'name': 'entity1'}],
            [{'name': 'entity2'}]
        ],
        'labels': [
            {
                'h': 0,
                't': 1,
                'r': 'relation1',
                'evidence': [0]
            }
        ]
    }
]
train_distant_path = os.path.join(temp_dir, 'train_distant.json')
with open(train_distant_path, 'w') as f:
    json.dump(train_distant_data, f)

# Create dev.json
dev_data = [
    {
        'title': 'doc1',
        'vertexSet': [
            [{'name': 'entity1'}],
            [{'name': 'entity2'}]
        ],
        'labels': [
            {
                'h': 0,
                't': 1,
                'r': 'relation1',
                'evidence': [0]
            }
        ]
    }
]
dev_path = os.path.join(temp_dir, 'dev.json')
with open(dev_path, 'w') as f:
    json.dump(dev_data, f)

# Create tmp (submission answer)
tmp = [
    {
        'title': 'doc1',
        'h_idx': 0,
        't_idx': 1,
        'r': 'relation1',
        'evidence': [0]
    }
]

ARGS = {
    'tmp': tmp,
    'path': temp_dir
}
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 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
process_long_input Ran
ran; our contract draft was wrong, not the code
zjunlp/DeepKE/src/deepke/relation_extraction/document/prepro.py
code served (permissive licence) · get_code("1caea7819d2e4841")
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 torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Create a minimal model that satisfies the function's usage
class MockModel(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.hidden_size = hidden_size
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def forward(self, input_ids, attention_mask, output_attentions=False):
        # input_ids shape: (batch, seq_len)
        batch_size, seq_len = input_ids.shape
        
        # sequence_output shape: (batch, seq_len, hidden_size)
        sequence_output = torch.randn(batch_size, seq_len, self.hidden_size)
        
        # attention shape: (batch, num_heads, seq_len, seq_len)
        # Create a list of attention tensors for each layer
        attention_layers = [
            torch.randn(batch_size, 2, seq_len, seq_len)
            for _ in range(2)
        ]
        
        return (sequence_output, None, attention_layers)

# Create model
model = MockModel(hidden_size=4)

# Create small test tensors
batch_size = 2
seq_len = 600  # Larger than 512 to trigger the long input processing

# input_ids: (batch_size, seq_len)
input_ids = torch.randint(0, 1000, (batch_size, seq_len))

# attention_mask: (batch_size, seq_len)
# For first sample: 550 actual tokens, for second: 480
attention_mask = torch.ones(batch_size, seq_len)
attention_mask[0, 550:] = 0
attention_mask[1, 480:] = 0

# start_tokens: list of token ids
start_tokens = [101]  # [CLS]

# end_tokens: list of token ids
end_tokens = [102]  # [SEP]

ARGS = {
    'model': model,
    'input_ids': input_ids,
    'attention_mask': attention_mask,
    'start_tokens': start_tokens,
    'end_tokens': end_tokens,
}
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 — 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
read_examples Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/triple_extraction/PRGC/dataloader_utils.py
code served (permissive licence) · get_code("402533ae0c194b8a")
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 json
from collections import defaultdict
import os
import tempfile

# Create a temporary directory for test data
temp_dir = tempfile.mkdtemp()

# Create a sample rel2idx mapping
rel2idx = {
    'located_in': 0,
    'works_for': 1,
    'married_to': 2
}

# Create sample data file
sample_data = [
    {
        'text': 'John works for Google in California.',
        'triple_list': [
            ['John', 'works_for', 'Google'],
            ['Google', 'located_in', 'California']
        ]
    },
    {
        'text': 'Alice is married to Bob.',
        'triple_list': [
            ['Alice', 'married_to', 'Bob']
        ]
    }
]

# Write the test data file
data_file_path = os.path.join(temp_dir, 'test_triples.json')
with open(data_file_path, 'w', encoding='utf-8') as f:
    json.dump(sample_data, f)

# Define ARGS dictionary with all required parameters
ARGS = {
    'data_dir': temp_dir,
    'data_sign': 'test',
    'rel2idx': rel2idx
}
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
span2str Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/triple_extraction/PRGC/evaluate.py
code served (permissive licence) · get_code("94ab66ec54e9046e")
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.

import torch

torch.manual_seed(0)

# triples: list of tuples where each tuple contains:
#   - triple[0]: subject span (tuple with indices)
#   - triple[1]: object span (tuple with indices)
#   - triple[-1]: relation (string)
# tokens: list of token strings

triples = [
    ((0, 2), (3, 5), "relation_1"),
    ((1, 3), (4, 6), "relation_2"),
]

tokens = [
    "The",
    "quick",
    "brown",
    "fox",
    "jumps",
    "over",
    "##ly",
    "lazy",
]

ARGS = {
    "triples": triples,
    "tokens": tokens,
}
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 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
split_label_words Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/relation_extraction/few_shot/get_label_word.py
code served (permissive licence) · get_code("3e44103f6e52ca2f")
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 2, dtype family int, shape (3, 3) 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
from transformers import AutoTokenizer

torch.manual_seed(0)

# Create a minimal stand-in tokenizer that has the required methods
class MinimalTokenizer:
    def encode(self, text, add_special_tokens=False):
        # Return a list of token IDs based on text length
        return [101 + i for i in range(len(text.split()))]
    
    def __call__(self, text, add_special_tokens=False):
        # Return a dict with 'input_ids' key
        return {'input_ids': [101 + i for i in range(len(text.split()))]}

tokenizer = MinimalTokenizer()

label_list = [
    'no_relation',
    'per:location',
    'org_based_in',
]

ARGS = {
    'tokenizer': tokenizer,
    'label_list': label_list,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int, shape (3, 3) — shape (3, 3) 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
to_official Ran
ran on a synthesized input
zjunlp/DeepKE/src/deepke/relation_extraction/document/evaluation.py
code served (permissive licence) · get_code("25620f5a71d51a9f")
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 json
import numpy as np
import tempfile
import os

# Create a temporary directory and necessary files
temp_dir = tempfile.mkdtemp()

# Create rel2id.json file
rel2id = {
    "NA": 0,
    "relation1": 1,
    "relation2": 2,
    "relation3": 3
}
rel2id_path = os.path.join(temp_dir, 'rel2id.json')
with open(rel2id_path, 'w') as f:
    json.dump(rel2id, f)

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

args = Args(temp_dir)

# Create preds - shape (2, 4) with some nonzero values
preds = np.array([
    [0, 1, 0, 2],  # First sample: predictions for relations 1 and 3
    [0, 0, 1, 0]   # Second sample: prediction for relation 2
], dtype=np.float32)

# Create features - list of 2 feature dicts
features = [
    {
        'hts': [[0, 1], [2, 3]],  # Two head-tail pairs
        'title': 'doc1'
    },
    {
        'hts': [[1, 2]],  # One head-tail pair
        'title': 'doc2'
    }
]

ARGS = {
    'args': args,
    'preds': preds,
    'features': features
}
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 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 Not yet run
unverified (harvested, no recorded run)
zjunlp/DeepKE/src/deepke/triple_extraction/PRGC/dataloader_utils.py
code served (permissive licence) · get_code("859f514ce96f405e")
How it ran

no invocation recorded.

evaluate Not yet run
unverified (harvested, no recorded run)
zjunlp/DeepKE/src/deepke/triple_extraction/PRGC/evaluate.py
code served (permissive licence) · get_code("7b0a68af7010382a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 16 samples lifted from this paper's linked repositories, 16 carry a function identity and 0 do not. Of the 16 distinct functions with an identity, 6 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 2 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
process_long_input 3 other papers
2 later, 1 same year, order not determinable
2023.findings-emnlp.253 (2023 (year only))
Adaptive Hinge Balance Loss for Document-Level Relation Extraction
2306.11386 (2023-06)
Did the Models Understand Documents? Benchmarking Models for Language Understanding in Document-Level Relation Extraction
2025.findings-acl.727 (2025 (year only))
GLiM: Integrating Graph Transformer and LLM for Document-Level Biomedical Relation Extraction with Incomplete Labeling
gen_train_facts 2 other papers
1 dated earlier, 1 later
2010.11304 (2020-10)
Document-Level Relation Extraction with Adaptive Thresholding and Localized Context Pooling
2025.findings-acl.727 (2025 (year only))
GLiM: Integrating Graph Transformer and LLM for Document-Level Biomedical Relation Extraction with Incomplete Labeling
chunks 1 other paper
1 same year, order not determinable
2023.findings-emnlp.253 (2023 (year only))
Adaptive Hinge Balance Loss for Document-Level Relation Extraction
find_head_idx 1 other paper
1 dated earlier
2210.10709 (2022-10)
Schema-aware Reference as Prompt Improves Data-Efficient Knowledge Graph Construction
get_metrics 1 other paper
1 dated earlier
2210.10709 (2022-10)
Schema-aware Reference as Prompt Improves Data-Efficient Knowledge Graph Construction
span2str 1 other paper
1 dated earlier
2210.10709 (2022-10)
Schema-aware Reference as Prompt Improves Data-Efficient Knowledge Graph Construction

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

Current generative knowledge graph construction approaches usually fail to capture structural knowledge by simply flattening natural language into serialized texts or a specification language. However, large generative language model trained on structured data such as code has demonstrated impressive capability in understanding natural language for structural prediction and reasoning tasks. Intuitively, we address the task of generative knowledge graph construction with code language model: given a code-format natural language input, the target is to generate triples which can be represented as code completion tasks. Specifically, we develop schema-aware prompts that effectively utilize the semantic structure within the knowledge graph. As code inherently possesses structure, such as class and function definitions, it serves as a useful model for prior semantic structural knowledge. Furthermore, we employ a rationale-enhanced generation method to boost the performance. Rationales provide intermediate steps, thereby improving knowledge extraction abilities. Experimental results indicate that the proposed approach can obtain better performance on benchmark datasets compared with baselines. Code and datasets are available in https://github.com/zjunlp/DeepKE/tree/main/example/llm.

For agents

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

get_harvested_code_for_paper("2304.09048")
get_code_for_paper("2304.09048")
have("2304.09048")

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

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

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

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

Connect an agent — have() is free.