Abstract
Graph Neural Networks (GNNs) have become the standard for graph representation learning. However, most GNNs rely on a recursive neighborhood aggregation scheme (message passing) that limits their theoretical expressive power to the first-order Weisfeiler-Lehman (1-WL) test. Furthermore, GNNs often struggle with "catastrophic forgetting" and poor performance on long-tailed label distributions. This paper introduces GRAPHRETRIEVAL, a model-agnostic framework that enhances GNNs by retrieving similar annotated examples from the training set during inference. By treating training data as an external memory, GRAPHRETRIEVAL bypasses traditional architectural limits. Our empirical study across 13 datasets demonstrates substantial improvements, particularly as a remedy for alleviating the long-tailed label distribution problem.
Introduction: The Limits of Message Passing
Modern GNN architectures are primarily built on the message-passing paradigm. While effective, this approach has a known theoretical ceiling: it cannot distinguish graph structures more complex than those identifiable by the 1-WL isomorphism test. Additionally, as models are trained, they often fail to retain specific nuances of rare training examples, leading to poor generalization on "long-tail" data—classes or values that appear infrequently in the dataset.
While retrieval-augmented generation (RAG) has transformed Natural Language Processing, its application to non-Euclidean graph data has been less explored. GRAPHRETRIEVAL addresses this gap by allowing a GNN to "look up" similar historical examples to inform its current prediction.
Methodology: The GRAPHRETRIEVAL Framework
GRAPHRETRIEVAL operates in two distinct phases to augment any backbone GNN (e.g., GCN, GIN, or PNA):
- Indexing: A backbone GNN is trained on the target dataset. Once trained, every graph in the training set is passed through the model to generate a vector embedding. These embeddings, paired with their ground-truth labels, are stored in a high-speed FAISS index.
- Retrieval and Adaptation: During inference, the system retrieves the $k$ most similar graphs from the index for a given input. A lightweight Self-Attention Adapter then compares the input graph's embedding against these retrieved neighbors.
The adapter is critical; the authors found that simple averaging of retrieved labels is insufficient. The attention mechanism allows the model to ignore "noisy" neighbors and focus on truly relevant structural analogs. To ensure the model learns to generalize rather than just memorizing itself, the authors employ Retrieval Dropout during the training of the adapter.
Experimental Setup and Results
The framework was rigorously tested on 13 benchmarks, including molecular classification (MoleculeNet), computer vision (MNIST/CIFAR10 as graphs), and large-scale chemistry regression (PCQM4Mv2).
Performance Across Tasks
GRAPHRETRIEVAL consistently outperformed baseline GNNs across all task types. In binary classification, it improved the GIN model's ROC-AUC on the BBBP dataset by 2%. In complex multi-class scenarios like the USPTO dataset (888 classes), the retrieval-enhanced PNA model reached 41.6% accuracy, a significant jump from the 35.2% baseline.
The Long-Tail Remedy
The most significant impact was observed in long-tailed distributions. As shown in Figure (b) above, while standard GCN accuracy plummets for rare classes (c4, c5), the retrieval-enhanced version maintains significantly higher performance. Similarly, in regression tasks (Figure c), the improvement in Mean Absolute Error (MAE) for common value ranges was a modest 2.6%, but it surged to 17.4% for values in the sparse [20, 30) range. This suggests that explicit memory is far more effective at handling rare edge cases than fixed model weights alone.
Discussion and Future Work
GRAPHRETRIEVAL proves that external memory is a powerful, model-agnostic tool for graph learning. It is computationally efficient, as the FAISS lookup and single-layer adapter add negligible overhead. However, the system's success is inherently tied to the quality of the backbone GNN's embeddings; if the base model suffers from over-smoothing, the retrieval process will yield poor matches.
Future research directions include extending this framework to node-level tasks and incorporating 3D geometric information to further refine the similarity search for molecular and biological data.
Summary updated