SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2203.15827 · ACL · 2022

LinkBERT: Pretraining Language Models with Document Links

Jure Leskovec, Percy Liang, Michihiro Yasunaga

arXiv · PDF · Open in the Atlas

Code that ran

3 of 14 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 3 have no contract verdict; 0 failures of our instrument; 11 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/2203.15827.json · badge: /api/ran/2203.15827.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
titipata/pubmed_parser canonical (classifier label)
classifier basis not recorded on the link
3 ran · 6 no recorded run
michiyasunaga/LinkBERT canonical (classifier label)
classifier basis not recorded on the link
0 ran · 5 no recorded run
FunctionStatusWhere it lives
flatten_zip_author Ran
ran on a synthesized input
titipata/pubmed_parser/pubmed_parser/pubmed_oa_parser.py
code served (permissive licence) · get_code("bf61041fdd6647e6")
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
import numpy as np
from itertools import chain

def zip_author(author):
    """
    Give a list of author and its affiliation keys
    in this following format
        [first_name, last_name, [key1, key2]]
    and return the output in
        [[first_name, last_name, key1], [first_name, last_name, key2]] instead
    """
    author_zipped = list(zip([[author[0], author[1]]] * len(author[-1]), author[-1]))
    return list(map(lambda x: x[0] + [x[-1]], author_zipped))

def flatten_zip_author(author_list):
    """
    Apply zip_author to author_list and flatten it
    """
    author_zipped_list = map(zip_author, author_list)
    return list(chain.from_iterable(author_zipped_list))

# Construct valid author_list argument
# Each author is [first_name, last_name, [key1, key2, ...]]
author1 = ["John", "Doe", ["aff1", "aff2"]]
author2 = ["Jane", "Smith", ["aff3"]]
author3 = ["Bob", "Johnson", ["aff4", "aff5", "aff6"]]

author_list = [author1, author2, author3]

ARGS = {
    "author_list": author_list
}
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 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
list_xml_path Ran
ran on a synthesized input
titipata/pubmed_parser/pubmed_parser/pubmed_oa_parser.py
code served (permissive licence) · get_code("9b111e4814825d40")
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 os
import tempfile
import shutil

# Create a temporary directory structure with some XML/NXML files
temp_dir = tempfile.mkdtemp()

# Create subdirectories and XML files
os.makedirs(os.path.join(temp_dir, "subdir1"), exist_ok=True)
os.makedirs(os.path.join(temp_dir, "subdir2"), exist_ok=True)

# Create some test XML and NXML files
xml_file1 = os.path.join(temp_dir, "test1.xml")
xml_file2 = os.path.join(temp_dir, "subdir1", "test2.nxml")
xml_file3 = os.path.join(temp_dir, "subdir2", "test3.xml")
txt_file = os.path.join(temp_dir, "test.txt")  # This should be filtered out

# Write dummy content to files
for filepath in [xml_file1, xml_file2, xml_file3, txt_file]:
    with open(filepath, 'w') as f:
        f.write("<dummy>content</dummy>")

ARGS = {
    "path_dir": 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 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
zip_author Ran
ran on a synthesized input
titipata/pubmed_parser/pubmed_parser/pubmed_oa_parser.py
code served (permissive licence) · get_code("89ed942af19f2fac")
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)

# The function expects an author in the format:
# [first_name, last_name, [key1, key2, ...]]
# It zips the name with each key and returns a list of [first_name, last_name, key]

author = ["John", "Doe", ["aff1", "aff2", "aff3"]]

ARGS = {
    "author": author
}
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
compute_p_r_f Not yet run
unverified (harvested, no recorded run)
michiyasunaga/LinkBERT/src/seqcls/utils_hoc.py
code served (permissive licence) · get_code("74040dc1e7877b49")
How it ran

no invocation recorded.

divide Not yet run
unverified (harvested, no recorded run)
michiyasunaga/LinkBERT/src/seqcls/utils_hoc.py
code served (permissive licence) · get_code("c2cd56888edff13a")
How it ran

no invocation recorded.

eval_hoc Not yet run
unverified (harvested, no recorded run)
michiyasunaga/LinkBERT/src/seqcls/utils_hoc.py
code served (permissive licence) · get_code("e3f1559c8f5f8688")
How it ran

no invocation recorded.

parse_doi Not yet run
unverified (harvested, no recorded run)
titipata/pubmed_parser/pubmed_parser/medline_parser.py
code served (permissive licence) · get_code("8abb78363c80dab0")
How it ran

no invocation recorded.

parse_mesh_terms Not yet run
unverified (harvested, no recorded run)
titipata/pubmed_parser/pubmed_parser/medline_parser.py
code served (permissive licence) · get_code("0d69b1b23dd6057d")
How it ran

no invocation recorded.

parse_pmid Not yet run
unverified (harvested, no recorded run)
titipata/pubmed_parser/pubmed_parser/medline_parser.py
code served (permissive licence) · get_code("0a88d93a2312fac0")
How it ran

no invocation recorded.

parse_pubmed_web_tree Not yet run
unverified (harvested, no recorded run)
titipata/pubmed_parser/pubmed_parser/pubmed_web_parser.py
code served (permissive licence) · get_code("5b766af778be529d")
How it ran

no invocation recorded.

postprocess_qa_predictions Not yet run
unverified (harvested, no recorded run)
michiyasunaga/LinkBERT/src/qa/utils_qa.py
code served (permissive licence) · get_code("3957d7cb42610910")
How it ran

no invocation recorded.

postprocess_qa_predictions_with_beam_search Not yet run
unverified (harvested, no recorded run)
michiyasunaga/LinkBERT/src/qa/utils_qa.py
code served (permissive licence) · get_code("31453e36e3e54527")
How it ran

no invocation recorded.

stringify_affiliation Not yet run
unverified (harvested, no recorded run)
titipata/pubmed_parser/pubmed_parser/utils.py
code served (permissive licence) · get_code("3ad8ed067be5af35")
How it ran

no invocation recorded.

stringify_children Not yet run
unverified (harvested, no recorded run)
titipata/pubmed_parser/pubmed_parser/utils.py
code served (permissive licence) · get_code("bec7a30d2cf6ff0d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 14 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.

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

Language model (LM) pretraining captures various knowledge from text corpora, helping downstream NLP tasks. However, existing methods such as BERT model a single document, failing to capture document dependencies and knowledge that spans across documents. In this work, we propose LinkBERT, an effective LM pretraining method that incorporates document links, such as hyperlinks. Given a pretraining corpus, we view it as a graph of documents, and create LM inputs by placing linked documents in the same context. We then train the LM with two joint self-supervised tasks: masked language modeling and our newly proposed task, document relation prediction. We study LinkBERT in two domains: general domain (pretrained on Wikipedia with hyperlinks) and biomedical domain (pretrained on PubMed with citation links). LinkBERT outperforms BERT on various downstream tasks in both domains. It is especially effective for multi-hop reasoning and few-shot QA (+5% absolute improvement on HotpotQA and TriviaQA), and our biomedical LinkBERT attains new state-of-the-art on various BioNLP tasks (+7% on BioASQ and USMLE). We release the pretrained models, LinkBERT and BioLinkBERT, as well as code and data. 1 * Equal senior authorship.

For agents

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

get_harvested_code_for_paper("2203.15827")
get_code_for_paper("2203.15827")
have("2203.15827")

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

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

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

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

Connect an agent — have() is free.