Manuscript Offprint

arXiv:2610.32329

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

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Haochen Lv 1^{1}

lvhaochen@bjtu.edu.cn

Jianhao Zhang 1^{1}

jianhaozhang@bjtu.edu.cn

Zhichen Lei 1^{1}

leizhichen@bjtu.edu.cn

Yang Jiang 1^{1}

jiangyang@bjtu.edu.cn

Xiaowei Mao 1^{1}

maoxiaowei@bjtu.edu.cn

Shengnan Guo 1,2,∗^{1,2,*}

guoshn@bjtu.edu.cn

Youfang Lin 1,3^{1,3}

yflin@bjtu.edu.cn

Huaiyu Wan 1,3^{1,3}

hywan@bjtu.edu.cn

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. Code is available at https://github.com/LvHaochenBANG/REMIND.git.

1 Introduction

Spatiotemporal forecasting plays a crucial role in real-world applications, such as transportation [1, 2, 3], hydrology [4], and energy systems [5, 6, 7]. In recent years, probabilistic approaches have gained increasing attention, as they aim to model the underlying distribution of system dynamics [8, 9, 10].

∗^{*} Corresponding author

1^{1} School of Computer Science and Technology, Beijing Jiaotong University, Beijing, China.

2^{2} Key Laboratory of Big Data and Artificial Intelligence in Transportation, Ministry of Education, Beijing, China.

3^{3} Beijing Key Laboratory of Traffic Data Mining and Embodied Intelligence, Beijing, China.

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

Beyond point predictions, these methods provide uncertainty quantification, which is essential for risk assessment, decision-making, and early warning [11, 12, 13, 14].

Most existing probabilistic spatiotemporal forecasting methods focus on modeling data distributions under standard settings. However, real-world spatiotemporal systems are inherently non-stationary, leading to distribution shifts, reflected as a mismatch between training and test data distributions [15]. Such shifts commonly arise from evolving system dynamics, including changing patterns, sensor noise, and unexpected events such as accidents or extreme weather [16, 17]. Importantly, distribution shift is inherently continuous rather than binary [18]. At one end, the absence of shift corresponds to in-distribution (ID) scenarios, while at the other end, extreme shifts correspond to out-of-distribution (OOD) scenarios [19]. In practice, many real-world cases lie between these two extremes.

Recently, several methods have been proposed to handle distribution shift. ShiftTS [20] improves generalization by learning invariant patterns of input features under different external conditions. TFPS [15] performs adaptive forecasting by dynamically selecting experts specialized in specific patterns. In particular, retrieval-based approaches such as RAFT [21] and STRAP [5] have shown strong potential by leveraging an external memory bank of historical data to retrieve and preserve diverse patterns, especially rare ones, thereby improving predictive performance across diverse distributional conditions.

Despite these advances, handling distribution shift remains challenging in practice. Existing methods often handle distribution shift in a coarse manner, lacking the ability to explicitly characterize shift degree and adapt prediction strategies accordingly, resulting in miscalibrated predictive distributions and unreliable forecasts. Retrieval-based methods, for example, typically retrieve historical samples based on historical observations, rank them by similarity, and reuse their associated future outcomes, implicitly assuming that the retrieved samples can be trusted without assessing their reliability. However, this assumption may fail in two ways. First, under severe distribution shifts, even the most similar historical samples may differ substantially from the current observation, providing limited support for prediction. Second, similar historical observations may correspond to markedly different future outcomes, making input similarity alone insufficient to determine the reliability of retrieved information. Consequently, reusing retrieved samples without assessing their relevance and consistency may bias predictions and undermine uncertainty estimation.

To address these challenges, we propose REMIND, a retrieval-guided probabilistic framework for spatiotemporal forecasting under distribution shift. Unlike conventional approaches that treat retrieval as passive memory lookup, REMIND leverages retrieval as an active signal of how well the current observation is supported by historical patterns. Specifically, it assesses both the relevance of retrieved observations and the consistency of their associated future outcomes to guide adaptive probabilistic forecasting.

Concretely, we design a coarse-to-fine spatiotemporal retrieval mechanism that equips REMIND with a memory bank and achieves both high retrieval quality and efficiency. Based on the retrieval, we construct two complementary branches. A memory-calibrated probabilistic branch predicts from retrieved patterns through lightweight calibration and is effective under mild shifts. A deviation-aware probabilistic branch predicts from the current observation and uses deviations from retrieved patterns as residual corrections, making it more suitable for severe shifts. REMIND then fuses the two branches via a shift-adaptive gate, which leverages retrieval similarity and memory dispersion to estimate shift degree and balance them accordingly. In addition, we design a hierarchical Gaussian mixture to capture heterogeneous uncertainty through inner-branch uncertainty and cross-branch disagreement, and introduce a memory perturbation training scheme to improve generalization under distribution shift.

Our contributions are summarized as follows:

• We propose REMIND, a retrieval-guided probabilistic framework for spatiotemporal forecasting under distribution shift. By treating retrieval as an active signal of support from historical patterns, it adaptively balances a memory-calibrated probabilistic branch and a deviation-aware probabilistic branch according to shift degree, enabling adaptive prediction across different shift regimes.

• We develop a hierarchical Gaussian mixture to model heterogeneous predictive uncertainty over the dual branch predictions, and introduce a memory perturbation training scheme to improve generalization under distribution shift.

• Experiments on real-world datasets from hydrology, traffic and energy domains with spatiotemporal distribution shifts demonstrate that our method consistently outperforms state-of-the-art approaches in both forecasting accuracy and probabilistic prediction quality.

References (38)