SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.01562 · ACL Findings · 2021

Discriminative Reasoning for Document-level Relation Extraction

Kehai Chen, Wang Xu, Tiejun Zhao

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 (6 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-21; 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/2106.01562.json · badge: /api/ran/2106.01562.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
xwjim/DRN community
Papers with Code archive
8 ran · 2 no recorded run
FunctionStatusWhere it lives
BiLSTM Ran
ran on a synthesized input · constructed an object; no result was computed
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("b726edbcdb133a6e")
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 an instance of its own class, BiLSTM: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

class BiLSTM(nn.Module):

    def __init__(self, input_size, lstm_hidden_size, nlayers, dropout, word_pad=0, bidir=True):
        super().__init__()
        self.lstm_hidden_size = lstm_hidden_size
        self.nlayers = nlayers
        self.word_pad = word_pad
        self.bidir = bidir
        self.lstm = nn.LSTM(input_size=input_size, hidden_size=lstm_hidden_size, num_layers=nlayers, batch_first=True, bidirectional=bidir)
        self.in_dropout = nn.Dropout(dropout)
        self.out_dropout = nn.Dropout(dropout)

    def forward(self, src, src_lengths, hidden_init=None, ceil_init=None):
        """
        src: [batch_size, slen, input_size]
        src_lengths: [batch_size]
        """
        self.lstm.flatten_parameters()
        bsz, slen, input_size = src.size()
        src = self.in_dropout(src)
        new_src_lengths, sort_index = torch.sort(src_lengths, dim=-1, descending=True)
        new_src = torch.index_select(src, dim=0, index=sort_index)
        packed_src = nn.utils.rnn.pack_padded_sequence(new_src, new_src_lengths.cpu(), batch_first=True, enforce_sorted=True)
        if hidden_init is not None and ceil_init is not None:
            packed_outputs, (src_h_t, src_c_t) = self.lstm(packed_src, (hidden_init, ceil_init))
        else:
            packed_outputs, (src_h_t, src_c_t) = self.lstm(packed_src)
        outputs, _ = nn.utils.rnn.pad_packed_sequence(packed_outputs, batch_first=True, padding_value=self.word_pad)
        unsort_index = torch.argsort(sort_index)
        outputs = torch.index_select(outputs, dim=0, index=unsort_index)
        if not self.bidir:
            src_h_t = src_h_t.view(self.nlayers, bsz, self.lstm_hidden_size)
            src_c_t = src_c_t.view(self.nlayers, bsz, self.lstm_hidden_size)
            output_h_t = src_h_t[-1]
            output_c_t = src_c_t[-1]
        else:
            src_h_t = src_h_t.view(self.nlayers, 2, bsz, self.lstm_hidden_size)
            src_c_t = src_c_t.view(self.nlayers, 2, bsz, self.lstm_hidden_size)
            output_h_t = torch.cat((src_h_t[-1, 0], src_h_t[-1, 1]), dim=-1)
            output_c_t = torch.cat((src_c_t[-1, 0], src_c_t[-1, 1]), dim=-1)
        output_h_t = torch.index_select(output_h_t, dim=0, index=unsort_index)
        output_c_t = torch.index_select(output_c_t, dim=0, index=unsort_index)
        outputs = self.out_dropout(outputs)
        output_h_t = self.out_dropout(output_h_t)
        output_c_t = self.out_dropout(output_c_t)
        return (outputs, (output_h_t, output_c_t))


input_size = 4
lstm_hidden_size = 8
nlayers = 2
dropout = 0.1
word_pad = 0
bidir = True

bilstm = BiLSTM(input_size=input_size, lstm_hidden_size=lstm_hidden_size, nlayers=nlayers, dropout=dropout, word_pad=word_pad, bidir=bidir)

batch_size = 2
seq_len = 5
src = torch.randn(batch_size, seq_len, input_size)
src_lengths = torch.tensor([5, 3], dtype=torch.long)

ARGS = {
    'input_size': input_size,
    'lstm_hidden_size': lstm_hidden_size,
    'nlayers': nlayers,
    'dropout': dropout,
    'word_pad': word_pad,
    'bidir': bidir,
}
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 BiLSTM — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BiLSTM 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
GraphAttentionLayer Ran
ran on a synthesized input · constructed an object; no result was computed
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("91e688bdb73b0536")
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 an instance of its own class, GraphAttentionLayer: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn

torch.manual_seed(0)

# Define the edges parameter
edges = [
    ('type1', 'type2'),
    ('type2', 'type3'),
    ('type3', 'type1'),
]

# Define input_size, hidden_size, and graph_drop
input_size = 4
hidden_size = 3
graph_drop = 0.1

ARGS = {
    'edges': edges,
    'input_size': input_size,
    'hidden_size': hidden_size,
    'graph_drop': graph_drop,
}
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 GraphAttentionLayer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GraphAttentionLayer 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
GraphConvolutionLayer Ran
ran on a synthesized input · constructed an object; no result was computed
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("a71906f960cae0a7")
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 an instance of its own class, GraphConvolutionLayer: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

# Define the parameters for GraphConvolutionLayer
edges = [0, 1, 2]  # List of edge types
input_size = 4
hidden_size = 3
graph_drop = 0.5

ARGS = {
    'edges': edges,
    'input_size': input_size,
    'hidden_size': hidden_size,
    'graph_drop': graph_drop,
}
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 GraphConvolutionLayer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GraphConvolutionLayer 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
GraphReasonLayer Ran
ran on a synthesized input · constructed an object; no result was computed
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("5ddc00be435de1dc")
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 an instance of its own class, GraphReasonLayer: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn

torch.manual_seed(0)

# Parameters for GraphReasonLayer
edges = [1, 2]  # Two edge types
input_size = 4
out_size = 8
iters = 2
graph_type = 'gat'
graph_drop = 0.1
graph_head = 4

# Create sample nodes_embed tensor: (batch_size=2, num_nodes=3, input_size=4)
nodes_embed = torch.randn(2, 3, input_size)

# Create sample node_adj tensor: (batch_size=2, num_nodes=3, num_nodes=3)
# Values should be 0 (no edge), 1 (edge type 1), or 2 (edge type 2)
node_adj = torch.tensor([
    [[0, 1, 2],
     [1, 0, 1],
     [2, 1, 0]],
    [[0, 2, 1],
     [2, 0, 2],
     [1, 2, 0]]
], dtype=torch.float32)

ARGS = {
    'edges': edges,
    'input_size': input_size,
    'out_size': out_size,
    'iters': iters,
    'graph_type': graph_type,
    'graph_drop': graph_drop,
    'graph_head': graph_head,
}
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 GraphReasonLayer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GraphReasonLayer 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
MultiHeadAttention Ran
ran on a synthesized input · constructed an object; no result was computed
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("b3cbaba8366c9a10")
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 an instance of its own class, MultiHeadAttention: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

# Parameters for MultiHeadAttention
n_head = 2
d_model = 4
d_k = 2
d_v = 2
dropout = 0.1

# Create sample tensors for forward pass
# batch_size=2, seq_len_q=3, seq_len_k=3, seq_len_v=3
batch_size = 2
seq_len_q = 3
seq_len_k = 3
seq_len_v = 3

q = torch.randn(batch_size, seq_len_q, d_model)
k = torch.randn(batch_size, seq_len_k, d_model)
v = torch.randn(batch_size, seq_len_v, d_model)

# Optional mask (attention mask with shape compatible with attention scores)
# Shape will be (batch_size, 1, seq_len_q, seq_len_k) after unsqueeze in forward
mask = torch.ones(batch_size, seq_len_q, seq_len_k)

ARGS = {
    'n_head': n_head,
    'd_model': d_model,
    'd_k': d_k,
    'd_v': d_v,
    'dropout': dropout,
}
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 MultiHeadAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MultiHeadAttention 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
ScaledDotProductAttention Ran
ran on a synthesized input
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("82da049dc17d5ab5")
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. 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 torch.nn.functional as F

class ScaledDotProductAttention(nn.Module):
    """ Scaled Dot-Product Attention """

    def __init__(self, temperature, attn_dropout=0.1):
        super().__init__()
        self.temperature = temperature
        self.dropout = nn.Dropout(attn_dropout)

    def forward(self, q, k, v, mask=None):
        scores = torch.matmul(q / self.temperature, k.transpose(2, 3))
        if mask is not None:
            scores = scores.masked_fill(mask == 0, -1000000000.0)
        attn = self.dropout(F.softmax(scores, dim=-1))
        output = torch.matmul(attn, v)
        return (output, scores)


INIT_ARGS = {
    'temperature': 8.0,
    'attn_dropout': 0.1,
}

ARGS = {
    'q': torch.randn(2, 3, 4, 5),
    'k': torch.randn(2, 3, 6, 5),
    'v': torch.randn(2, 3, 6, 7),
    'mask': torch.ones(2, 3, 4, 6),
}

if __name__ == '__main__':
    model = ScaledDotProductAttention(**INIT_ARGS)
    output, scores = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Scores shape: {scores.shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Task_Decompose Ran
ran on a synthesized input · constructed an object; no result was computed
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("9ce5acb95a0bb132")
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 an instance of its own class, Task_Decompose: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn

torch.manual_seed(0)

class Config:
    def __init__(self):
        self.use_dis_embed = True

config = Config()

ARGS = {
    "config": config
}
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 Task_Decompose — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Task_Decompose 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
get_cuda Ran
ran, honoured the contract we drafted
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("f43f423bf4cb3982")
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 float, shape (2, 4) as a later run recorded it. 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, 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 get_cuda takes a tensor and moves it to CUDA if available
# Since we're CPU-only, we just need to pass a valid tensor
# The function will check torch.cuda.is_available() and return the tensor as-is on CPU

tensor = torch.randn(2, 4)

ARGS = {
    "tensor": tensor
}
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
DRN_GloVe Not yet run
unverified (harvested, no recorded run)
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("591c83506ab3a0f0")
How it ran

no invocation recorded.

mergy_span_token Not yet run
unverified (harvested, no recorded run)
xwjim/DRN/code/models/DRN.py
code served (permissive licence) · get_code("a5c1c83f9e35d84c")
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
MultiHeadAttention
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 later
1706.03762 (2017-06)
Attention Is All You Need
2303.05095 (2023-03)
Trajectory-Aware Body Interaction Transformer for Multi-Person Pose Forecasting
get_cuda
brick of this paper's assembly: helper
1 other paper
1 later
2109.04008 (2021-09)
Graph Based Network with Contextualized Representations of Turns in Dialogue

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

Repositories linked to this paper

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

Abstract

models generally use graph networks to implicitly model the reasoning skill (i.e., pattern recognition, logical reasoning, coreference reasoning, etc.) related to the relation between one entity pair in a document. In this paper, we propose a novel discriminative reasoning framework to explicitly model the paths of these reasoning skills between each entity pair in this document. Thus, a discriminative reasoning network is designed to estimate the relation probability distribution of different reasoning paths based on the constructed graph and vectorized document contexts for each entity pair, thereby recognizing their relation. Experimental results show that our method outperforms the previous state-of-theart performance on the large-scale DocRE dataset. The code is publicly available at https://github.com/xwjim/DRN.

For agents

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

get_harvested_code_for_paper("2106.01562")
get_code_for_paper("2106.01562")
have("2106.01562")

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

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

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

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

Connect an agent — have() is free.