Skip to main content

Signals plus LLMs

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

History

0.0.2 - 2024-10-24

New Prompter pipeline.

  • Test README with GPT – Issue #20 by @sarahmish
  • Mistral-prompter – Issue #19 by @Linh-nk

0.0.1 - 2024-09-25

First sigllm release to PyPI: https://pypi.org/project/sigllm/

  • Add README – Issue #17 by @sarahmish
  • Create a SigLLM API – Issue #13 by @sarahmish
  • Add a Quick Example – Issue #12 by @sarahmish
  • Forecasting Pipeline – Issue #11 by @sarahmish
  • Refactor Transformation Primitives – Issue #7 by @sarahmish
  • Forecasting Module – Issue #2 by @sarahmish

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.0.2.tar.gz (69.2 kB view details)

Uploaded Source

Built Distribution

sigllm-0.0.2-py2.py3-none-any.whl (35.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file sigllm-0.0.2.tar.gz.

File metadata

  • Download URL: sigllm-0.0.2.tar.gz
  • Upload date:
  • Size: 69.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.1 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.66.5 importlib-metadata/4.13.0 keyring/25.4.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.14

File hashes

Hashes for sigllm-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2a03a1426e887f9a32d80b01c729f1ce6ff9a573805cd208337b92878201cc52
MD5 fab6a30bee9b615bbcbeeb1a62046aa5
BLAKE2b-256 4df6b35ebc73284e9c32874baabc60231a2e41411ab33439ec24b76487c0bafd

See more details on using hashes here.

File details

Details for the file sigllm-0.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: sigllm-0.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 35.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.1 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.66.5 importlib-metadata/4.13.0 keyring/25.4.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.14

File hashes

Hashes for sigllm-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9491107e2301461bce20af2d71c23262e59cb639abf7b29bd80225ea72fe6acf
MD5 6e3bcbf3d2d46af0c9bcffdd724afaed
BLAKE2b-256 116531bbfceffc89c9769d1638e7f06d36e75f0ad42fde84ed5f5ecdcda8a3df

See more details on using hashes here.

Supported by

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