GPI: Generative-AI Powered Inference
gpi_pack is a Python library for the statistical inference powered by Generative Artificial Intelligence (AI). It provides a set of tools and utilities for performing statistical inference using the internal representation of the Generative AI models. The library is designed to be easy to use and flexible, allowing users to perform a wide range of statistical analyses.
Note
gpi_pack version 0.2.1 is available from PyPI. It supports (1) Text/Image-as-Confounder, (2) Text/Image-as-Treatment, and (3) Video-as-Treatment with scalar or repeated outcomes. Please read our recent paper for the video application and technical details. If you have feedback or suggestions, please reach out to the maintainer.
Getting Started
Data Generation
Basic Operations
Advanced Operations
References
- Function Reference
- dml_score
- estimate_k_ate
- estimate_psi_split
- extract_and_save_hidden_states
- generate_text
- get_instruction
- load_hiddens
- save_generated_texts
- pad_to_multiple_of_8
- StableDiffusionImg2ImgExtractor
- extract_images
- CosmosVideoExtractor
- VideoExtractionResult
- VideoSegmentOutput
- extract_videos
- TextMLPEncoder
- Video3DEncoder
- DynamicTarNetBase
- mse_loss
- DynamicTarNet
- DynamicGPIHyperparameterTuner
- estimate_k_ipsi
- SpectralNormClassifier
- TarNet
- TarNetBase
- TarNetHyperparameterTuner
How to cite
Imai, Kosuke and Nakamura, Kentaro (2026). Causal Inference with Generative Artificial Intelligence: Application to Texts as Treatments. Journal of the American Statistical Association, forthcoming. [Published article] [Preprint]
@article{imai2026causal,
title={Causal Inference with Generative Artificial Intelligence: Application to Texts as Treatments},
author={Imai, Kosuke and Nakamura, Kentaro},
journal={Journal of the American Statistical Association},
year={2026},
note={Forthcoming},
doi={10.1080/01621459.2026.2689629}
}
Imai, Kosuke and Nakamura, Kentaro (2025). GenAI-Powered Inference. arXiv preprint arXiv:2507.03897. [Paper]
@article{imai2025genai,
title={GenAI-Powered Inference},
author={Imai, Kosuke and Nakamura, Kentaro},
journal={arXiv preprint arXiv:2507.03897},
year={2025}
}
Nakamura, Kentaro and Imai, Kosuke (2026). GenAI Powered Dynamic Causal Inference with Unstructured Data. arXiv preprint arXiv:2605.07834. [Paper]
@article{nakamura2026genai,
title={GenAI Powered Dynamic Causal Inference with Unstructured Data},
author={Nakamura, Kentaro and Imai, Kosuke},
journal={arXiv preprint arXiv:2605.07834},
year={2026}
}
Nakamura, Kentaro, Breuer, Adam, Crespin, Michael H., Dietrich, Bryce J., and Imai, Kosuke (2026). Causal Inference with Video Features as Treatments. arXiv preprint arXiv:2607.06126. [Paper]
@article{nakamura2026causal,
title={Causal Inference with Video Features as Treatments},
author={Nakamura, Kentaro and Breuer, Adam and Crespin, Michael H. and Dietrich, Bryce J. and Imai, Kosuke},
journal={arXiv preprint arXiv:2607.06126},
year={2026}
}