Skip to main content

PyWhy-LLM: Leveraging Large Language Models for Causal Analysis

All Contributors

License

Introduction

PyWhy-LLM is an innovative library designed to augment human expertise by seamlessly integrating Large Language Models (LLMs) into the causal analysis process. It empowers users with access to knowledge previously only available through domain experts. As part of the DoWhy community, we aim to investigate and harness the capabilities of LLMs for enhancing causal analysis process.

Documentation and Tutorials

For detailed usage instructions and tutorials, refer to Notebook.

Installation

To install PyWhy-LLM, you can use pip:

pip install pywhyllm

Usage

PyWhy-LLM seamlessly integrates into your existing causal inference process. Import the necessary classes and start exploring the power of LLM-augmented causal analysis.

from pywhyllm.suggesters.model_suggester import ModelSuggester 
from pywhyllm.suggesters.identification_suggester import IdentificationSuggester
from pywhyllm.suggesters.validation_suggester import ValidationSuggester
from pywhyllm import RelationshipStrategy

Modeler

# Create instance of Modeler
modeler = ModelSuggester('gpt-4')

all_factors = ["smoking", "lung cancer", "exercise habits", "air pollution exposure"]
treatment = "smoking"
outcome = "lung cancer"

# Suggest a list of domain expertises
domain_expertises = modeler.suggest_domain_expertises(all_factors)

# Suggest a set of potential confounders
suggested_confounders = modeler.suggest_confounders(treatment, outcome, all_factors, domain_expertises)

# Suggest pair-wise relationship between variables
suggested_dag = modeler.suggest_relationships(treatment, outcome, all_factors, domain_expertises, RelationshipStrategy.Pairwise)

Identifier

# Create instance of Identifier
identifier = IdentificationSuggester('gpt-4')

# Suggest a backdoor set, mediator set, and iv set
suggested_backdoor = identifier.suggest_backdoor(treatment, outcome, all_factors, domain_expertises)
suggested_mediators = identifier.suggest_mediators(treatment, outcome, all_factors, domain_expertises)
suggested_iv = identifier.suggest_ivs(treatment, outcome, all_factors, domain_expertises)

Validator

# Create instance of Validator
validator = ValidationSuggester('gpt-4')

# Suggest a critique of the edges in provided DAG
suggested_critiques_dag = validator.critique_graph(all_factors, suggested_dag, domain_expertises, RelationshipStrategy.Pairwise)

# Suggest latent confounders
suggested_latent_confounders = validator.suggest_latent_confounders(treatment, outcome, all_factors, domain_expertises)

# Suggest negative controls
suggested_negative_controls = validator.suggest_negative_controls(treatment, outcome, all_factors, domain_expertises)

Contributors ✨

This project welcomes contributions and suggestions. For a guide to contributing and a list of all contributors, check out CONTRIBUTING.md. Our contributor code of conduct is available here.

If you encounter an issue or have a specific request for DoWhy, please raise an issue.

Metadata

Release files for pywhyllm 0.1

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

Source distribution (sdist)

Source distribution for pywhyllm 0.1
File Size Uploaded Provenance
pywhyllm-0.1.tar.gz 87.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 114.9 kB

Release files / pywhyllm-0.1.tar.gz

Download URL pywhyllm-0.1.tar.gz
Size 87.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3f2019a5b46e14f69ac8922bcd56873dbb7eeae65d7c0d3515336326ea232aca
BLAKE2b-256 checksum
How to use checksums
9d922b9dae9ce3fea90a0cbd95272144c89719f8d6828634171bcfa2e1669acc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.5

Release files / pywhyllm-0.1-py3-none-any.whl

Download URL pywhyllm-0.1-py3-none-any.whl
Size 27.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07e67f3212788355cb26b00cd4a550e3760b363aff03dda7424261f75eff1912
BLAKE2b-256 checksum
How to use checksums
ee0df40a0831905b0f88c5a441197b4cf5ac9950f42db0f8984560ad99d38253
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.5

Security for pywhyllm 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

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