Back Home

時間序列與檢索增強

TS-RAG Fuses Historical Sequences via Reference Tokens, Reducing Average MSE to 0.310 Across Six Forecasting Datasets

Baidu researchers have adapted RAG from text generation to multivariate time-series forecasting, using a TCN to retrieve similar segments and cross-attention to fuse them. A channel-dependent variant outperformed the listed baselines across six datasets, but the code has not been released, and maintainers have warned that the conventional benchmarks used may no longer be sufficiently discriminative.

猫猫的日记本 · CC BY-SA 3.0 · Image source
zh-Hant

The core of TS-RAG is not simply appending historical sequences to the input. The system first divides each variable into fixed-length patches and uses additional learnable reference tokens to represent retrieval results. The input sequence models its own dynamics through self-attention, then reads similar historical segments through cross-attention. TS-RAG-CM additionally models dependencies between channels, making it suitable for multivariate data such as electricity load and weather observations.

The retriever is a separately trained Temporal Convolutional Network (TCN) that uses vector distance to find similar sequences. In the experiments, the input length was fixed at 96 time steps, with forecast horizons of 96, 192, 336, and 720 steps across ECL, ETTh1, ETTh2, ETTm1, ETTm2, and Weather. Averaged over the four forecast horizons, TS-RAG-CM achieved an MSE/MAE of 0.310/0.348. The variant without channel-dependency modeling scored 0.317/0.353, while the listed TimeXer baseline scored 0.312/0.349.

Ablation experiments showed that, compared with directly concatenating historical sequences, TS-RAG-CM reduced MSE by 14.2% to 18.2% across the four forecast horizons. More retrieval was not necessarily better, however: top-1 retrieval performed best, while adding two or four reference sequences generally increased error, indicating that even similar segments can introduce conflicting patterns. TCN retrieval reportedly took 0.004 seconds, far less than the 14.27 seconds required by Dynamic Time Warping, though slightly more than the 0.002 seconds required by Euclidean distance.

The results suggest that RAG's value may lie in how retrieved information is fused, rather than in simply expanding the context. However, the paper provides no public code, index-construction costs, or end-to-end deployment latency, and all results come from only six commonly used datasets. In 2026, the maintainers of Time-Series-Library warned that many of the repository's older benchmarks might no longer be sufficient to measure research progress. Engineering teams should next pay particular attention to data leakage from sliding windows, erroneous retrieval under distribution shift, and whether the system can safely fall back to the original forecaster when retrieval fails.

Sources

  1. TS-RAG: Retrieval Augmented Generation for Time Series Forecasting
  2. Time Series Library:基準維護與過時警告