SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2105.02605 · NeurIPS · 2021

GraphFormers: GNN-nested Transformers for Representation Learning on Textual Graph

Amit Singh, Junhan Yang, Zheng Liu, Shitao Xiao, Chaozhuo Li, Defu Lian, Sanjay Agrawal, ♥ Guangzhong, Xing Xie

arXiv · PDF · Open in the Atlas

Code that ran

10 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; 2 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 7 failures of our instrument; 0 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-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/2105.02605.json · badge: /api/ran/2105.02605.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
microsoft/GraphFormers canonical (classifier label)
classifier basis: census
10 ran · 0 no recorded run
FunctionStatusWhere it lives
swish Ran
ran; our contract draft was wrong, not the code
microsoft/GraphFormers/src/models/tnlrv3/modeling_decoding.py
code served (permissive licence) · get_code("0f786c407fb1ee4c")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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 comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-04T22:33:52Z). 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 swish takes a single parameter 'x' which is used with:
# - torch.sigmoid(x) - requires a tensor
# - x * ... - requires a tensor that supports multiplication
# So x should be a tensor

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
acc Ran
ran, honoured the contract we drafted
microsoft/GraphFormers/src/utils.py
code served (permissive licence) · get_code("5f6cca96082d0328")
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 Tensor, 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)

# The function acc takes two parameters:
# - y_true: a tensor of true labels (1D)
# - y_hat: a tensor of logits/predictions (2D, with class dimension at dim=-1)
# The function uses:
#   - torch.argmax(y_hat, dim=-1) to get predicted class indices
#   - y_true.shape[0] to get batch size
#   - torch.sum() to count matches
#   - .data.float() to convert to float

# Create small tensors with batch size 2
batch_size = 2
num_classes = 4

# y_true: shape (2,) with class indices
y_true = torch.tensor([0, 2], dtype=torch.long)

# y_hat: shape (2, 4) with logits for 4 classes
# Make predictions such that argmax gives [0, 2] to test the function
y_hat = torch.tensor([
    [2.0, 1.0, 0.5, 0.1],  # argmax = 0
    [0.1, 0.2, 3.0, 1.5]   # argmax = 2
], dtype=torch.float32)

