SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2109.04901 · EMNLP · 2021

Document-level Entity-based Extraction as Template Generation

Nanyun Peng, Kung-Hsiang Huang, Sam Tang

arXiv · PDF · Open in the Atlas

Code that ran

8 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/2109.04901.json · badge: /api/ran/2109.04901.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
PlusLabNLP/TempGen canonical (classifier label)
classifier basis: census
8 ran · 2 no recorded run
FunctionStatusWhere it lives
compute_mapping Ran
ran on a synthesized input
PlusLabNLP/TempGen/bre_eval.py
code served (permissive licence) · get_code("1a6bd830af39580b")
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.

from typing import Dict, List

# Construct arguments for compute_mapping

# doc_tokens: a list of strings representing tokens in a document
doc_tokens = [
    "The", "model", "achieved", "high", "accuracy",
    "on", "Natural", "language", "inference", "task"
]

# gold_entities: a dict mapping entity names to lists of (start_tok, end_tok) spans
gold_entities = {
    "Metric_1": [(3, 4), (4, 5)],  # "high" and "accuracy"
    "Task_1": [(6, 9)],            # "Natural language inference"
}

# predicted_relations: a list of dicts, each representing a binary relation
predicted_relations = [
    {
        "Metric": "accuracy",
        "Task": "Natural language inference",
    },
    {
        "Metric": "high",
        "Task": "Natural language inference",
    },
]

ARGS = {
    "predicted_relations": predicted_relations,
    "gold_entities": gold_entities,
    "doc_tokens": doc_tokens,
}
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 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
f1 Ran
ran, honoured the contract we drafted
PlusLabNLP/TempGen/ree_eval.py
pointer only (licence: MIT); the stored copy get_code serves, from sapienzanlp/bookcoref, is pointer only (licence: NONE) · get_code("5dc251a1bb16c94f")
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 sapienzanlp/bookcoref, 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.

format_inputs_outputs Ran
ran on a synthesized input
PlusLabNLP/TempGen/util.py
code served (permissive licence) · get_code("86ce8222fefed159")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.pad_token_id = 0

tokenizer = MinimalTokenizer()

# Create flattened sequences (lists of token IDs)
# Each sequence should have different lengths to test padding logic
flattened_seqs = [
    [1, 2, 3, 4, 5],
    [6, 7, 8]
]

# Parameters for the function
use_gpu = False
max_position_embeddings = 10

ARGS = {
    'flattened_seqs': flattened_seqs,
    'tokenizer': tokenizer,
    'use_gpu': use_gpu,
    'max_position_embeddings': max_position_embeddings
}
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
has_all_mentions Ran
ran on a synthesized input
PlusLabNLP/TempGen/bre_eval.py
code served (permissive licence) · get_code("cc66af9f533680f2")
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 bool, ndim 0, dtype family float, 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)

def create_doc():
    """Create a valid doc structure with coref information"""
    doc = {
        'coref': {
            0: [1, 2],  # entity 0 has mentions [1, 2]
            1: [3],      # entity 1 has mention [3]
            2: [],       # entity 2 has no mentions (empty list)
        }
    }
    return doc

def create_relation():
    """Create a valid relation structure"""
    # Relation is a list of tuples where each tuple contains indices
    # The second element x[1] is used to index into doc['coref']
    relation = [
        (0, 0),  # First tuple, second element is 0
        (1, 1),  # Second tuple, second element is 1
    ]
    return relation

ARGS = {
    'doc': create_doc(),
    'relation': create_relation(),
}
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 bool, ndim 0, dtype family float, 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
phi_prop Ran
ran on a synthesized input
PlusLabNLP/TempGen/ree_eval.py
code served (permissive licence) · get_code("f7b10b434d2ca733")
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 float, ndim 0, dtype family float, 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)

# phi_prop takes two arguments: c1 and c2
# The function checks: len([m for m in c1 if m in c2]) / len(c2)
# This means:
# - c1 and c2 should be iterable/container types
# - Elements of c1 need to be comparable to elements of c2 (membership test)
# - c2 must have a len()
# - The function counts how many elements from c1 are in c2, divided by len(c2)

# Simple approach: use lists of hashable elements (strings, integers, tuples)
c1 = ['a', 'b', 'c', 'd']
c2 = ['b', 'd', 'e', 'f']

