Skip to main content
QUICK REVIEW

[Paper Review] Large language models can be zero-shot anomaly detectors for time series?

Sarah Alnegheimish, Linh Nguyen|arXiv (Cornell University)|May 23, 2024
Topic ModelingComputer Science3 citations
TL;DR

This paper proposes SigLLM, a framework that enables large language models (LLMs) to detect anomalies in time series data using zero-shot prompting and forecasting. It demonstrates that LLMs can outperform traditional methods via a forecasting-based detection pipeline (Detector), achieving significantly higher F1 scores than prompting, though still lagging behind state-of-the-art deep learning models by ~30%.

ABSTRACT

Recent studies have shown the ability of large language models to perform a variety of tasks, including time series forecasting. The flexible nature of these models allows them to be used for many applications. In this paper, we present a novel study of large language models used for the challenging task of time series anomaly detection. This problem entails two aspects novel for LLMs: the need for the model to identify part of the input sequence (or multiple parts) as anomalous; and the need for it to work with time series data rather than the traditional text input. We introduce sigllm, a framework for time series anomaly detection using large language models. Our framework includes a time-series-to-text conversion module, as well as end-to-end pipelines that prompt language models to perform time series anomaly detection. We investigate two paradigms for testing the abilities of large language models to perform the detection task. First, we present a prompt-based detection method that directly asks a language model to indicate which elements of the input are anomalies. Second, we leverage the forecasting capability of a large language model to guide the anomaly detection process. We evaluated our framework on 11 datasets spanning various sources and 10 pipelines. We show that the forecasting method significantly outperformed the prompting method in all 11 datasets with respect to the F1 score. Moreover, while large language models are capable of finding anomalies, state-of-the-art deep learning models are still superior in performance, achieving results 30% better than large language models.

Motivation & Objective

  • To investigate whether large language models (LLMs) can serve as zero-shot anomaly detectors for time series data without fine-tuning.
  • To address the challenge of adapting LLMs—designed for natural language—to time series data, which requires sequence understanding and anomaly localization.
  • To develop a framework that converts time series into LLM-ready text representations while preserving temporal semantics.
  • To compare two distinct paradigms: direct prompting (Prompter) and forecasting-based anomaly detection (Detector).
  • To evaluate the practicality, cost, and performance of LLM-based anomaly detection against established baselines.

Proposed method

  • SigLLM includes a time-series-to-text conversion module that transforms numerical time series into reversible, descriptive string representations suitable for LLM input.
  • The Prompter pipeline directly prompts the LLM to identify anomalous segments in the input sequence using natural language instructions.
  • The Detector pipeline leverages the LLM’s autoregressive forecasting capability to predict future values, then computes residuals between predictions and actual values to detect anomalies.
  • The framework supports integration with LLMs hosted on OpenAI and HuggingFace, enabling zero-shot inference without model fine-tuning.
  • Rolling windows are used to handle long sequences due to LLM context length limitations, though this introduces computational overhead.
  • Post-processing strategies are identified as critical for reducing false positives, especially in the Prompter approach.
Figure 2: General principle of how machine learning models find anomalies in an unsupervised setting. Step 1: Apply a sequence of preprocessing operations and train a machine learning model to learn the pattern of the data. This is the most time-consuming step; Step 2: Use the trained model to gener
Figure 2: General principle of how machine learning models find anomalies in an unsupervised setting. Step 1: Apply a sequence of preprocessing operations and train a machine learning model to learn the pattern of the data. This is the most time-consuming step; Step 2: Use the trained model to gener

Experimental results

Research questions

  • RQ1Can large language models detect anomalies in time series data in a zero-shot setting without any fine-tuning?
  • RQ2How do prompting-based and forecasting-based LLM approaches compare in performance for time series anomaly detection?
  • RQ3To what extent do LLMs outperform or underperform against state-of-the-art deep learning and classical anomaly detection models?
  • RQ4What are the practical limitations of using LLMs for time series anomaly detection, particularly in terms of latency and cost?
  • RQ5How can memorization of training data affect LLM-based anomaly detection, and what mitigations are effective?

Key findings

  • The forecasting-based Detector method outperformed the prompting-based Prompter method by 135% in F1 score across all 11 datasets evaluated.
  • LLMs using the Detector pipeline achieved better performance than the Anomaly Transformer model and outperformed a moving average baseline.
  • Despite strong zero-shot performance, LLMs still lag behind state-of-the-art deep learning models by approximately 30% in F1 score.
  • The average inference cost for the Prompter method was $1.69 per signal, while the Detector method cost $4.30 per signal, indicating higher computational expense.
  • Detector inference time was nearly double that of Prompter, with average times ranging from 30 to 120 minutes per signal in offline settings.
  • The study found that rolling windows were necessary due to LLM context length constraints, which limits scalability and efficiency, especially for multivariate time series.
Figure 3: Visualizing the output of large language models ( GPT and Mistral ) under different variations of the transformation process. Each row depicts the exchange-2_cpm_results signal from the AdEx dataset, where the x-axis shows the timestamp and the y-axis is the signal value. The first row ind
Figure 3: Visualizing the output of large language models ( GPT and Mistral ) under different variations of the transformation process. Each row depicts the exchange-2_cpm_results signal from the AdEx dataset, where the x-axis shows the timestamp and the y-axis is the signal value. The first row ind

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.