ARGS = {
    "y_true": y_true,
    "y_hat": y_hat
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 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
batch_list_to_batch_tensors Ran
ran; our contract draft was wrong, not the code
microsoft/GraphFormers/src/models/tnlrv3/s2s_loader.py
code served (permissive licence) · get_code("0185bc550948bb9e")
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
import torch.nn as nn

torch.manual_seed(0)

# The function expects a batch which is a list of tuples/sequences
# Each element of the batch should be a tuple where corresponding indices can be zipped together
# The function processes each zipped column and either:
# 1. Returns None if the first element is None
# 2. Stacks tensors if the first element is a torch.Tensor
# 3. Converts to long tensor otherwise

# Create a sample batch with mixed types
batch = [
    # First sample: (tensor, int, None)
    (torch.tensor([1, 2, 3, 4], dtype=torch.float32), 5, None),
    # Second sample: (tensor, int, None)
    (torch.tensor([5, 6, 7, 8], dtype=torch.float32), 10, None),
]

ARGS = {
    "batch": batch
}
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
create_mask_and_position_ids Ran
ran; our contract draft was wrong, not the code
microsoft/GraphFormers/src/models/tnlrv3/modeling.py
code served (permissive licence) · get_code("3c1f5f7bfb4716fa")
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 3, 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

torch.manual_seed(0)

# num_tokens: a tensor of integers representing token counts per sequence
# Should be 1D tensor with batch size
num_tokens = torch.tensor([3, 5], dtype=torch.long)

# max_len: maximum sequence length (scalar int)
max_len = 7

# offset: optional tensor to add to position matrix, same shape as num_tokens
offset = torch.tensor([0, 2], dtype=torch.long)

ARGS = {
    "num_tokens": num_tokens,
    "max_len": max_len,
    "offset": offset,
}
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 3, dtype family int — 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
dcg_score Ran
ran; our contract draft was wrong, not the code
microsoft/GraphFormers/src/utils.py
code served (permissive licence) · get_code("43e79e8e0904d5d8")
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 float64, 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 numpy as np

# Construct valid arguments for dcg_score function
# The function expects:
# - y_true: array of true relevance labels (binary or graded)
# - y_score: array of predicted scores
# - k: number of top results to consider (default 10)

# Create small sample data
np.random.seed(0)

# y_true: binary relevance labels (0 or 1), shape (15,)
y_true = np.array([1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0])

# y_score: predicted scores, shape (15,)
y_score = np.array([0.9, 0.2, 0.8, 0.7, 0.3, 0.85, 0.1, 0.15, 0.75, 0.95, 0.05, 0.88, 0.12, 0.92, 0.08])

# k: number of top results to evaluate
k = 10

ARGS = {
    "y_true": y_true,
    "y_score": y_score,
    "k": k
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, 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
gelu Ran
ran, honoured the contract we drafted
microsoft/GraphFormers/src/models/tnlrv3/modeling_decoding.py
pointer only (licence: MIT); the stored copy get_code serves, from shmsw25/qa-hard-em, is pointer only (licence: NONE) · get_code("40e9fee2e0b7e278")
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 shmsw25/qa-hard-em, 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.

get_random_word Ran
ran; our contract draft was wrong, not the code
microsoft/GraphFormers/src/models/tnlrv3/s2s_loader.py
code served (permissive licence) · get_code("8321d846789e75f1")
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 str. 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
from random import randint

torch.manual_seed(0)

# The function get_random_word expects a vocab_words parameter
# It uses: len(vocab_words) and indexing vocab_words[i]
# So vocab_words should be a list-like object with string elements

vocab_words = [
    "hello",
    "world",
    "python",
    "torch",
    "neural",
    "network"
]

ARGS = {
    "vocab_words": vocab_words
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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_model Ran
ran; our contract draft was wrong, not the code
microsoft/GraphFormers/src/models/tnlrv3/convert_state_dict.py
code served (permissive licence) · get_code("91d5980aeafe04e4")
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)

# Create a state_dict with various keys that exercise the different branches
# of the load_model function

state_dict = {
    'attention.self.q_bias': torch.randn(4),
    'attention.self.v_bias': torch.randn(4),
    'attention.self.qkv_linear.weight': torch.randn(12, 8),  # 12 = 3 * 4 (split into 3 parts of 4)
    'bert.encoder.rel_pos_bias.weight': torch.randn(5, 6),
    'some.other.key': torch.randn(2, 3),
    'layer.0.weight': torch.randn(7, 9),
}

ARGS = {
    'state_dict': state_dict
}
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
relative_position_bucket Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
microsoft/GraphFormers/src/models/tnlrv3/modeling.py
code served (permissive licence) · get_code("0fa0e6d25bc5b48e")
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 int, shape (2, 4) 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 math

torch.manual_seed(0)

# Construct a small relative_position tensor
# The function expects a tensor of relative positions (can be any shape)
relative_position = torch.tensor([[-5, -2, 0, 3], [1, 8, 15, 64]], dtype=torch.long)

ARGS = {
    "relative_position": relative_position,
    "bidirectional": True,
    "num_buckets": 32,
    "max_distance": 128,
}
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 int, 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
str2bool Ran
ran, violated the contract we drafted
microsoft/GraphFormers/src/utils.py
code served (permissive licence) · get_code("7c508037b40522af")
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 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 argparse

def str2bool(v):
    if isinstance(v, bool):
        return v
    if v.lower() in ('yes', 'true', 't', 'y', '1'):
        return True
    elif v.lower() in ('no', 'false', 'f', 'n', '0'):
        return False
    else:
        raise argparse.ArgumentTypeError('Boolean value expected.')

# Test cases for str2bool
ARGS = {
    'v': 'true'  # string input that should convert to boolean
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 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

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, 7 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 3 the same month, 5 later) and 3 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
swish 206 other papers
67 dated earlier, 1 the same month, 135 later, 3 same year, order not determinable · 44 only as an assembly brick
1408.5882 (2014-08)
Convolutional Neural Networks for Sentence Classification
1805.12114 (2018-05)
Deep Reinforcement Learning in a Handful of Trials using Probabilistic Dynamics Models
1809.01357 (2018-09)
Zero Shot Learning for Code Education: Rubric Sampling with Deep Learning Inference
and 203 more not named here
gelu 198 other papers
73 dated earlier, 3 the same month, 118 later, 4 same year, order not determinable · 32 only as an assembly brick
1408.5882 (2014-08)
Convolutional Neural Networks for Sentence Classification
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1901.10125 (2019-01)
Glyce: Glyph-vectors for Chinese Character Representations
and 195 more not named here
str2bool 175 other papers
28 dated earlier, 3 the same month, 144 later · 2 only as an assembly brick
1406.6247 (2014-06)
Recurrent Models of Visual Attention
1603.09382 (2016-03)
Deep Networks with Stochastic Depth
1710.10196 (2017-10)
Progressive Growing of GANs for Improved Quality, Stability, and Variation
and 172 more not named here
dcg_score 5 other papers
5 later
2109.05446 (2021-09)
Efficient-FedRec: Efficient Federated Learning Framework for Privacy-Preserving News Recommendation
2205.10282 (2022-05)
Heterformer: Transformer-based Deep Node Representation Learning on Heterogeneous Text-Rich Networks
2302.11050 (2023-02)
Edgeformers: Graph-Empowered Transformers for Representation Learning on Textual-Edge Networks
and 2 more not named here
acc 2 other papers
2 later
2205.10282 (2022-05)
Heterformer: Transformer-based Deep Node Representation Learning on Heterogeneous Text-Rich Networks
2302.11050 (2023-02)
Edgeformers: Graph-Empowered Transformers for Representation Learning on Textual-Edge Networks
get_random_word 2 other papers
1 dated earlier, 1 same year, order not determinable
1909.11059 (2019-09)
Unified Vision-Language Pre-Training for Image Captioning and VQA
2021.findings-emnlp.347 (2021 (year only))
Attend, Memorize and Generate: Towards Faithful Table-to-Text Generation in Few Shots
batch_list_to_batch_tensors 1 other paper
1 same year, order not determinable
2021.findings-emnlp.347 (2021 (year only))
Attend, Memorize and Generate: Towards Faithful Table-to-Text Generation in Few Shots

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

The representation learning on textual graph is to generate low-dimensional embeddings for the nodes based on the individual textual features and the neighbourhood information. Recent breakthroughs on pretrained language models and graph neural networks push forward the development of corresponding techniques. The existing works mainly rely on the cascaded model architecture: the textual features of nodes are independently encoded by language models at first; the textual embeddings are aggregated by graph neural networks afterwards. However, the above architecture is limited due to the independent modeling of textual features. In this work, we propose GraphFormers, where layerwise GNN components are nested alongside the transformer blocks of language models. With the proposed architecture, the text encoding and the graph aggregation are fused into an iterative workflow, making each node's semantic accurately comprehended from the global perspective. In addition, a progressive learning strategy is introduced, where the model is successively trained on manipulated data and original data to reinforce its capability of integrating information on graph. Extensive evaluations are conducted on three large-scale benchmark datasets, where GraphFormers outperform the SOTA baselines with comparable running efficiency. The source code is released at https://github.com/microsoft/GraphFormers .

For agents

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

get_harvested_code_for_paper("2105.02605")
get_code_for_paper("2105.02605")
have("2105.02605")

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

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

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

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

Connect an agent — have() is free.