Abstract
Standard Graph Neural Networks (GNNs) rely on local message passing, which limits their ability to capture long-range dependencies without suffering from oversmoothing or oversquashing. We introduce GraphTrans, a hybrid architecture that combines GNNs with Transformers. GraphTrans utilizes a GNN submodule to learn local structural representations and a Transformer submodule to perform global reasoning across all nodes. Our approach achieves state-of-the-art results on several benchmarks, demonstrating the power of global attention in graph representation learning.
Introduction
GNNs have become the standard for processing graph-structured data. However, their reliance on local neighborhoods creates a "near-sightedness" problem. To capture relationships between nodes $K$ hops apart, a GNN requires $K$ layers. Increasing depth often leads to oversmoothing, where node features become indistinguishable, or oversquashing, where information from a large neighborhood is squeezed into a fixed-size vector, creating a bottleneck. GraphTrans addresses these limitations by allowing nodes to interact globally, regardless of their topological distance.
Methodology: The GraphTrans Architecture
GraphTrans is composed of two primary stages designed to separate local feature extraction from global context modeling.
- GNN Submodule: A standard GNN (e.g., GCN or GIN) processes the input graph for a few layers to capture local structural information and neighborhood geometry.
- Transformer Submodule: The resulting node embeddings are flattened into a sequence. To maintain permutation invariance, positional encodings are omitted. This allows the Transformer to learn pairwise relationships between all nodes via self-attention without being constrained by the graph's edges.
- <CLS> Readout: Inspired by NLP models like BERT, a learnable
<CLS>token is prepended to the node sequence. After the Transformer layers, the embedding of this token serves as the final representation of the entire graph for classification.
Experimental Evaluation
We evaluated GraphTrans on diverse benchmarks, ranging from small biochemical datasets to large-scale code analysis tasks:
- Biochemical Datasets: NCI1 and NCI109 for anti-cancer activity prediction.
- OGBG-Molpcba: A large-scale molecular dataset from the Open Graph Benchmark (OGB).
- OGBG-Code2: Abstract Syntax Trees (ASTs) of Python code, where long-range dependencies are critical for predicting method names.
GraphTrans achieved state-of-the-art (SOTA) performance on OGBG-Code2 (F1 score of 0.1830) and OGBG-Molpcba. It proved more parameter-efficient than deep GNN baselines and scaled effectively to graphs with over 1,000 nodes.
Discussion and Key Insights
The success of GraphTrans stems from the specialization of its components. The GNN acts as a local feature extractor, while the Transformer provides a "global perspective."
The attention mechanism allows the model to bypass the graph's edges for high-level reasoning. Interestingly, the <CLS> token learns to selectively attend to the most informative nodes, outperforming traditional global pooling methods. This structure-agnostic approach suggests that for complex graph tasks, explicit topology can sometimes be a hindrance to global information flow; letting the Transformer learn relationships from scratch via attention is often more effective.
Conclusion
GraphTrans bridges the gap between local structural learning and global context modeling. By stacking a Transformer on top of a GNN, we overcome the inherent receptive field limitations of traditional message-passing architectures. Future work will explore more efficient attention mechanisms for massive graphs and the application of this hybrid model to node-level tasks.
Summary updated