PyWhyLLM enables usage of large language models in the causal inference pipeline. It integrates with existing PyWhy libraries such as DoWhy and causallearn.
Project description
PyWhy-LLM: Leveraging Large Language Models for Causal Analysis
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.
Project details
Release history Release notifications | RSS feed
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 pywhyllm-0.1.tar.gz.
File metadata
- Download URL: pywhyllm-0.1.tar.gz
- Upload date:
- Size: 87.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f2019a5b46e14f69ac8922bcd56873dbb7eeae65d7c0d3515336326ea232aca
|
|
| MD5 |
6ab880afdf3cfde91ead07221a8aa4c5
|
|
| BLAKE2b-256 |
9d922b9dae9ce3fea90a0cbd95272144c89719f8d6828634171bcfa2e1669acc
|
File details
Details for the file pywhyllm-0.1-py3-none-any.whl.
File metadata
- Download URL: pywhyllm-0.1-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07e67f3212788355cb26b00cd4a550e3760b363aff03dda7424261f75eff1912
|
|
| MD5 |
f462f8921c8893b9ebc79673f2ed7275
|
|
| BLAKE2b-256 |
ee0df40a0831905b0f88c5a441197b4cf5ac9950f42db0f8984560ad99d38253
|