Large language models can be zero-shot anomaly detectors for time series?

Sarah Alnegheimish, Linh Nguyen, Laure Berti-Équille, Kalyan VeeramachaneniarXiv 2024 · DOI

Introduction

Time series anomaly detection—identifying unusual spikes or drops in data such as satellite telemetry or web traffic—is a cornerstone of industrial monitoring. Traditionally, this requires training specialized machine learning models on massive datasets, a process that is both time-consuming and computationally expensive.

With the rise of Large Language Models (LLMs), researchers from MIT and IRD have introduced SIGLLM, a framework designed to test whether these models, primarily trained on text, can "understand" numerical patterns well enough to spot anomalies in a zero-shot setting. This approach addresses two primary challenges: the difference in data modality (text vs. continuous numbers) and task complexity (identifying specific sub-sections as anomalous).

The SIGLLM Framework

The authors developed SIGLLM to bridge the gap between raw numerical sequences and LLM inputs. The process involves several critical pre-processing and modeling steps to translate time series data into a format compatible with language models.

Overview of the SIGLLM framework showing the training and inference pipelines.

Signal-to-Text Conversion

To make numbers "readable" for an LLM, data is scaled to non-negative values, quantized into integers, and segmented using rolling windows. A key discovery was that inserting spaces between digits (e.g., "244" becomes "2 4 4") helps the LLM process numerical magnitude more effectively. This avoids the "tokenization trap" where standard tokenizers group numbers in ways that obscure their mathematical value.

Detection Paradigms

The framework evaluates two primary detection methods:

  1. PROMPTER: A direct approach where the LLM is prompted to identify indices of anomalies within a sequence.
  2. DETECTOR: A forecasting approach where the LLM predicts the next values in a sequence. The framework calculates the "residual" (the difference between the prediction and the actual value); high errors are flagged as anomalies.

Experimental Evaluation

SIGLLM was evaluated on 11 datasets, including NASA satellite telemetry (SMAP and MSL), Yahoo S5 production traffic, and the Numenta Anomaly Benchmark (NAB). The study primarily utilized GPT-3.5-turbo and Mistral-7B-Instruct.

Key Results and Insights

The study revealed that the DETECTOR (forecasting) method significantly outperformed the direct PROMPTER method. This suggests that LLMs are more adept at pattern continuation than explicit labeling of deviations within a text block.

Performance comparison relative to baselines (left) and a sample LLM forecast on SMAP data (right).

While zero-shot LLMs outperformed some specialized models like the Anomaly Transformer, they still lag behind state-of-the-art (SOTA) deep learning models. For instance, the SOTA model AER remains approximately 30% more accurate. LLM-based methods achieved an average F1 score of 0.525, performing 14.6% better than a simple Moving Average baseline but 18% worse than the average of all tested deep learning models.

Discussion and Future Work

Despite their promise, LLMs face significant hurdles in industrial applications. They are currently slow and expensive at inference time; for example, running the PROMPTER experiment on GPT-3.5 cost roughly $1.69 per signal, compared to fractions of a cent for traditional models. Additionally, context window limits hinder the detection of long-term trends, and the current study was limited to univariate data.

Future research may explore the use of "log probabilities" (internal confidence scores) to filter false positives and extend the framework to multivariate systems where hundreds of correlated sensors must be monitored simultaneously.

Summary updated

BibTeX
@misc{alnegheimish2024large,
  author = {Sarah Alnegheimish and Linh Nguyen and Laure Berti-Équille and Kalyan Veeramachaneni},
  title = {{Large language models can be zero-shot anomaly detectors for time series?}},
  year = {2024},
  eprint = {2405.14755},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.14755},
}
Figure