SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.05185 · NeurIPS · 2024

Text2NKG: Fine-Grained N-ary Relation Extraction for N-ary relational Knowledge Graph Construction

Anh Luu, Wei Lin, Tuan, Haoran Luo, Yuhao Yang, Tianyu Yao, Yikai Guo, Zichen Tang, Wentai Zhang, Shiyao Peng, Kaiyang Wan, Meina Song, and 1 more

arXiv · PDF · Open in the Atlas

Code that ran

7 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; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 5 failures of our instrument; 5 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, measured 2026-11-23; 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/2310.05185.json · badge: /api/ran/2310.05185.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
LHRLAB/Text2NKG canonical (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
lhrlab/text2nkg marked official in Papers with Code
Papers with Code archive
5 ran · 4 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
to_list Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from AI-secure/InfoBERT
pointer only; the stored copy get_code serves, from AI-secure/InfoBERT, is pointer only (licence: NONE) · get_code("9df40357afea56cc")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

BioEncoder Ran
ran on a synthesized input
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("b15e1145195f287e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 numpy as np

# BioEncoder has no __init__ parameters (it's a stateless utility class)
INIT_ARGS = {}

# The run method is the main computation method
METHOD = 'run'

# Arguments for the run method: spans, length
ARGS = {
    'spans': [(0, 2, 'PER'), (3, 5, 'LOC'), (7, 8, 'ORG')],
    'length': 10
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Entity Ran
ran on a synthesized input
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("4161204c355ff4f5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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.

from typing import Dict, List, Tuple, Optional
from pydantic import BaseModel

Span = Tuple[int, int]

class Entity(BaseModel):
    span: Span
    label: str

    def as_tuple(self) -> Tuple[int, int, str]:
        return (self.span[0], self.span[1], self.label)


INIT_ARGS = {
    "span": (5, 10),
    "label": "PERSON"
}

ARGS = {}

METHOD = "as_tuple"

if __name__ == "__main__":
    entity = Entity(**INIT_ARGS)
    result = entity.as_tuple()
    print(f"Entity created: {entity}")
    print(f"as_tuple() result: {result}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
pydantic — 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
add_tag_joint_label Ran
ran; our contract draft was wrong, not the code
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("e82ac45ea887bc39")
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 numpy as np
from typing import Dict, List, Tuple

# Create a small label vocabulary
label_vocab = {
    'id': {
        'O': 0,
        'B-PERSON': 1,
        'I-PERSON': 2,
        'B-LOC': 3,
        'I-LOC': 4,
    }
}

# Create a sample sentence with tokens and entities
sent = {
    'tokens': ['John', 'Smith', 'lives', 'in', 'New', 'York'],
    'entities': [
        {'span': (0, 2), 'label': 'PERSON'},
        {'span': (4, 6), 'label': 'LOC'},
    ]
}

ARGS = {
    'sent': sent,
    'label_vocab': label_vocab,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
add_tokens Ran
ran; our contract draft was wrong, not the code
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("51d44540fb9cd150")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from transformers import BertTokenizer, RobertaTokenizer

# Create a minimal tokenizer stand-in for BERT
class BertTokenizerStandIn:
    def __init__(self):
        self.cls_token = "[CLS]"
        self.sep_token = "[SEP]"
    
    def tokenize(self, token):
        # Simple tokenization: split into characters and add ## prefix for subwords
        if len(token) <= 2:
            return [token]
        return [token[:2], "##" + token[2:]]

# Create a minimal tokenizer stand-in for RoBERTa
class RobertaTokenizerStandIn:
    def __init__(self):
        self.cls_token = "<s>"
        self.sep_token = "</s>"
    
    def tokenize(self, token):
        # RoBERTa tokenization simulation
        if len(token) <= 2:
            return [token]
        return [token[:2], "##" + token[2:]]

# Create sample sentence input
sent = {
    'tokens': ['hello', 'world', 'test'],
    'other_field': 'some_value'
}

# Use BERT tokenizer
tokenizer = BertTokenizerStandIn()

ARGS = {
    'sent': sent,
    'tokenizer': tokenizer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_sent_to_tags Ran
ran; our contract draft was wrong, not the code
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("ace46dde5211f557")
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 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 numpy as np
from typing import List, Tuple

# Define the classes from the function signature
Span = Tuple[int, int]

class Entity:
    def __init__(self, span: Span, label: str):
        self.span = span
        self.label = label
    
    def json(self):
        return f"{self.span}_{self.label}"

class Relation:
    def __init__(self, head: Span, tail: Span, label: str, qualifiers: List[Entity] = None):
        self.head = head
        self.tail = tail
        self.label = label
        self.qualifiers = qualifiers if qualifiers is not None else []

class Sentence:
    def __init__(self, tokens: List[str], entities: List[Entity] = None, relations: List[Relation] = None,
                 wordpieceSentText=None, wordpieceTokensIndex=None, wordpieceSegmentIds=None,
                 jointLabelMatrix=None, quintupletMatrix=None):
        self.tokens = tokens
        self.entities = entities if entities is not None else []
        self.relations = relations if relations is not None else []
        self.wordpieceSentText = wordpieceSentText
        self.wordpieceTokensIndex = wordpieceTokensIndex
        self.wordpieceSegmentIds = wordpieceSegmentIds
        self.jointLabelMatrix = jointLabelMatrix
        self.quintupletMatrix = quintupletMatrix
    
    @property
    def text(self) -> str:
        return ' '.join(self.tokens)
    
    def copy(self, deep=False):
        if deep:
            import copy
            return copy.deepcopy(self)
        else:
            return Sentence(
                tokens=self.tokens[:],
                entities=self.entities[:],
                relations=self.relations[:],
                wordpieceSentText=self.wordpieceSentText,
                wordpieceTokensIndex=self.wordpieceTokensIndex,
                wordpieceSegmentIds=self.wordpieceSegmentIds,
                jointLabelMatrix=self.jointLabelMatrix,
                quintupletMatrix=self.quintupletMatrix
            )

# Create test data
tokens = ["The", "cat", "sat", "on", "the", "mat"]
entities = [
    Entity(span=(0, 1), label="ANIMAL"),
    Entity(span=(5, 6), label="OBJECT")
]
qualifiers = [
    Entity(span=(3, 4), label="LOCATION")
]
relations = [
    Relation(head=(0, 1), tail=(5, 6), label="SITS_ON", qualifiers=qualifiers)
]

sent = Sentence(
    tokens=tokens,
    entities=entities,
    relations=relations,
    wordpieceSentText=None,
    wordpieceTokensIndex=None,
    wordpieceSegmentIds=None,
    jointLabelMatrix=None,
    quintupletMatrix=None
)

ARGS = {
    "sent": sent
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, pydantic — 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
sset Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
LHRLAB/Text2NKG/run_re.py
code served (permissive licence) · get_code("03619aadbbc021c8")
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 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

torch.manual_seed(0)

# The function sset takes an array-like object and removes duplicates
# while preserving order. It iterates through elements and checks membership.
# We need to provide an array with some duplicate elements.

arr = [1, 2, 3, 2, 4, 1, 5]

ARGS = {
    "arr": arr
}
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 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
Relation Not yet run
unverified (harvested, no recorded run)
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("09904326420aaef1")
How it ran

no invocation recorded.

Sentence Not yet run
unverified (harvested, no recorded run)
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("81db230e87f76be0")
How it ran

no invocation recorded.

SparseCube Not yet run
unverified (harvested, no recorded run)
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("c95bb2a25e11fe46")
How it ran

no invocation recorded.

load_tf_weights_in_albert Not yet run
unverified (harvested, no recorded run)
LHRLAB/Text2NKG/transformers/src/transformers/modeling_albert.py
code served (permissive licence) · get_code("0acb90d02eadd73f")
How it ran

no invocation recorded.

process Not yet run
unverified (harvested, no recorded run)
lhrlab/text2nkg/hyperred_data_process.py
code served (permissive licence) · get_code("fccd9efaa74da2dd")
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, 3 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 2 later) and 9 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
to_list 41 other papers
34 dated earlier, 2 the same month, 4 later, 1 same year, order not determinable
1902.01718 (2019-02)
End-to-End Open-Domain Question Answering with BERTserini
1910.06188 (2019-10)
Q8BERT: Quantized 8Bit BERT
1911.02984 (2019-11)
The TechQA Dataset
and 38 more not named here
load_tf_weights_in_albert 2 other papers
2 dated earlier
2109.06067 (2021-09)
Packed Levitated Marker for Entity and Relation Extraction
2110.12567 (2021-10)
Alignment Attention by Matching Key and Query Distributions
add_tokens
brick of this paper's assembly: data_transform
1 other paper
1 later
2405.10288 (2024-05)
Timeline-based Sentence Decomposition with In-Context Learning for Temporal Fact Extraction

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

Repositories linked to this paper

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

Abstract

Beyond traditional binary relational facts, n-ary relational knowledge graphs (NKGs) are comprised of n-ary relational facts containing more than two entities, which are closer to real-world facts with broader applications. However, the construction of NKGs remains at a coarse-grained level, which is always in a single schema, ignoring the order and variable arity of entities. To address these restrictions, we propose Text2NKG, a novel fine-grained n-ary relation extraction framework for n-ary relational knowledge graph construction. We introduce a span-tuple classification approach with hetero-ordered merging and output merging to accomplish fine-grained n-ary relation extraction in different arity. Furthermore, Text2NKG supports four typical NKG schemas: hyper-relational schema, event-based schema, role-based schema, and hypergraph-based schema, with high flexibility and practicality. The experimental results demonstrate that Text2NKG achieves state-of-the-art performance in F 1 scores on the fine-grained n-ary relation extraction benchmark. Our code and datasets are publicly available 1 .

For agents

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

get_harvested_code_for_paper("2310.05185")
get_code_for_paper("2310.05185")
have("2310.05185")

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

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

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

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

Connect an agent — have() is free.