Sample- And Population-Level Causal Discovery from Event Sequences using Autoregressive Models
Project description
seq2cause
seq2cause: Turns any discrete sequence of events into a causal graph using autoregressive models (LLaMA, GPT, RNN, Mamba).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07f8f9b80b70d31dfedd415dd0138aa8076f03de793452f12356e7b14f137c8c
|
|
| MD5 |
35a5b43911a3f76352c0b6c1efe24fb3
|
|
| BLAKE2b-256 |
a8e34d978c391a9a86bcc2ca85c8a8f275320f56cd777f05985e2fe9d985e7f2
|
Provenance
The following attestation bundles were made for seq2cause-0.1.5.tar.gz:
Publisher:
publish.yml on Mathugo/seq2cause
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seq2cause-0.1.5.tar.gz -
Subject digest:
07f8f9b80b70d31dfedd415dd0138aa8076f03de793452f12356e7b14f137c8c - Sigstore transparency entry: 1116164300
- Sigstore integration time:
-
Permalink:
Mathugo/seq2cause@e73dc4cbb98938ec7a99cead2418a7652260af05 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/Mathugo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e73dc4cbb98938ec7a99cead2418a7652260af05 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe65af37abae07d10f7f0691afd6bbff39ddcf32242c3d0247675331061b7a8b
|
|
| MD5 |
a60bfcd69cf89d68212975b9453bd861
|
|
| BLAKE2b-256 |
3389056d2930a86b1428573f008f259acaf527ed0c179ee39d8cf0f9b8473987
|
Provenance
The following attestation bundles were made for seq2cause-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on Mathugo/seq2cause
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seq2cause-0.1.5-py3-none-any.whl -
Subject digest:
fe65af37abae07d10f7f0691afd6bbff39ddcf32242c3d0247675331061b7a8b - Sigstore transparency entry: 1116164733
- Sigstore integration time:
-
Permalink:
Mathugo/seq2cause@e73dc4cbb98938ec7a99cead2418a7652260af05 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/Mathugo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e73dc4cbb98938ec7a99cead2418a7652260af05 -
Trigger Event:
push
-
Statement type: