All models

GraphiT

A graph transformer whose attention is weighted by graph kernels and whose inputs add local path features.

Graphs and geometry · 546 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 (27 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
354.6K
Operations
546
Framework
PyTorch
Recurrent
No
Published
2021
Cited by
294 (as of 29 November 2026)
Authors
Grégoire Mialon, Dexiong Chen, Margot Selosse, Julien Mairal
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
m17166
Graph hash
a0421ed60eb50ed9650b46a235147379163cfbcf97e0003d59c6eb568203087b
Skeleton hash
1d481baa1ebd19e80df38a95a5630520307330b7c7ecedb98821237902805fb1
Architecture hash
ce9d7ded7450412b0db54ab8f291c564ccd9e861c0b0fbc78993da32adea0aab
Diagram SHA-256
bbbfe35e9688e69455c1d2d0ee25e837440d41171d4728c6dda0d5561d68a0af
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

GraphiT is a transformer designed for graph-structured data. It views a graph as a set of node features and brings the graph structure back in through two ingredients, which may be combined or used independently. The paper reports that this approach is able to outperform representations learned with classical graph neural networks (GNNs).

The first ingredient is a relative positional encoding: the self-attention scores are modulated by a positive definite kernel on the graph, such as a diffusion kernel, so the weight between two nodes multiplies a kernel based on positions by a kernel based on content. The second follows the principle of graph convolutional kernel networks (GCKN), enumerating and encoding small substructures such as paths; each node is then encoded as the concatenation of its original features and those produced by one GCKN layer.

For the ZINC dataset the paper trains GraphiT with 10 layers, 8 heads and 64 hidden dimensions, and reports that it outperforms all previous baseline methods there by a large margin. The paper also notes that the model admits visualization mechanisms for interpreting graph motifs explaining the predictions.

Key idea. GraphiT encodes graph structure in a transformer through kernel-based relative positional encoding in the attention scores and through features that encode local substructures such as short paths.

  • GraphiT
  • graph transformer
  • encoding graph structure in transformers
  • kernel positional encoding
  • diffusion kernel
  • GCKN features
  • ZINC regression
  • graph classification

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

Cite the paper

@misc{mialon2021graphitencodinggraphstructure,
      title={GraphiT: Encoding Graph Structure in Transformers}, 
      author={Grégoire Mialon and Dexiong Chen and Margot Selosse and Julien Mairal},
      year={2021},
      eprint={2106.05667},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2106.05667}, 
}