Skip to main content

LLMs for unsupervised time series anomaly detection

Project description

“DAI-Lab” An open source project from Data to AI Lab at MIT.

Development Status Python PyPi Shield Run Tests Downloads

SigLLM

Using Large Language Models (LLMs) for time series anomaly detection.

Overview

SigLLM is an extension of the Orion library, built to detect anomalies in time series data using LLMs. We provide two types of pipelines for anomaly detection:

  • Prompter: directly prompting LLMs to find anomalies in time series.
  • Detector: using LLMs to forecast time series and finding anomalies through by comparing the real and forecasted signals.

For more details on our pipelines, please read our paper.

Quickstart

Install with pip

The easiest and recommended way to install SigLLM is using pip:

pip install sigllm

This will pull and install the latest stable release from PyPi.

In the following example we show how to use one of the SigLLM Pipelines.

Detect anomalies using a SigLLM pipeline

We will load a demo data located in tutorials/data.csv for this example:

import pandas as pd

data = pd.read_csv('data.csv')
data.head()

which should show a signal with timestamp and value.

     timestamp      value
0   1222840800   6.357008
1   1222862400  12.763547
2   1222884000  18.204697
3   1222905600  21.972602
4   1222927200  23.986643
5   1222948800  24.906765

In this example we use gpt_detector pipeline and set some hyperparameters. In this case, we set the thresholding strategy to dynamic. The hyperparameters are optional and can be removed.

In addtion, the SigLLM object takes in a decimal argument to determine how many digits from the float value include. Here, we don't want to keep any decimal values, so we set it to zero.

from sigllm import SigLLM

hyperparameters = {
    'orion.primitives.timeseries_anomalies.find_anomalies#1': {'fixed_threshold': False}
}

sigllm = SigLLM(pipeline='gpt_detector', decimal=0, hyperparameters=hyperparameters)

Now that we have initialized the pipeline, we are ready to use it to detect anomalies:

anomalies = sigllm.detect(data)

:warning: Depending on the length of your timeseries, this might take time to run.

The output of the previous command will be a pandas.DataFrame containing a table of detected anomalies:

        start         end  severity
0  1225864800  1227139200  0.625879

Resources

Additional resources that might be of interest:

Citation

If you use SigLLM for your research, please consider citing the following paper:

Sarah Alnegheimish, Linh Nguyen, Laure Berti-Equille, Kalyan Veeramachaneni. Can Large Language Models be Anomaly Detectors for Time Series?.

@inproceedings{alnegheimish2024sigllm,
  title={Can Large Language Models be Anomaly Detectors for Time Series?},
  author={Alnegheimish, Sarah and Nguyen, Linh and Berti-Equille, Laure and Veeramachaneni, Kalyan},
  booktitle={2024 IEEE International Conferencze on Data Science and Advanced Analytics (IEEE DSAA)},
  organization={IEEE},
  year={2024}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sigllm-0.1.1.dev1.tar.gz (95.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sigllm-0.1.1.dev1-py3-none-any.whl (70.6 kB view details)

Uploaded Python 3

File details

Details for the file sigllm-0.1.1.dev1.tar.gz.

File metadata

  • Download URL: sigllm-0.1.1.dev1.tar.gz
  • Upload date:
  • Size: 95.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for sigllm-0.1.1.dev1.tar.gz
Algorithm Hash digest
SHA256 c7fc0b10be16a466a10d53d6cb1af47ee15f670ca97522024247785d5e75bb23
MD5 be08e4e0aa85685f948b9ece39c55bd7
BLAKE2b-256 cc91c70a224f54003c6f6f2f202219d1381df7e8de884afc1dfdf370bd50ff72

See more details on using hashes here.

File details

Details for the file sigllm-0.1.1.dev1-py3-none-any.whl.

File metadata

  • Download URL: sigllm-0.1.1.dev1-py3-none-any.whl
  • Upload date:
  • Size: 70.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for sigllm-0.1.1.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef281e6a5a70d7eaea634da85e58f4ae0cd07b6c007e54b845550391ae9accdb
MD5 69393b1eff202d8f6b0b419715fdf6fc
BLAKE2b-256 f5cacfb3c0f367a7cd15aa8fe6c99bc677fa5921ad22ff5c54efa0abb32f0d93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page