An Empirical Study of Retrieval-enhanced Graph Neural Networks

Dingmin Wang, Shengchao Liu, Hanchen Wang, Bernardo Cuenca Grau, Linfeng Song, Jian Tang, Song Le, Qi Liu

TL;DR

Graph Neural Networks (GNNs) often struggle with limited expressive power and "forgetting" training data, especially when dealing with rare or long-tailed labels. This paper introduces GRAPHRETRIEVAL, a model-agnostic framework that enhances GNNs by retrieving similar graphs and their ground-truth labels from the training set at inference time. By combining initial GNN predictions with this retrieved data via a self-attention adapter, the approach delivers substantial performance gains across 13 diverse datasets without significantly increasing model size.

What Problem Does This Paper Address?

Most modern Graph Neural Networks rely on a recursive neighborhood aggregation scheme known as message passing. While effective, this approach bounds their theoretical expressive power to the first-order Weisfeiler-Lehman (1-WL) graph isomorphism test.

Furthermore, standard supervised learning typically discards the training dataset once training is complete, forcing the model to rely entirely on its learned parameters. This often leads to "catastrophic forgetting," where the model fails to retain specific training examples. This limitation is particularly severe for datasets with long-tailed label distributions, where rare classes or values are poorly captured by the model's weights.

While retrieval-augmented models have revolutionized natural language processing (NLP) and computer vision, how to effectively bring non-parametric retrieval into the graph domain remained an open question.

Methods

The authors propose GRAPHRETRIEVAL, a plug-and-play framework executed in two distinct phases:

  1. Initial Training & Indexing: A baseline GNN model ($M$) is trained in a standard supervised fashion. Once trained, its parameters are frozen. The model is then used to generate graph-level embeddings for the entire training dataset. These embeddings are stored as key-value pairs (where the key is the embedding and the value is the graph-label pair) in a fast vector database using FAISS to enable Maximum Inner Product Search (MIPS).
  2. Self-Attention Based Adapter: At test time, an unseen input graph is passed through the GNN to get an initial prediction and embedding. The framework queries the FAISS index using $L_2$ distance to retrieve the top-$k$ most similar training graphs and their true labels. A lightweight self-attention adapter then computes the final prediction as a weighted sum of the initial prediction and the retrieved labels.

To prevent overfitting during the adapter's training phase (where a training graph would perfectly retrieve itself), the authors implement a Retrieval Dropout strategy, which fetches $k+1$ graphs and discards the exact match.

The architecture of this attention mechanism is outlined below:

Figure 2: Scheme on Scaled Dot Product Attention.

Datasets

The framework was extensively evaluated on 13 benchmark datasets spanning multiple domains:

  • Molecular Property Prediction (8 datasets): BBBP, Tox21, ToxCast, SIDER, ClinTox, MUV, HIV, and BACE (characterized by highly imbalanced binary labels).
  • Computer Vision (2 datasets): MNIST and CIFAR10, converted into grid-structured graphs with fixed topologies.
  • Chemical Reactions/Catalysts (1 dataset): USPTO, a highly multi-class dataset (888 classes) with a severe long-tailed distribution.
  • Quantum Chemistry (2 datasets): PCQM4M and PCQM4Mv2, large-scale regression datasets consisting of millions of molecular graphs.

Key Insights and Ideas

  • Memory over Pure Parametrization: Keeping the training set explicitly accessible at test time acts as an external memory, helping the model bypass the structural representation limits of standard message passing.
  • A Cure for the Long Tail: Standard GNNs struggle to generalize on rare classes because neural network weights naturally favor majority patterns. Retrieval mitigates this by directly surfacing the few relevant rare examples during inference.
  • Attention is Non-Negotiable: Simply averaging the labels of retrieved graphs actually degrades performance due to noise. The self-attention adapter is critical because it learns to assign lower weights to irrelevant or noisy retrievals, ensuring the model is robust.

Key Results

GRAPHRETRIEVAL consistently boosted the performance of three strong backbone architectures: GCN, GIN, and PNA.

  • Long-Tail Breakthroughs: On the PCQM4M regression dataset, GRAPHRETRIEVAL achieved a massive 17% improvement in Mean Absolute Error (MAE) within the long-tailed numerical ranges, compared to just a 2.6% improvement in the well-represented ranges.
  • Multi-Class Scaling: On the imbalanced USPTO dataset, the framework achieved a dramatic accuracy boost, particularly for rare classes with fewer than 100 training samples.
  • Synergy is Key: Pure retrieval methods (like k-NN or majority voting) without a base GNN underperformed significantly, proving that the combination of parametric learning (the GNN) and non-parametric retrieval is what drives the performance gains.

Limitations and Future Work

  • Graph-Level Focus: The current framework is designed exclusively for graph-level classification and regression tasks. It does not yet support node-level or edge-level prediction tasks (such as node classification or link prediction).
  • Downstream of Embedding Quality: The retrieval quality is fundamentally bottlenecked by the base GNN's embeddings. If the base GNN suffers from inherent issues like over-smoothing or over-squashing, the retrieved graphs may not be truly semantically similar.
  • Future Directions: The authors suggest extending this approach to node-level tasks and integrating it with advanced 3D geometric modeling methods.

Summary updated

BibTeX
@inproceedings{wang2023empirical,
  author = {Dingmin Wang and Shengchao Liu and Hanchen Wang and Bernardo Cuenca Grau and Linfeng Song and Jian Tang and Song Le and Qi Liu},
  title = {{An Empirical Study of Retrieval-enhanced Graph Neural Networks}},
  booktitle = {ECAI},
  year = {2023},
  doi = {10.3233/faia230547},
}
Figure