[Paper Review] GRPE: Relative Positional Encoding for Graph Transformer
This paper proposes Graph Relative Positional Encoding (GRPE), a novel relative positional encoding method for Graph Transformers that jointly models node-topology and node-edge interactions without graph linearization. By learning topology and edge encodings that interact with node features in both attention maps and value representations, GRPE achieves state-of-the-art performance on graph classification, regression, and node classification benchmarks, including SOTA results on PCQM4Mv2 and competitive results on ZINC and MolHIV.
We propose a novel positional encoding for learning graph on Transformer architecture. Existing approaches either linearize a graph to encode absolute position in the sequence of nodes, or encode relative position with another node using bias terms. The former loses preciseness of relative position from linearization, while the latter loses a tight integration of node-edge and node-topology interaction. To overcome the weakness of the previous approaches, our method encodes a graph without linearization and considers both node-topology and node-edge interaction. We name our method Graph Relative Positional Encoding dedicated to graph representation learning. Experiments conducted on various graph datasets show that the proposed method outperforms previous approaches significantly. Our code is publicly available at https://github.com/lenscloth/GRPE.
Motivation & Objective
- To address the limitation of existing graph positional encoding methods that either linearize graphs (losing topological precision) or use bias terms (losing tight feature-encoding integration).
- To develop a positional encoding method that preserves structural information by modeling both relative node-topology and node-edge relationships in Graph Transformers.
- To enable effective integration of graph topology and edge types directly within the self-attention mechanism, enhancing representation learning.
Proposed method
- Introduces two learnable positional encoding vectors: topology encoding $\mathcal{P}$ for capturing relative topological distances (up to $L$-hop shortest paths), and edge encoding $\mathcal{E}$ for modeling different edge types.
- Embeds topology and edge encodings into both the attention map and value computation, enabling interaction between node features and structural encodings during self-attention.
- Uses a maximum shortest path distance $L$ to control the receptive field of topology encoding, with $L=5$ used in experiments.
- Applies the positional encodings via learnable projections that interact with query, key, and value vectors in the scaled dot-product attention mechanism.
- Employs a virtual node as a global context in the attention mechanism, allowing deeper layers to attend to the entire graph.
- Supports both shared and layer-specific encodings, with ablation showing minimal performance gain from sharing, suggesting independent encodings are more effective.
Experimental results
Research questions
- RQ1Can a relative positional encoding method that jointly models node-topology and node-edge interactions outperform absolute positional encoding or bias-based relative encoding in Graph Transformers?
- RQ2How does the integration of topology and edge encodings into both attention maps and value representations affect model performance on graph representation learning tasks?
- RQ3What is the optimal maximum shortest path distance $L$ for capturing structural information in the topology encoding without overfitting or redundancy?
- RQ4Does sharing topology and edge encodings across all transformer layers degrade performance, and if so, by how much?
- RQ5How does the attention mechanism of GRPE evolve across layers, and does it enable global graph awareness in deeper layers?
Key findings
- On the PCQM4Mv2 dataset, the large GRPE model achieved the best validation MAE score, demonstrating state-of-the-art performance on the largest molecule property prediction benchmark.
- On the ZINC dataset, GRPE-Small achieved a test MAE of 0.093, significantly outperforming the baseline Transformer without positional encoding (0.668) and ablation variants.
- The ablation study showed that combining both topology and edge encodings reduced MAE from 0.267 (topology only) to 0.147 (both without value encoding), and further to 0.093 when graph-encoded value was added.
- Increasing the maximum shortest path distance $L$ improved AUC performance up to $L=4$, but further increases to $L=5$ provided no additional gain, indicating $L=4$ is optimal for generalization.
- Sharing topology and edge encodings across layers improved MAE slightly (0.101 to 0.094) but increased parameter count, suggesting independent encodings are more efficient.
- Visualization of attention maps confirmed that deeper layers attend more to the virtual node, indicating progressive global context aggregation, with attention focusing on neighbors in early layers.
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.