Skip to main content

“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}
}

Metadata

Release files for sigllm 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sigllm 0.2.0
File Size Uploaded
sigllm-0.2.0.tar.gz 96.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sigllm 0.2.0
File Interpreter ABI Platform
sigllm-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 166.5 kB

Release files / sigllm-0.2.0.tar.gz

Download URL sigllm-0.2.0.tar.gz
Size 96.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f7bd48927da054bbeb7bcffe5551fa8a3e9544985ea1a490078271b9807f0a31
BLAKE2b-256 checksum
How to use checksums
2679b9027a5568d1e0e1af5598038471629938a7d7f2a0a445a9c35f5d31b262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Release files / sigllm-0.2.0-py3-none-any.whl

Download URL sigllm-0.2.0-py3-none-any.whl
Size 70.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64a41a43c92d35bb2ae3904c0098d0e7f711ca4fb18e7de7c00c3c8cb78ac16e
BLAKE2b-256 checksum
How to use checksums
1af58eaaa78c761a313a3256e87b53947ea7375b3df6a31124fd39cf73e97a63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page