
Graphormer molecular
Graphs and geometry305 ops10.3M params
A plain Transformer encoder taught graph structure through centrality, shortest-path and edge attention biases.
Graphs and geometry · 1,043 operations Checked
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.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
About this model's family
Graphormer is a graph Transformer built upon the standard Transformer architecture, aimed at graph representation learning tasks. The question behind the title is why the Transformer, dominant elsewhere, had not achieved competitive performance on popular leaderboards of graph-level prediction compared to mainstream GNN variants. The key insight is that the structural information of a graph has to be encoded effectively into the model.
Centrality Encoding assigns each node two real-valued embedding vectors according to its indegree and outdegree and simply adds them to the node features at the input. Spatial Encoding uses the distance of the shortest path between two connected nodes, with a special value of -1 when they are not connected. Each feasible distance value gets a learnable scalar that serves as a bias term in the self-attention module. If that bias is learned to decrease with distance, each node will likely pay more attention to the nodes near it and less to those far away. Edge Encoding computes an average of the dot-products of the edge feature and a learnable embedding along the shortest path, and feeds it in as another bias term to the attention module. The layer itself applies layer normalization before the multi-head self-attention and feed-forward blocks instead of after. A special node called [VNode] is added and connected to each node individually. The representation of the entire graph is the node feature of [VNode] in the final layer. By choosing proper weights and distance function, a Graphormer layer can represent the AGGREGATE and COMBINE steps of popular GNN models such as GIN, GCN and GraphSAGE.
The paper primarily reports two model sizes on PCQM4M-LSC: Graphormer with L = 12 and d = 768, and GraphormerSMALL with L = 6 and d = 512. Compared to the previous state-of-the-art GNN architecture, Graphormer surpasses GIN-VN by a large margin, an 11.5% relative decline in validate MAE. With an ensemble with ExpC the team got a 0.1200 MAE on the complete test set and won first place of the graph-level track in the OGB Large-Scale Challenge. In the ablations, degree-based centrality encoding yields a large margin performance boost over models without centrality information. The authors note that the quadratic complexity of the self-attention module restricts Graphormer's application on large graphs. The Hugging Face model card adds that the model is resource intensive for large graphs and might lead to OOM errors.
Key idea. A standard Transformer made graph-aware through three structural encodings, centrality, spatial and edge, that works surprisingly well across popular graph benchmarks.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{ying2021transformersreallyperformbad,
title={Do Transformers Really Perform Bad for Graph Representation?},
author={Chengxuan Ying and Tianle Cai and Shengjie Luo and Shuxin Zheng and Guolin Ke and Di He and Yanming Shen and Tie-Yan Liu},
year={2021},
eprint={2106.05234},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2106.05234},
}