Skip to main content

Sample- And Population-Level Causal Discovery from Event Sequences using Autoregressive Models

Project description

DOI

seq2cause

seq2cause: Turns any discrete sequence of events into a causal graph using autoregressive models (LLaMA, GPT, RNN, Mamba).

DOI PyPI version License: MIT Python 3.8+

seq2cause is a Python library for Causal Discovery on Discrete Event Sequences. It bridges the gap between Autoregressive Models (Language Models, RNN, Mambda) and Causal Discovery by treating autoregressive models as density estimators to perform parallelized CI-tests on GPUs.

🚀 Key Features

  • Bring Your Own Model: Plug in any HuggingFace/PyTorch model (GPT-2, LLaMA, RNN) trained on your discrete sequences (logs, codes, symbols).
  • Scaling: To thousands of events: The memory complexity scales linearly with the vocabulary and sequence length. Optimized for sparse, high-dimensional streams (e.g., Vehicle Diagnostics, Server Logs, User Journeys).
  • Multiple GPUs Acceleration: Batch processing for analyzing thousands of events in seconds using multiple GPUs.
  • Delayed Effects: Are identifiable up to the sequence length
  • Causal Relationships Type: We explain event-to-event, event-to-outcome causal graphs from single sequences and also an aggregation of global event-to-outcome scenarios with instance time causal graphs and summary causal graph.

📦 Installation

pip install seq2cause

⚡ Quick Start

Recover the causal graph from your logs in 3 lines of code.

📚 How It Works

seq2cause implements the TRACE framework (Temporal Reconstruction via Autoregressive Causal Estimation) for the event-to-event causal discovery and OSCAR for the event-to-outcome.

Graph Types

You can precise the graph types, which includes [redo graph namming and parameters in packages, put time instrance, summary graph]:

  • Event-to-Event (per sequence): Implements the TRACE algorithm using Conditional Mutual Information (CMI) approximation.
  • Event-to-Outcome (per sequence): Implements the OSCAR algorithm which target event-to-outcome relationships using a second autoregressive models to predict outcomes.
  • Event-to-Outcome (global): Implements the CARGO algorithm which aggregate the per-sequence causal graph to provide a global causal relationship of observational data.

Future works

  • Time series: Implements causal discovery for time series using autoregressive models (normalizing flows, AR models)

🔗 Citation

If you use seq2cause in your research, please cite our works:

@software{math2026seq2cause,
  author = {Math, Hugo},
  title = {seq2cause: Sample- and Population-Level Causal Discovery from Event Sequences using Autoregressive Models},
  year = {2026},
  publisher = {Zenodo},
  doi = {10.5281/zenodo.19068730},
  url = {https://doi.org/10.5281/zenodo.19068730},
  version = {0.1.4}
}
@misc{math2026tracescalableamortizedcausal,
      title={Scalable Sample-Level Causal Discovery in Event Sequences via Autoregressive Density Estimation},
      author={Hugo Math and Rainer Lienhart},
      year={2026},
      eprint={2602.01135},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2602.01135},
}
@inproceedings{
math2025oneshot,
title={One-Shot Multi-Label Causal Discovery in High-Dimensional Event Sequences},
author={Hugo Math and Robin Sch{\"o}n and Rainer Lienhart},
booktitle={NeurIPS 2025 Workshop on CauScien: Uncovering Causality in Science},
year={2025},
url={https://openreview.net/forum?id=z7NT8vGWC2}
}
@inproceedings{
math2025towards,
title={Towards Practical Multi-label Causal Discovery in High-Dimensional Event Sequences via One-Shot Graph Aggregation},
author={Hugo Math and Rainer Lienhart},
booktitle={NeurIPS 2025 Workshop on Structured Probabilistic Inference {\&} Generative Modeling},
year={2025},
url={https://openreview.net/forum?id=1HZfpuDVeW}
}

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🔧 Building

Ruff is used to add only clean code. A pre-commit will be automatically run.

pre-commit run --all-files
git add .
git commit -m "corrected import jaxtyping"
git push origin main
git push origin v0.1.4

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

seq2cause-0.1.5.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

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

seq2cause-0.1.5-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file seq2cause-0.1.5.tar.gz.

File metadata

  • Download URL: seq2cause-0.1.5.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for seq2cause-0.1.5.tar.gz
Algorithm Hash digest
SHA256 07f8f9b80b70d31dfedd415dd0138aa8076f03de793452f12356e7b14f137c8c
MD5 35a5b43911a3f76352c0b6c1efe24fb3
BLAKE2b-256 a8e34d978c391a9a86bcc2ca85c8a8f275320f56cd777f05985e2fe9d985e7f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for seq2cause-0.1.5.tar.gz:

Publisher: publish.yml on Mathugo/seq2cause

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seq2cause-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: seq2cause-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for seq2cause-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fe65af37abae07d10f7f0691afd6bbff39ddcf32242c3d0247675331061b7a8b
MD5 a60bfcd69cf89d68212975b9453bd861
BLAKE2b-256 3389056d2930a86b1428573f008f259acaf527ed0c179ee39d8cf0f9b8473987

See more details on using hashes here.

Provenance

The following attestation bundles were made for seq2cause-0.1.5-py3-none-any.whl:

Publisher: publish.yml on Mathugo/seq2cause

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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