Abstract
Deep learning models for time series forecasting often struggle with the dual requirements of memorization and generalization, particularly when faced with non-stationary data and rare historical patterns. We present RAFT (Retrieval-Augmented Forecasting of Time-series), a framework that treats the training history as an external database. By retrieving similar historical segments and their subsequent outcomes, RAFT reduces the learning burden on neural network weights and improves forecasting accuracy across diverse domains.
Introduction
While deep learning has revolutionized time series analysis, standard models like Transformers and MLPs face a fundamental hurdle: they must "remember" every pattern seen during training within their fixed internal parameters. This is particularly challenging for real-world data, which is often non-stationary and contains infrequent events. Furthermore, these models are typically constrained by a fixed lookback window, preventing them from easily referencing similar situations from the distant past.
To address these limitations, we propose RAFT, a framework that adapts the "RAG" (Retrieval-Augmented Generation) concept from Large Language Models to the time series domain. RAFT explicitly retrieves relevant historical patterns to assist the forecasting process, allowing the model to "look up" similar past events rather than relying solely on internal memorization.
Methodology
The RAFT framework operates by treating the entire training history as an external memory. The process involves three primary stages: candidate set generation, retrieval, and prediction.
Candidate Set Generation
The training time series is processed using a sliding window to create a "Candidate Set" of key-value pairs. For any given segment, the "key" represents the historical pattern, and the "value" represents the data that immediately followed it.
The Retrieval Module
When the model receives a new input (the "query"), it searches the candidate set for the most similar keys. Unlike traditional methods that use Euclidean distance, RAFT employs Pearson’s correlation for similarity. This choice is critical for non-stationary data, as correlation focuses on the "shape" or trend of the pattern (e.g., increasing or decreasing) rather than absolute values, making it robust to shifts in scale or mean.
Multi-Periodicity and Prediction
Time series data often exhibits patterns at different scales (e.g., hourly, daily, weekly). RAFT addresses this by downsampling the data at multiple intervals (e.g., periods of 1, 2, and 4) and performs retrieval at each scale. This allows the model to capture both high-frequency local fluctuations and low-frequency global trends. Finally, the top-$m$ retrieved values are aggregated via an attention mechanism and combined with the original input. A lightweight MLP then produces the final forecast.
Experimental Setup
The researchers evaluated RAFT on 10 widely-used benchmark datasets covering diverse domains:
- ETT (h1, h2, m1, m2): Electricity transformer temperature.
- Electricity: Household power consumption.
- Exchange Rate: Daily rates of eight countries.
- Illness: Weekly influenza-like illness ratios.
- Solar: 10-minute solar power forecasts.
- Traffic: Hourly road occupancy rates.
- Weather: 21 weather-related indicators.
Synthetic datasets were also utilized to specifically test the model's ability to handle rare patterns and data with low temporal correlation.
Key Results and Insights
RAFT demonstrated superior performance across all benchmarks, outperforming nine contemporary baselines—including PatchTST, TimesNet, and TimeMixer—with an average win ratio of 86%.
The Power of Rare Patterns
A significant finding was that RAFT’s performance gains are most pronounced when patterns are rare. While standard models struggle to encode a pattern that only appears once or twice into their weights, RAFT can simply retrieve it from history. On synthetic datasets, this led to an MSE reduction of up to 14.7%.
Architecture Agnostic Benefits
The retrieval module is not limited to MLPs. Experiments showed that adding RAFT to Transformer-based models like Autoformer also boosted accuracy, suggesting that retrieval provides a universally beneficial inductive bias for forecasting.
Conclusion and Future Work
RAFT offers a practical and efficient way to augment time series models. Despite the retrieval step, inference remains fast (e.g., 1.9 seconds for ETTm1). Future work will focus on scaling the retrieval process for extremely large datasets using advanced vector search techniques like FAISS and exploring "Foundation Model" style retrieval across different but related time series.
Summary updated