STRAP: Spatio-Temporal Pattern Retrieval for Out-of-Distribution Generalization

Haoyu Zhang, WentaoZhang, Hao Miao, Xinke Jiang, Yuchen Fang, Yifan Zhang

Abstract

Spatio-Temporal Graph Neural Networks (STGNNs) often struggle with Out-of-Distribution (OOD) shifts where spatial structures and temporal dynamics evolve. We present STRAP (Spatio-Temporal Retrieval-Augmented Pattern Learning), a framework that maintains an explicit library of historical patterns. By retrieving and fusing these patterns during inference, STRAP mitigates catastrophic forgetting and improves generalization across dynamic streaming tasks.

1. Introduction

Spatio-Temporal Graph Neural Networks (STGNNs) are essential for modeling complex systems such as traffic networks, energy grids, and meteorological patterns. Despite their success, these models face significant challenges when encountering Spatio-Temporal Out-of-Distribution (STOOD) shifts. In real-world streaming scenarios, the underlying graph topology may change as sensors are added or removed, and temporal patterns may shift due to seasonal variations or sudden events.

Existing approaches often suffer from "catastrophic forgetting," where new information overwrites previously learned knowledge, or the "stability-plasticity trade-off," where models are either too rigid to adapt or too flexible to retain stability. STRAP addresses these issues by shifting from implicit knowledge storage in model weights to an explicit, multi-dimensional pattern library.

2. The STRAP Framework

STRAP introduces a retrieval-augmented approach to STGNNs, consisting of three primary components:

2.1 Spatial-Temporal Subgraph Chunking

To capture the nuances of evolving data, STRAP decomposes input streams into three specialized subgraph types:

  • Spatial Subgraphs: Time-slices that emphasize persistent structural relationships.
  • Temporal Subgraphs: Localized neighborhood evolutions tracked over the entire time horizon.
  • Spatio-Temporal Subgraphs: Communities of nodes exhibiting coherent joint dynamics.

2.2 Multi-dimensional Pattern Library

For each subgraph, the framework constructs a key-value pair. The Keys are robust, hand-crafted features designed to remain informative despite distribution shifts. These include Forman-Ricci curvature for geometric insights, clustering coefficients for topological structure, and wavelet transformations for frequency-domain temporal analysis. The Values are high-dimensional embeddings generated by a frozen, pretrained STGNN backbone.

2.3 Retrieval and Knowledge Fusion

During inference, STRAP extracts a query key from current observations and retrieves the top-$k$ most similar patterns from the library. An adaptive fusion mechanism then merges these historical insights with the current representation. This "plug-and-play" design allows STRAP to enhance various architectures, including DCRNN and ASTGNN.

3. Experimental Evaluation

The framework was evaluated on three real-world streaming datasets: AIR-Stream (AQI data), PEMS-Stream (traffic flow), and ENERGY-Stream (wind power). These datasets simulate realistic OOD scenarios where the number of nodes evolves over multiple time periods.

3.1 Performance Results

STRAP demonstrated superior generalization, achieving a 7.17% average improvement across MAE, RMSE, and MAPE metrics compared to state-of-the-art baselines. The framework proved to be backbone-agnostic, consistently boosting the performance of STGNN, ASTGNN, DCRNN, and TGCN.

3.2 Robustness and Efficiency

In few-shot scenarios with 50% missing data, STRAP outperformed the best baseline (EWC) by 8.7% in MAE. Furthermore, STRAP maintains computational efficiency; it is significantly faster than intensive baselines like PECPM while providing higher accuracy.

4. Key Insights

Ablation studies highlighted the importance of geometric features, specifically Forman-Ricci curvature. Removing this feature led to a significant performance decline, indicating that the "shape" of the graph is a critical signal for OOD generalization. By decoupling pattern indexing (via robust keys) from pattern utilization (via neural embeddings), STRAP ensures that historical knowledge remains accessible even when raw data distributions shift.

5. Conclusion and Future Work

STRAP offers a scalable solution to the STOOD problem by leveraging explicit memory retrieval. While the current model relies on historical data availability and faces potential scaling challenges with very large libraries, it sets a new benchmark for streaming graph tasks. Future research will focus on adaptive library management (pruning old or redundant patterns), uncertainty-aware retrieval, and the integration of multi-modal data sources.

Summary updated

BibTeX
@inproceedings{zhang2025strap,
  author = {Haoyu Zhang and WentaoZhang and Hao Miao and Xinke Jiang and Yuchen Fang and Yifan Zhang},
  title = {{STRAP: Spatio-Temporal Pattern Retrieval for Out-of-Distribution Generalization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=Y5wMoIbdDs},
}
Figure