Abstract
Recently, transformers have shown promising performance in learning graph representations. However, there are still some challenges when applying transformers to real-world scenarios due to the fact that deep transformers are hard to train from scratch and the quadratic memory consumption w.r.t. the number of nodes. In this paper, we propose Graph Masked Autoencoders (GMAEs), a self-supervised transformer-based model for learning graph representations. To address the above two challenges, we adopt the masking mechanism and the asymmetric encoder-decoder design. Specifically, GMAE takes partially masked graphs as input, and reconstructs the features of the masked nodes. The encoder and decoder are asymmetric, where the encoder is a deep transformer and the decoder is a shallow transformer. The masking mechanism and the asymmetric design make GMAE a memory-efficient model compared with conventional transformers. We show that, when serving as a conventional self-supervised graph representation model, GMAE achieves state-of-the-art performance on both the graph classification task and the node classification task under common downstream evaluation protocols. We also show that, compared with training in an end-to-end manner from scratch, we can achieve comparable performance after pre-training and fine-tuning using GMAE while simplifying the training process.
Introduction: Overcoming the Limitations of GCNs and Transformers
Graph Convolutional Networks (GCNs) have long been the standard for graph mining. However, they are often plagued by over-smoothing: as layers are added, node representations tend to converge and become indistinguishable. This effectively limits most GCNs to shallow architectures that cannot capture long-range, global dependencies. While Transformers offer a solution through their global self-attention mechanism, they introduce two significant hurdles: training instability when learning from scratch and a quadratic memory cost ($O(N^2)$) relative to the number of nodes.
Graph Masked Autoencoders (GMAEs) address these issues by bringing the efficiency of asymmetric masked pre-training to Graph Transformers. By masking a large percentage of nodes and utilizing a deep-encoder/shallow-decoder architecture, GMAE achieves state-of-the-art performance while significantly reducing memory overhead.
The GMAE Framework
GMAE is a self-supervised framework inspired by the Masked Autoencoders (MAE) used in computer vision. The workflow consists of four primary stages:
- Random Masking: A high percentage of node features (often 50% to 70%) is randomly masked. Crucially, the graph structure (edges) remains intact to provide structural context.
- Asymmetric Encoding: Only the unmasked nodes are processed by a deep Transformer encoder (using the Graphormer backbone). By ignoring masked nodes, the encoder drastically reduces its memory footprint.
- Feature Reconstruction: A shared, learnable "mask token" is inserted for the missing nodes. A shallow Transformer decoder then attempts to reconstruct the original features of these masked nodes.
- Positional Encodings: To capture graph topology, the model utilizes centrality, spatial, and edge encodings, allowing the Transformer to understand the graph structure despite the lack of a natural sequence order.
The asymmetric design is critical: by keeping the decoder shallow (e.g., only 2 layers) and the encoder deep, the model forces the encoder to learn highly compressed, meaningful representations. This ensures that the computational "heavy lifting" is focused on the encoder, which is the component used for downstream tasks.
Performance and Efficiency
GMAE was evaluated across diverse benchmarks, including graph classification (e.g., PROTEINS, MUTAG), node classification (e.g., Cora, PubMed), and graph regression (ZINC).
Key Results
- SOTA Performance: GMAE outperformed popular self-supervised baselines like GraphCL and InfoGraph on the majority of classification datasets tested.
- Pre-training vs. End-to-End: On the ZINC molecular regression task, GMAE pre-training followed by fine-tuning achieved a Test MAE of 0.120, surpassing a standard Graphormer trained from scratch (0.122) while simplifying the training regime.
- Memory Efficiency: The model demonstrates a significant reduction in memory usage. For a graph with 110 nodes, GMAE shows a 20% reduction in memory compared to standard Graphormer, a gap that widens as node counts increase.
Key Insights
- Redundancy in Graphs: One of the most notable findings is that masking up to 90% of the graph can still yield excellent results. This suggests that graph data is often highly redundant.
- Global Context: While GCNs excel at local aggregation, GMAE’s Transformer backbone allows it to capture global patterns. The masking task forces the model to leverage these global patterns to "guess" the missing local features.
- Scalability: Because the encoder only processes a fraction of the nodes, GMAE can scale to larger graphs or deeper architectures that would typically trigger "out of memory" errors on standard hardware.
Conclusion and Future Work
GMAE successfully scales Graph Transformers by leveraging asymmetric masked autoencoding. While currently focused on feature masking, future work may explore masking graph structure (edges) to further enhance robustness. Additionally, while GMAE improves efficiency, the underlying $O(N^2)$ complexity for unmasked nodes suggests that integrating sparse attention mechanisms could be a valuable next step for even larger-scale applications.
Summary updated