A Language Model-Guided Framework for Mining Time Series with Distributional Shifts

Haibei Zhu, Yousef El-Laham, Elizabeth Fons, Svitlana Vyetrenko

TL;DR

Time series foundation models often fail when confronted with abrupt real-world regime changes and distributional shifts, largely because shift-heavy training data is scarce. This paper introduces an automated framework that uses Large Language Models (LLMs) to identify open APIs, write retrieval code, and query real-world time series tied to historical disruption events. Fine-tuning models like Lag-Llama and Chronos on this mined, shift-rich data significantly improves forecasting accuracy and variance over zero-shot baselines on both seen and unseen datasets.

What Problem Does This Paper Address?

Time series data often experiences distributional shifts—sudden statistical changes in mean, variance, or trend caused by macro events such as pandemics, policy changes, or economic crises. While time series foundation models demonstrate impressive zero-shot forecasting capabilities, they struggle under distribution shifts.

Training models to handle these shifts is difficult because high-quality, shift-heavy datasets are scarce, restricted by privacy, or hidden across disparate web sources. While synthetic data generation is an option, simple mathematical processes often fail to capture the nuanced dynamics of real-world disruptions.

Methods

The authors propose a five-stage mining pipeline:

  1. Data Source Exploration: An LLM (e.g., GPT-4) is prompted to suggest public time series data sources, domain contexts, and API availability where distributional shifts are expected.
  2. Data Collection via LLM-Generated Code:
  3. The LLM receives API documentation and generates Python code to handle authentication, queries, rate limiting, and retries.
  4. Using knowledge of historical events, the LLM constructs targeted queries (defining metrics, start/end dates, and qualitative justifications for expected shifts).
  5. Data Pruning: To guarantee the presence of regime changes, time series are filtered using offline Change Point Detection (CPD) via the Ruptures Python library. Samples without detectable shifts in statistical properties (mean/variance) are discarded.
  6. Data Augmentation: The pruned time series are expanded (by a factor of 30×) using time-warping transformations: time warping, window warping, and window slicing.
  7. Evaluation & Fine-Tuning: Foundation models are fine-tuned on the augmented datasets and evaluated on both in-sample and out-of-sample domains.

Datasets

The pipeline collected five heterogeneous datasets:

  • FRED (Federal Reserve Economic Data): Macroeconomic and financial metrics (In-sample).
  • World Cup Search Trends: Google search query popularity around the 2022 World Cup (In-sample).
  • EIA Daily Energy: Daily electricity generation and demand data from the U.S. Energy Information Administration (In-sample).
  • Yahoo Finance: Stock prices, commodities, and FX rates (Out-of-sample).
  • COVID Search Trends: Google search query popularity during COVID-19 (Out-of-sample).

Models were trained on an 80/20 split of the augmented in-sample datasets and evaluated on unseen held-out segments as well as completely out-of-sample domains.

Key Insights and Ideas

  • LLMs as World-Knowledge Data Miners: Instead of using LLMs directly to generate numbers, the framework harnesses their qualitative historical knowledge to locate where and when real-world shifts occurred (e.g., COVID shocks or market crashes) and write the code to retrieve them.
  • Algorithmic Quality Gate: Change Point Detection serves as a mathematical filter, discarding "boring" stationary samples so models are exposed strictly to non-stationary dynamics.
  • Synthetic Data Falls Short: In an ablation using Ornstein-Uhlenbeck (OU) mean-reverting stochastic processes with parameter shifts, adding synthetic data (10K–200K samples) failed to improve foundation model predictions. Real-world mined shifts possess structural complexities that simple parametric stochastic processes cannot replicate.

Key Results

The authors evaluated zero-shot vs. fine-tuned performance on Lag-Llama (2.5M parameters) and Chronos (Tiny 8M, Mini 20M, Small 46M, Base 200M) measuring Mean Squared Error (MSE), MSE variance across samples, and MAE coverage:

  • In-Sample Substantial Gains:
  • For Lag-Llama on the FRED dataset, MSE dropped from 0.1959 (zero-shot) to 0.0779 (fine-tuned), with error variance dropping from 0.0110 to 0.0015. On EIA energy data, MSE decreased from 0.1147 to 0.0428.
  • For Chronos-Base on EIA energy data, MSE decreased from 0.0753 to 0.0163.
  • Out-of-Sample Generalization:
  • Improvements carried over to unseen domains: on Yahoo Finance, Lag-Llama’s MSE dropped from 0.0613 to 0.0488. Chronos-Tiny improved from 0.0508 to 0.0445.
  • On COVID search trends, Chronos-Base MSE dropped from 0.0681 to 0.0374.
  • Prediction Intervals: MAE coverage (measuring reliability of prediction intervals) showed more modest and mixed adjustments compared to point-estimate MSE reductions.

Limitations and Future Work

  • Data Inconsistencies: Varying sampling frequencies, irregular lengths, and API-specific noise across different web platforms can introduce unwanted artifacts.
  • Uncertainty Calibration: While point forecasts (MSE) and stability (variance) improved significantly, fine-tuning yielded limited benefits for quantile/interval coverage calibration (MAE coverage).
  • Future Scope: The authors suggest expanding the framework beyond distributional shifts to mine datasets with diverse seasonalities, multi-resolution sampling, and broader multi-modal time series applications.

Summary updated

BibTeX
@inproceedings{zhu2024language,
  author = {Haibei Zhu and Yousef El-Laham and Elizabeth Fons and Svitlana Vyetrenko},
  title = {{A Language Model-Guided Framework for Mining Time Series with Distributional Shifts}},
  booktitle = {TSALM @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=ZMl9pIRx6O},
}
Figure