SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.10709 · 2022

Schema-aware Reference as Prompt Improves Data-Efficient Knowledge Graph Construction

arXiv · PDF · Open in the Atlas

Code that ran

10 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 9 have no contract verdict; 1 failure of our instrument; 1 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/2210.10709.json · badge: /api/ran/2210.10709.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/RAP canonical (classifier label)
classifier basis not recorded on the link
10 ran · 1 no recorded run
FunctionStatusWhere it lives
find_head_idx Ran
ran on a synthesized input
zjunlp/RAP/BaseModel/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
find_sublist_index Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
zjunlp/RAP/BaseModel/RelationPrompt/utils.py
code served (permissive licence) · get_code("97a3eca137c3440e")
How it ran

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

torch.manual_seed(0)

# The function find_sublist_index takes two parameters:
# - items: a list to search within
# - query: a list to search for as a sublist
# 
# The function iterates through items looking for a contiguous sublist
# that matches query exactly using list equality comparison.

ARGS = {
    "items": [1, 2, 3, 4, 5, 6, 7, 8],
    "query": [4, 5, 6]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, 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
find_sublist_indices Ran
ran on a synthesized input
zjunlp/RAP/BaseModel/RelationPrompt/utils.py
code served (permissive licence) · get_code("489e40f0d2ef6927")
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 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
import numpy as np

# Test case 1: Find sublist in a list of integers
items_1 = [1, 2, 3, 4, 5, 3, 4, 6]
query_1 = [3, 4]

# Test case 2: Query not in items
items_2 = [1, 2, 3, 4, 5]
query_2 = [7, 8]

# Test case 3: Single element query
items_3 = [10, 20, 30, 40]
query_3 = [30]

# Test case 4: Query at the beginning
items_4 = [5, 6, 7, 8, 9]
query_4 = [5, 6]

# Test case 5: Empty query (edge case)
items_5 = [1, 2, 3]
query_5 = []

ARGS = {
    "items": items_1,
    "query": query_1
}
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 list, ndim 1, 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
get_chunk_type Ran
ran on a synthesized input
zjunlp/RAP/BaseModel/PRGC/metrics.py
code served (permissive licence) · get_code("9d4067b23a01fee1")
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

torch.manual_seed(0)

# Build idx_to_tag dictionary mapping token IDs to BIO tags
idx_to_tag = {
    0: "O",
    1: "B-PER",
    2: "I-PER",
    3: "B-LOC",
    4: "I-LOC",
    5: "B-ORG",
}

# Define arguments for get_chunk_type
ARGS = {
    "tok": 1,
    "idx_to_tag": idx_to_tag,
}
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_chunks Ran
ran on a synthesized input
zjunlp/RAP/BaseModel/PRGC/metrics.py
code served (permissive licence) · get_code("68b3cc3a2577fbd6")
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 numpy as np

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

# Define the arguments for get_chunks function
seq = np.array([4, 5, 0, 0, 3, 5, 0])

tags = {
    "O": 0,
    "B-PER": 4,
    "I-PER": 5,
    "B-LOC": 3
}

ARGS = {
    "seq": seq,
    "tags": tags
}
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 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_metrics Ran
ran on a synthesized input
zjunlp/RAP/BaseModel/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
load_wiki_relation_map Ran
ran on a synthesized input
zjunlp/RAP/BaseModel/RelationPrompt/utils.py
code served (permissive licence) · get_code("0b33d061e8b7d42d")
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 pandas as pd
import tempfile
import os

# Create a temporary CSV file with sample WikiProperty data
temp_dir = tempfile.gettempdir()
csv_path = os.path.join(temp_dir, "wiki_properties_test.csv")

# Create sample data that matches WikiProperty fields
sample_data = {
    'p': ['http://www.wikidata.org/entity/P1', 'http://www.wikidata.org/entity/P2'],
    'pType': ['wikibase:WikibaseItem', 'wikibase:String'],
    'pLabel': ['instance of', 'name'],
    'pDescription': ['that class of which this subject is a particular example and member', 'the name by which someone is known'],
    'pAltLabel': ['is a, is an', 'given name, full name']
}

df = pd.DataFrame(sample_data)
df.to_csv(csv_path, index=False)

ARGS = {
    'path': csv_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, pydantic — 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
read_examples Ran
ran on a synthesized input
zjunlp/RAP/BaseModel/PRGC/dataloader_utils.py
code served (permissive licence) · get_code("7edec986d793594c")
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
from pathlib import Path
import tempfile
import os

class InputExample(object):
    """a single set of samples of data
    """

    def __init__(self, text, en_pair_list, re_list, rel2ens):
        self.text = text
        self.en_pair_list = en_pair_list
        self.re_list = re_list
        self.rel2ens = rel2ens

# Create a temporary directory with test data
temp_dir = tempfile.mkdtemp()
data_dir = Path(temp_dir)

# Create sample data file
sample_data = [
    {
        "text": "Barack Obama was born in Hawaii",
        "triple_list": [
            ["Barack Obama", "birthPlace", "Hawaii"],
            ["Barack Obama", "nationality", "American"]
        ]
    },
    {
        "text": "Paris is the capital of France",
        "triple_list": [
            ["Paris", "capitalOf", "France"],
            ["France", "location", "Europe"]
        ]
    }
]

# Write the test data to file
with open(data_dir / 'train_triples.json', 'w', encoding='utf-8') as f:
    json.dump(sample_data, f)

# Create relation to index mapping
rel2idx = {
    "birthPlace": 0,
    "nationality": 1,
    "capitalOf": 2,
    "location": 3
}

ARGS = {
    "data_dir": data_dir,
    "data_sign": "train",
    "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/RAP/BaseModel/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
tag_mapping_nearest Ran
ran on a synthesized input
zjunlp/RAP/BaseModel/PRGC/metrics.py
code served (permissive licence) · get_code("b38b4069b22679d0")
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 numpy as np

# Construct predict_tags: shape (rel_num, 2, max_sen_len)
# rel_num = 3, max_sen_len = 5
predict_tags = np.array([
    # First relation: [subject_tags, object_tags]
    [[4, 5, 0, 3, 0],   # subject sequence
     [4, 5, 0, 0, 0]],  # object sequence
    # Second relation
    [[4, 0, 0, 3, 6],
     [0, 0, 5, 6, 0]],
    # Third relation
    [[3, 0, 4, 5, 0],
     [0, 3, 0, 0, 0]]
])

# label2idx_sub: maps tag names to indices for subject tags
label2idx_sub = {
    "O": 0,
    "B-H": 4,
    "I-H": 5,
    "B-T": 3,
    "I-T": 6
}

# label2idx_obj: maps tag names to indices for object tags
label2idx_obj = {
    "O": 0,
    "B-H": 4,
    "I-H": 5,
    "B-T": 3,
    "I-T": 6
}

# pre_rels: optional array of relation indices/labels, shape (rel_num,)
pre_rels = np.array([0, 1, 2])

ARGS = {
    "predict_tags": predict_tags,
    "pre_rels": pre_rels,
    "label2idx_sub": label2idx_sub,
    "label2idx_obj": label2idx_obj
}
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 — 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
load_checkpoint Not yet run
unverified (harvested, no recorded run)
zjunlp/RAP/BaseModel/PRGC/utils.py
code served (permissive licence) · get_code("1d6af4e45a421828")
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, 4 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 3 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
find_head_idx 1 other paper
1 later
2304.09048 (2023-04)
CodeKGC: Code Language Model for Generative Knowledge Graph Construction
find_sublist_index 1 other paper
1 dated earlier
2203.09101 (2022-03)
RelationPrompt: Leveraging Prompts to Generate Synthetic Data for Zero-Shot Relation Triplet Extraction
get_metrics 1 other paper
1 later
2304.09048 (2023-04)
CodeKGC: Code Language Model for Generative Knowledge Graph Construction
span2str 1 other paper
1 later
2304.09048 (2023-04)
CodeKGC: Code Language Model for Generative 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

With the development of pre-trained language models, many prompt-based approaches to data-efficient knowledge graph construction have been proposed and achieved impressive performance. However, existing prompt-based learning methods for knowledge graph construction are still susceptible to several potential limitations: (i) semantic gap between natural language and output structured knowledge with pre-defined schema, which means model cannot fully exploit semantic knowledge with the constrained templates; (ii) representation learning with locally individual instances limits the performance given the insufficient features, which are unable to unleash the potential analogical capability of pre-trained language models. Motivated by these observations, we propose a retrieval-augmented approach, which retrieves schema-aware Reference As Prompt (RAP), for data-efficient knowledge graph construction. It can dynamically leverage schema and knowledge inherited from human-annotated and weak-supervised data as a prompt for each sample, which is model-agnostic and can be plugged into widespread existing approaches. Experimental results demonstrate that previous methods integrated with RAP can achieve impressive performance gains in low-resource settings on five datasets of relational triple extraction and event extraction for knowledge graph construction. Code is available in https://github.com/zjunlp/RAP.

For agents

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

get_harvested_code_for_paper("2210.10709")
get_code_for_paper("2210.10709")
have("2210.10709")

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

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

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

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

Connect an agent — have() is free.