A Generalization of Transformer Networks to Graphs

Vijay Prakash Dwivedi, Xavier Bresson
12/17/2020
cs.LG

Official code: graphdeeplearning/graphtransformer (1,025 stars, MIT, last commit 2021-07-27).

Abstract

We propose a generalization of transformer neural network architecture for arbitrary graphs. The original transformer was designed for Natural Language Processing (NLP), which operates on fully connected graphs representing all connections between the words in a sequence. Such architecture does not leverage the graph connectivity inductive bias, and can perform poorly when the graph topology is important and has not been encoded into the node features. We introduce a graph transformer with four new properties compared to the standard model. First, the attention mechanism is a function of the neighborhood connectivity for each node in the graph. Second, the positional encoding is represented by the Laplacian eigenvectors, which naturally generalize the sinusoidal positional encodings often used in NLP. Third, the layer normalization is replaced by a batch normalization layer, which provides faster training and better generalization performance. Finally, the architecture is extended to edge feature representation, which can be critical to tasks s.a. chemistry (bond type) or link prediction (entity relationship in knowledge graphs). Numerical experiments on a graph benchmark demonstrate the performance of the proposed graph transformer architecture. This work closes the gap between the original transformer, which was designed for the limited case of line graphs, and graph neural networks, that can work with arbitrary graphs. As our architecture is simple and generic, we believe it can be used as a black box for future applications that wish to consider transformer and graphs.

View on arXivView PDF

Code Implementations(1)

MIT

Graph Transformer Architecture. Source code for "A Generalization of Transformer Networks to Graphs", DLG-AAAI'21.

1,025150Shell, PythonDec 17, 20205 years agoMIT
aaaiattentiongraph-deep-learninggraph-neural-networksgraph-transformer+3 more

Similar Papers

Cite this paper

@article{dwivedi2020generalization,
  title  = {A Generalization of Transformer Networks to Graphs},
  author = {Vijay Prakash Dwivedi and Xavier Bresson},
  year   = {2020},
  eprint = {2012.09699},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2012.09699}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2012.09699.svg)](https://codeofpaper.com/paper/2012.09699)

Discussion