arXiv(opens in a new tab)Computer ScienceDec 2020Cited by 23 papers on PaperVantageClassic Paper

Manuscript Offprint

arXiv:2012.09699

A Generalization of Transformer Networks to Graphs

Vijay Prakash Dwivedi, X. Bresson

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.

¶ School of Computer Science and Engineering, Nanyang Technological University, Singapore vijaypra001@e.ntu.edu.sg, xbresson@ntu.edu.sg

1 Introduction

There has been a tremendous success in the field of natural language processing (NLP) since the development of Transformers (Vaswani et al. 2017) which are currently the best performing neural network architectures for handling long-term sequential datasets such as sentences in NLP. This is achieved by the use of attention mechanism (Bahdanau, Cho, and Bengio 2014) where a word in a sentence attends to each other word and combines the received information to generate its abstract feature representations. From a perspective of message-passing paradigm (Gilmer et al. 2017) in graph neural networks (GNNs), this process of learning word feature representations by combining feature information from other words in a sentence can alternatively be viewed as a case of a GNN applied on a fully connected graph of words (Joshi 2020). Transformers based models have led to state-of-the-art performance on several NLP applications (Devlin et al. 2018; Radford et al. 2018; Brown et al. 2020). On the other hand, graph neural networks (GNNs) are shown to be the most effective neural network architectures on graph datasets and have achieved significant success on a wide range of applications, such as in knowledge graphs (Schlichtkrull et al. 2018; Chami et al. 2020), in social sciences (Monti et al. 2019), in physics (Cranmer et al. 2019; Sanchez-Gonzalez et al. 2020), etc. In particular, GNNs exploit the given arbitrary graph structure while learning the feature representations for nodes and edges and eventually the learned representations are used for downstream tasks. In this work, we explore inductive biases at the convergence of these two active research areas in deep learning towards presenting an improved version of Graph Transformer (see Figure 1) which extends the key design components of the NLP transformers to arbitrary graphs.

Figure 1: Block Diagram of Graph Transformer with Laplacian Eigvectors (λ\lambda) used as positional encoding (LapPE). LapPE is added to input node embeddings before passing the features to the first layer. Left: Graph Transformer operating on node embeddings only to compute attention scores; Right: Graph Transformer with edge features with designated feature pipeline to maintain layer wise edge representations. In this extension, the available edge attributes in a graph is used to explicitly modify the corresponding pairwise attention scores.

References (40)

Cited by (23)