All models

NAGphormer

A graph Transformer that turns each node's multi-hop neighborhood into a token sequence for node classification.

Graphs and geometry · 46 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (22 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
2.5M
Operations
46
Framework
PyTorch
Recurrent
No
Published
ICLR 2023
Cited by
41 (as of 27 October 2026)
Authors
Jinsong Chen, Kaiyuan Gao, Gaichao Li, Kun He
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m18629
Graph hash
503dd7a7199c75efaf3c8e02990d4857b808061b7b7a0600bbcee11cc6a6a857
Skeleton hash
4fd7ed0686d8605a59623b50d78347f8586bc477c5a5d8be052b6f4d7158936d
Architecture hash
6ba571289110ba2af309f81a91afca9e2b7a67f3c217791b1481300aba7b40d0
Diagram SHA-256
299120f2c49a23beaca4d2cf9f846508370db8b51ca8773599e741be27e1ab3d
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

NAGphormer, short for Neighborhood Aggregation Graph Transformer, is a graph Transformer for node classification in large graphs. The paper observes that existing graph Transformers treat nodes as independent tokens and build a single long sequence of all node tokens, which is hard to scale because self-attention is quadratic in the number of nodes.

NAGphormer instead treats each node as a sequence of tokens of its own. For each node, a module called Hop2Token aggregates the neighborhood features from different hops into different representations, which become the token vectors of one input. Because of this, the model can be trained in mini-batches and can scale to large graphs.

The paper also shows mathematically that, compared with the decoupled Graph Convolutional Network, NAGphormer could learn more informative node representations from multi-hop neighborhoods. On benchmark datasets from small to large, it reports that NAGphormer consistently outperforms existing graph Transformers and mainstream GNNs. The paper was accepted by ICLR 2023.

Key idea. NAGphormer treats each node as a sequence of tokens built by its Hop2Token module, so a graph Transformer can be trained in mini-batches on large graphs.

  • NAGphormer
  • Neighborhood Aggregation Graph Transformer
  • Hop2Token
  • tokenized graph transformer
  • graph transformer
  • node classification
  • large graphs

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{chen2023nagphormertokenizedgraphtransformer,
      title={NAGphormer: A Tokenized Graph Transformer for Node Classification in Large Graphs}, 
      author={Jinsong Chen and Kaiyuan Gao and Gaichao Li and Kun He},
      year={2023},
      eprint={2206.04910},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2206.04910}, 
}