Retrieval Augmented Generation for Dynamic Graph Modeling

Yuxia Wu, Yuan Fang, Lizi Liao · DOI

Abstract

Dynamic graph modeling is crucial for analyzing evolving patterns in various applications. Existing approaches often integrate graph neural networks with temporal modules or redefine dynamic graph modeling as a generative sequence task. However, these methods typically rely on isolated historical contexts of the target nodes from a narrow perspective, neglecting occurrences of similar patterns or relevant cases associated with other nodes. In this work, we introduce the Retrieval-Augmented Generation for Dynamic Graph Modeling (RAG4DyG) framework, which leverages guidance from contextually and temporally analogous examples to broaden the perspective of each node. This approach presents two critical challenges: (1) How to identify and retrieve high-quality demonstrations that are contextually and temporally analogous to dynamic graph samples? (2) How can these demonstrations be effectively integrated to improve dynamic graph modeling? To address these challenges, we propose RAG4DyG, which enriches the understanding of historical contexts by retrieving and learning from contextually and temporally pertinent demonstrations. Specifically, we employ a time- and context-aware contrastive learning module to identify and retrieve relevant cases for each query sequence. Moreover, we design a graph fusion strategy to integrate the retrieved cases, thereby augmenting the inherent historical contexts for improved prediction. Extensive experiments on real-world datasets across different domains demonstrate the effectiveness of RAG4DyG for dynamic graph modeling.

Introduction

Dynamic graphs, such as social networks, e-commerce platforms, and citation networks, are constantly evolving. Accurately modeling these changes is essential for tasks like link prediction and recommendation. Traditional approaches generally fall into two categories: Graph Neural Networks (GNNs) that focus on local neighborhoods, and sequence models that treat a node’s history as a series of events.

However, these models often suffer from a "local context" bottleneck. They are frequently "blind" to emerging patterns occurring elsewhere in the graph. For instance, in an inductive scenario where a new user joins a network, the model has no historical data for that specific node, making accurate predictions difficult. Furthermore, standard GNNs can suffer from "over-smoothing" when attempting to capture long-range dependencies. RAG4DyG addresses these issues by asking: Can we look at how similar nodes behaved in the past to better predict what a specific node will do next?

Comparison between RAG in NLP and RAG in dynamic graphs

Methodology

The RAG4DyG framework adapts the "Retrieval-Augmented Generation" (RAG) paradigm from natural language processing to the domain of dynamic graphs. It consists of three primary components:

1. Time- and Context-Aware Retriever

The retriever identifies historical interaction sequences that are both structurally similar (context) and temporally close to the current query. To achieve this, RAG4DyG employs a contrastive learning strategy. It uses a time-decay function to ensure that recent, relevant demonstrations are prioritized over older, less relevant ones.

Time- and context-aware contrastive learning for retrieval

2. Graph Fusion-based Generator

In NLP, retrieved sequences are often simply concatenated. However, for graphs, this can lead to "input bloat" and ignores the underlying structural topology. RAG4DyG instead fuses the retrieved demonstrations into a summary graph. This summary graph preserves the structural relationships of the demonstrations, allowing for more effective feature extraction.

3. Model Pipeline

The overall pipeline involves processing the summary graph with a Graph Convolutional Network (GCN) to create an enriched representation. This representation is then prepended to the target node's sequence. Finally, a Transformer-based generator (utilizing the SimpleDyG architecture) predicts the next set of interactions.

Experimental Results

The authors evaluated RAG4DyG on six diverse real-world datasets, including social networks (UCI, Enron), citation networks (Hepth), conversation logs (MMConv), behavioral data (Wikipedia), and hyperlink networks (Reddit).

Performance and Inductive Strength

RAG4DyG consistently outperformed state-of-the-art baselines, such as TGN and DySAT.

  • Accuracy: On the UCI dataset, it achieved a Recall@5 of 0.111, surpassing the best baseline.
  • Inductive Settings: The most significant gains were observed in inductive settings. On the Reddit dataset, RAG4DyG improved the NDCG@5 from 0.134 to 0.143, demonstrating its ability to handle nodes with no prior history by leveraging global patterns.

Efficiency

Despite the additional retrieval step, training time per epoch remained competitive with complex GNN-based temporal models. This efficiency is due to the highly parallelizable nature of the underlying sequence architecture.

Conclusion

RAG4DyG demonstrates that global knowledge from similar nodes can significantly enhance local history for dynamic graph modeling. Key insights include the importance of time-decay in retrieval and the superiority of structural fusion over simple concatenation. Future research directions include optimizing the "noise" threshold for the number of retrieved demonstrations ($K$) and exploring the framework's scalability to billion-node graphs.

Summary updated

BibTeX
@inproceedings{wu2024retrieval,
  author = {Yuxia Wu and Yuan Fang and Lizi Liao},
  title = {{Retrieval Augmented Generation for Dynamic Graph Modeling}},
  booktitle = {International ACM SIGIR Conference on Research and Development in Information Retrieval},
  year = {2024},
  doi = {10.1145/3726302.3729958},
}
Figure