Predicting the Future by Retrieving the Past

Tao Han (韩滔), Dazhao Du, Tao Han, Song GuoarXiv 2025 · DOI

Abstract

Modern time series forecasting models often suffer from "inference-time amnesia," where they are limited to a narrow lookback window despite having seen the entire historical dataset during training. We present PFRP (Predicting the Future by Retrieving the Past), a model-agnostic framework that introduces Retrieval-Augmented Generation (RAG) to time series forecasting. By searching a Global Memory Bank for historical patterns similar to the current context, PFRP addresses the limitations of local-only prediction. Experimental results show an average accuracy improvement of 8.4% across major benchmarks, with gains up to 17.4% on highly periodic datasets, while maintaining high inference efficiency.

Introduction

Most contemporary forecasting architectures—including Transformers, MLPs, and CNNs—implicitly compress historical knowledge into static weights during training. At inference, however, they typically only process a short "lookback window." This prevents them from explicitly leveraging long-term recurring patterns, such as seasonal electricity usage or annual traffic cycles. PFRP bridges this gap by allowing models to dynamically access a library of global historical patterns to inform their local predictions.

Overview of the PFRP framework: (a) Identifying recurring patterns, (b) Constructing the Global Memory Bank, and (c) Fusing global and local predictions.

Methodology

The PFRP framework introduces several key components to enable efficient and accurate retrieval:

  1. Global Memory Bank (GMB): A compact library of lookback window features (keys) and their corresponding future sequences (values). To ensure efficiency, PFRP uses K-medoids clustering to store representative "exemplars" rather than the entire training set.
  2. Predictive Contrastive Learning (PCL): A novel training objective that ensures lookback windows leading to similar future outcomes are mapped closely in the feature space. This makes retrieval "future-centric," ensuring the retrieved past is actually predictive of the future.
  3. Gating Mechanisms: A Confidence Gate assesses the relevance of retrieved patterns to the current context, while an Output Gate adjusts the scale and shift of the retrieved sequence to match the current data's magnitude.
  4. Dynamic Fusion: The final forecast is an adaptive blend of the "Global Prediction" (retrieved) and a "Local Prediction" (from any standard base model) using learned weights.

Results and Discussion

PFRP was evaluated on seven univariate benchmarks, including Traffic, Electricity, and Weather datasets. It consistently improved the performance of four state-of-the-art baselines (e.g., PatchTST, DLinear) by an average of 8.4%.

Performance comparison: (Left) MAE and inference time across different horizons; (Right) Accuracy gains when integrating PFRP with foundation models like Moirai and TimeCMA.

The most significant improvements were observed in datasets with high periodicity, such as Traffic (17.4%) and Electricity (10.1%). In contrast, for noisier data like Weather, the model adaptively leans more on the local prediction model. Notably, PFRP maintains high efficiency, adding negligible overhead compared to more complex diffusion-based retrieval methods. It also proved to be a successful "booster" for large-scale foundation models like Moirai.

Conclusion

PFRP demonstrates that explicitly retrieving historical precedents is a powerful and efficient way to enhance time series forecasting. By aligning retrieval features with future outcomes through PCL, the framework ensures that the retrieved "past" is truly relevant to the predicted "future." Future work will focus on extending this approach to high-dimensional multivariate data and incorporating temporal metadata (e.g., calendar features) for even more precise retrieval.

Summary updated

BibTeX
@misc{2025predicting,
  author = {Tao Han (韩滔) and Dazhao Du and Tao Han and Song Guo},
  title = {{Predicting the Future by Retrieving the Past}},
  year = {2025},
  eprint = {2511.05859},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.05859},
}
Figure