ARGS = {
    'c1': c1,
    'c2': c2,
}
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 float, ndim 0, dtype family float, 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
phi_strict Ran
ran on a synthesized input
PlusLabNLP/TempGen/ree_eval.py
code served (permissive licence) · get_code("6cc07897ce7e5e2b")
How it ran

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

import torch
import numpy as np

torch.manual_seed(0)

# Analyzing the function:
# phi_strict(c1, c2) iterates over items in c2 and checks if each is in c1
# It returns 0 if any item in c2 is not in c1, otherwise returns 1
# This suggests c1 and c2 are iterable containers (likely lists, sets, or tuples)
# The function checks membership with "in" operator

# Create two simple container arguments
c1 = [1, 2, 3, 4, 5]  # First container with several elements
c2 = [2, 3]            # Second container with elements that are all in c1

ARGS = {
    "c1": c1,
    "c2": c2
}
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 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
process_entities Ran
ran on a synthesized input
PlusLabNLP/TempGen/convert_grit.py
code served (permissive licence) · get_code("999a0e4f59e1e104")
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 torch

torch.manual_seed(0)

entities = [
    [
        ['guerrillas', 37], 
        ['guerrilla column', 349]
    ],
    [
        ['apple', 45]
    ],
    [
        ['banana', 60]
    ]
]

ARGS = {
    'entities': entities
}
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 — 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
token2sub_tokens Ran
ran on a synthesized input
PlusLabNLP/TempGen/util.py
code served (permissive licence) · get_code("6b87c15aae792362")
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

class MockTokenizer:
    def __init__(self):
        self.vocab = {
            "hello": 101,
            "world": 102,
            "##ing": 103,
            "test": 104,
            "##s": 105,
        }
        self.token_to_id = self.vocab
    
    def tokenize(self, token):
        """Tokenize a string into subtokens."""
        token_lower = token.lower()
        if token_lower == "hello":
            return ["hello"]
        elif token_lower == "testing":
            return ["test", "##ing"]
        elif token_lower == "tests":
            return ["test", "##s"]
        elif token_lower == "world":
            return ["world"]
        else:
            return ["test"]
    
    def convert_tokens_to_ids(self, token):
        """Convert a single token string to its ID."""
        return self.vocab.get(token, 999)

tokenizer = MockTokenizer()
token = "testing"

ARGS = {
    "tokenizer": tokenizer,
    "token": token,
}
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
bre_eval Not yet run
unverified (harvested, no recorded run)
PlusLabNLP/TempGen/bre_eval.py
code served (permissive licence) · get_code("179c577cfe250d9c")
How it ran

no invocation recorded.

scirex_eval Not yet run
unverified (harvested, no recorded run)
PlusLabNLP/TempGen/scirex_eval.py
code served (permissive licence) · get_code("bc8299f646161453")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 2 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 2 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
f1 12 other papers
2 dated earlier, 9 later, 1 same year, order not determinable
1804.05392 (2018-04)
Higher-order Coreference Resolution with Coarse-to-fine Inference
1907.10529 (2019-07)
SpanBERT: Improving Pre-training by Representing and Predicting Spans
2021.naacl-main.125 (2021 (year only))
Incorporating Syntax and Semantics in Coreference Resolution with Heterogeneous Graph Attention Network
and 9 more not named here
token2sub_tokens 1 other paper
1 later
2303.08233 (2023-03)
NL4Opt Competition: Formulating Optimization Problems Based on Their Natural Language Descriptions

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

Document-level entity-based extraction (EE), aiming at extracting entity-centric information such as entity roles and entity relations, is key to automatic knowledge acquisition from text corpora for various domains. Most document-level EE systems build extractive models, which struggle to model long-term dependencies among entities at the document level. To address this issue, we propose a generative framework for two document-level EE tasks: role-filler entity extraction (REE) and relation extraction (RE). We first formulate them as a template generation problem, allowing models to efficiently capture crossentity dependencies, exploit label semantics, and avoid the exponential computation complexity of identifying N-ary relations. A novel cross-attention guided copy mechanism, TOPK COPY, is incorporated into a pre-trained sequence-to-sequence model to enhance the capabilities of identifying key information in the input document. Experiments done on the MUC-4 and SCIREX dataset show new stateof-the-art results on REE (+3.26%), binary RE (+4.8%), and 4-ary RE (+2.7%) in F1 score 1 .

For agents

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

get_harvested_code_for_paper("2109.04901")
get_code_for_paper("2109.04901")
have("2109.04901")

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

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

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

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

Connect an agent — have() is free.