[Paper Review] A Generalization of Transformer Networks to Graphs
This paper generalizes the Transformer architecture to arbitrary graphs by incorporating graph sparsity, Laplacian eigenvector positional encodings, batch normalization, and optional edge feature processing, showing competitive performance on graph benchmarks.
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.
Motivation & Objective
- Motivate adapting the Transformer to leverage graph structure and inductive biases in arbitrary graphs.
- Introduce Graph Transformer layers that attend to local graph neighborhoods rather than full connectivity.
- Incorporate Laplacian eigenvector-based positional encodings to capture node positions on graphs.
- Provide an architecture variant that supports edge features to exploit pairwise edge information.
- Demonstrate competitive performance on standard graph benchmarks compared to GNN baselines.
Proposed method
- Embed node and edge features with linear projections to a common hidden dimension.
- Add Laplacian eigenvector-based positional encodings to input node features.
- Compute multi-head attention where each head attends to local neighbors with softmax over neighbors.
- Include residual connections and normalization (BatchNorm or LayerNorm) around FFNs.
- Provide a Graph Transformer variant that jointly updates node and edge representations with dedicated FFNs.
- Evaluate on ZINC, PATTERN, and CLUSTER datasets with both sparse and full-graph settings.
Experimental results
Research questions
- RQ1Can a Transformer-like attention mechanism be effectively localized to graph neighborhoods to exploit sparsity?
- RQ2Do Laplacian eigenvector positional encodings improve performance for graph tasks over other positional encodings?
- RQ3Does replacing layer normalization with batch normalization improve training and generalization in graph transformers?
- RQ4Does incorporating edge features into Graph Transformer improve performance on datasets with rich edge information?
Key findings
- The Graph Transformer with Laplacian PE and BatchNorm outperforms baseline isotropic and anisotropic GNNs on all three datasets.
- Sparse graph configurations yield better performance than full graphs, validating the sparsity inductive bias.
- Graph Transformer with edge features closely approaches the performance of the best GNN (GatedGCN) on ZINC.
- LapPExam-based encodings (Laplacian PEs) outperform WL-PE and intimacy-based encodings in Graph-BERT for these tasks.
- Using BatchNorm rather than LayerNorm generally improves training efficiency and generalization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.