Are Large Language Models Useful for Time Series Data Analysis?

F Tang, Ying DingarXiv 2024 · DOI

TL;DR

This paper investigates whether the hype surrounding Large Language Models (LLMs) translates to superior performance in time series analysis. By conducting head-to-head comparisons across classification, anomaly detection, and forecasting, the researchers find that while LLMs offer clear advantages in identifying complex patterns and anomalies, their benefits are task-dependent and often come with significant computational costs.

What Problem Does This Paper Address?

Time series data—sequential measurements like heart rates, stock prices, or energy usage—is the backbone of decision-making in almost every industry. Traditionally, these tasks were handled by domain-specific statistical models or "lightweight" machine learning.

Recently, researchers have begun repurposing LLMs (originally built for text) to handle time series data, arguing that the "attention" mechanisms used to understand sentences can also understand temporal patterns. However, a heated debate has emerged: Are LLMs actually better, or are they just expensive "overkill" compared to simpler, specialized models? This paper seeks to provide an empirical answer by systematically comparing LLM-based architectures against their non-LLM counterparts.

Methods

The authors adopted a comparative framework to isolate the "LLM effect." They looked at two primary architectural styles:

  1. Non-Autoregressive Models (e.g., GPT4TS): These models process the entire sequence at once. They are used for classification and anomaly detection. The researchers compared a version of GPT4TS with the LLM layer against a version without it (feeding embeddings directly to the output).
  2. Autoregressive Models (e.g., AutoTimes): These models predict the next value in a sequence step-by-step, making them ideal for forecasting. The study utilized a LLaMA 7B-based model to see if the massive scale of an LLM improves long-term predictions.

The general pipeline for both involved: Normalization (scaling data) $\rightarrow$ Input Embedding (turning numbers into high-dimensional vectors) $\rightarrow$ LLM Layer (the "brain") $\rightarrow$ Output Layer (the final prediction).

Datasets

The study evaluated models across a wide array of standard benchmarks:

  • Classification (8 datasets): Including MIMIC-III (hospital readmissions), Handwriting (accelerometer data), and Heartbeat (spectrograms).
  • Anomaly Detection (4 datasets): Including PSM (server metrics) and SWaT (water treatment security).
  • Forecasting (2 datasets): ETTh1 (electricity transformer temperature) and Weather (climate data).

Key Insights and Ideas

  • The "LLM Tax" is often worth it for Classification: For 7 out of 8 classification datasets, the LLM-enhanced model outperformed the version without it. This suggests that the LLM's pre-trained ability to recognize complex, non-linear relationships helps it "see" patterns in time series that simpler layers miss.
  • Anomaly Detection is a Sweet Spot: The LLM-based approach showed significant improvements in F1-scores for detecting irregular patterns in 3 out of 4 datasets. LLMs seem particularly adept at understanding what "normal" looks like across long sequences.
  • Task Alignment Matters: The researchers found that non-autoregressive models are best for "global" tasks (classification), while autoregressive models are essential for "temporal" tasks (forecasting). You can't just throw any LLM at a problem; the architecture must match the goal.
  • Diminishing Returns on Simplicity: On very simple datasets (like JapaneseVowels), the LLM provided zero additional benefit, achieving the exact same accuracy as the non-LLM version.

Key Results

  • Classification: GPT4TS (with LLM) achieved 94.1% accuracy on hospital readmissions vs. 93.5% without the LLM. While the margin seems small, in healthcare, these increments are vital.
  • Anomaly Detection: On the PSM dataset, the LLM boosted the F1-score from 0.942 to 0.971.
  • Forecasting: The autoregressive AutoTimes (with LLaMA 7B) achieved the lowest Mean Squared Error (MSE) on both ETTh1 (0.3582) and Weather (0.1624), outperforming the non-autoregressive GPT4TS. However, the authors noted that training these models is incredibly resource-intensive.

Limitations and Future Work

The primary hurdle identified is computational efficiency. Training a LLaMA 7B model for time series forecasting, even for a single epoch, requires massive GPU resources (like the NVIDIA A6000 used in this study) and long training times.

The authors suggest that future work should focus on:

  • Efficiency: Finding ways to get LLM-level performance without the massive "compute footprint."
  • Broader Benchmarking: Testing on even more diverse datasets to find the "breaking point" where LLMs stop being useful.
  • Scalability: Investigating how these models perform in real-world, real-time applications where latency is a factor.

Summary updated

Abstract

Time series data plays a critical role across diverse domains such as healthcare, energy, and finance, where tasks like classification, anomaly detection, and forecasting are essential for informed decision-making. Recently, large language models (LLMs) have gained prominence for their ability to handle complex data and extract meaningful insights. This study investigates whether LLMs are effective for time series data analysis by comparing their performance with non-LLM-based approaches across three tasks: classification, anomaly detection, and forecasting. Through a series of experiments using GPT4TS and autoregressive models, we evaluate their performance on benchmark datasets and assess their accuracy, precision, and ability to generalize. Our findings indicate that while LLM-based methods excel in specific tasks like anomaly detection, their benefits are less pronounced in others, such as forecasting, where simpler models sometimes perform comparably or better. This research highlights the role of LLMs in time series analysis and lays the groundwork for future studies to systematically explore their applications and limitations in handling temporal data.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
PSMGPT4TS (with LLM)F1-score0.971Time Series Anomaly Detection
Source quote
L121: Dataset │ GPT4TS (with LLM) │ GPT4TS (w/o LLM) PSM │ 0.971 │ 0.942
PSMGPT4TS (w/o LLM)F1-score0.942Time Series Anomaly Detection
Source quote
L121: Dataset │ GPT4TS (with LLM) │ GPT4TS (w/o LLM) PSM │ 0.971 │ 0.942
ETTh1AutoTimes (with LLM)MSE (Mean Squared Error)0.3582Time Series Forecasting · params=7B
Source quote
L144: \multicolumn{4}{c}{Evaluation Metric: MSE (Mean Squared Error)} ETTh1 │ 0.3941 │ 0.3767 │ 0.3582
ETTh1GPT4TS (with LLM)MSE (Mean Squared Error)0.3767Time Series Forecasting
Source quote
L144: \multicolumn{4}{c}{Evaluation Metric: MSE (Mean Squared Error)} ETTh1 │ 0.3941 │ 0.3767 │ 0.3582
WeatherAutoTimes (with LLM)MSE (Mean Squared Error)0.1624Time Series Forecasting · params=7B
Source quote
L145: Weather │ 0.1739 │ 0.1659 │ 0.1624
WeatherGPT4TS (with LLM)MSE (Mean Squared Error)0.1659Time Series Forecasting
Source quote
L145: Weather │ 0.1739 │ 0.1659 │ 0.1624
BibTeX
@misc{tang2024are,
  author = {F Tang and Ying Ding},
  title = {{Are Large Language Models Useful for Time Series Data Analysis?}},
  year = {2024},
  eprint = {2412.12219},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.12219},
}
Figure