When to Trust Memory: Retrieval-Guided Probabilistic Spatiotemporal Forecasting under Distribution Shift

Haochen Lv, Jianhao Zhang, Zhichen Lei, Yang Jiang, Xiaowei Mao, Shengnan Guo, Youfang Lin, Huaiyu Wan

TL;DR

REMIND is a novel retrieval-guided probabilistic framework designed to handle the "non-stationarity" problem in spatiotemporal forecasting. By adaptively balancing a memory-calibrated branch for familiar patterns and a deviation-aware branch for novel shifts, it achieves state-of-the-art accuracy and superior uncertainty calibration across hydrology, traffic, and energy datasets.

What Problem Does This Paper Address?

Spatiotemporal forecasting—predicting variables like traffic flow or wind speed across a network—is notoriously difficult because real-world systems are non-stationary. The patterns learned during training often shift by the time the model reaches production (a phenomenon known as distribution shift).

Current probabilistic methods typically assume a stable data distribution, leading to overconfident and "miscalibrated" forecasts when things change. While some recent methods use "retrieval" (looking up similar historical patterns to guide predictions), they often do so blindly. They assume that if a past situation looks like the current one, the future outcome will also be the same. In reality, under severe distribution shifts, even the most similar historical samples might be poor predictors. The authors ask a fundamental question: When should we trust our memory of the past, and when should we focus on how the present deviates from it?

Methods

The authors propose REMIND, which treats retrieval not just as a data source, but as an "active signal" of how much the distribution has shifted.

  1. Coarse-to-Fine Spatiotemporal Retrieval: To build an efficient memory bank, REMIND first performs a global search to find relevant historical windows, then refines this with node-wise temporal matching to account for local misalignments.
  2. Dual-Branch Architecture:
    • Memory-Calibrated Branch: Designed for "mild" shifts. It takes retrieved historical targets and applies lightweight calibration to adapt them to the current query.
  3. Deviation-Aware Branch: Designed for "severe" shifts. Instead of reusing historical targets, it predicts from the current observation and uses the difference (deviation) from historical patterns as a residual correction.
  4. Shift-Adaptive Gate: This is the "brain" of the system. It uses two key metrics—Retrieval Similarity (how well the current state matches the past) and Memory Dispersion (how much the retrieved historical outcomes disagree with each other)—to dynamically weight the two branches.
  5. Hierarchical Gaussian Mixture: To capture complex, multi-modal uncertainty, the model outputs a mixture of Gaussians. This allows it to represent multiple plausible future scenarios rather than just a single average path.
Figure 1: The overall architecture of REMIND. REMIND performs coarse-to-fine spatiotemporal retrieval to construct a memory bank and employs a dual branch architecture for probabilistic forecasting under distribution shift. A shift-adaptive gate dynamically balances the branches based on retrieval similarity and memory dispersion, and a hierarchical Gaussian mixture models heterogeneous predictive distribution.

Datasets

The model was evaluated on three real-world datasets characterized by significant distribution shifts:

  • CAMELS: Daily streamflow observations from hydrological basins (long-term variability).
  • PEMS: Traffic flow data from 581 sensors over 7 years (high spatial complexity).
  • ENERGY: Wind speed measurements from 103 locations (high-frequency dynamics).

Key Insights and Ideas

  • Memory Dispersion as a Red Flag: One of the most interesting findings is that "input similarity" isn't enough. If a model retrieves five similar historical moments, but those moments led to five wildly different outcomes, the "Memory Dispersion" is high. This is a strong indicator that the past is an unreliable guide for the current situation.
  • Retrieval as a Meta-Signal: Instead of just using retrieved data to make a prediction, REMIND uses the quality of the retrieval to decide how to make the prediction.
  • The Power of Deviations: In severe shift regimes, the authors found that modeling the residual (how the current state differs from the most similar past state) is far more effective than trying to predict the entire future state from scratch.
Analysis showing that higher memory dispersion correlates with higher forecasting error, justifying its use in the adaptive gate.

Key Results

REMIND consistently outperformed eight state-of-the-art baselines (including DeepAR, PriSTI, and STRAP) across all datasets.

  • Accuracy: On the ENERGY dataset, REMIND improved MAE by ~11% over the strongest baseline (STGNF).
  • Probabilistic Quality: It showed significant gains in CRPS (Continuous Ranked Probability Score), indicating that its uncertainty estimates are much more reliable and better calibrated than existing methods.
  • Robustness: In "memory corruption" experiments, where noise was added to the memory bank, REMIND's adaptive gate successfully reduced reliance on the corrupted memory, showing much more graceful degradation than competing retrieval-based models.

Limitations and Future Work

While REMIND is robust, it still fundamentally relies on the availability of historical memory. In entirely "black swan" events where no remotely similar historical pattern exists, the retrieval mechanism may provide limited support. The authors also note that under extremely sparse data conditions, the effectiveness of retrieval-guided adaptation might diminish.

Future work could explore how to handle "entirely unseen" scenarios where the memory bank is empty, perhaps by integrating large-scale pre-trained foundation models for time-series data.

Summary updated

Abstract

Spatiotemporal forecasting plays an important role in real-world applications, where probabilistic approaches provide uncertainty estimates for decision-making. Real-world systems are inherently non-stationary, leading to distribution shifts between training and test data. However, existing probabilistic methods mainly focus on modeling data distributions under standard settings, while distribution shift methods often handle such shifts in a coarse manner, failing to characterize shift degree and adapt prediction strategy accordingly. As a result, they often produce miscalibrated and unreliable forecasts. To address this issue, we propose REMIND, a retrieval-guided probabilistic framework for spatiotemporal forecasting under distribution shift. REMIND leverages retrieval to estimate how well current observation are supported by historical patterns, enabling adaptive prediction under different shift regimes. It employs spatiotemporal retrieval to construct a memory bank and introduces a dual branch architecture, combining a memory-calibrated probabilistic branch for mild shifts with a deviation-aware probabilistic branch for severe shifts. A shift-adaptive gate, guided by retrieval similarity and memory dispersion, balances the two branches according to shift degree. We further design a hierarchical Gaussian mixture to capture heterogeneous uncertainty over the dual branch predictions, and introduce a memory perturbation training scheme to improve generalization. Experiments on real-world datasets with distribution shifts demonstrate that REMIND consistently outperforms state-of-the-art methods in both forecasting accuracy and probabilistic prediction quality.
BibTeX
@inproceedings{lv2026when,
  author = {Haochen Lv and Jianhao Zhang and Zhichen Lei and Yang Jiang and Xiaowei Mao and Shengnan Guo and Youfang Lin and Huaiyu Wan},
  title = {{When to Trust Memory: Retrieval-Guided Probabilistic Spatiotemporal Forecasting under Distribution Shift}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=cw7vh4EHhq},
}
Figure