百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

Causal-Copilot

> 编程语言
开源

Causal-Copilot: 一个自主因果分析代理 [演示] • [代码] • [技术报告] --- 2025 年 4 月 16 日消息:我们发布了 Causal-Copilot-V2 …

199 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

Causal-Copilot: 一个自主因果分析代理 [演示] • [代码] • [技术报告] --- 2025 年 4 月 16 日消息:我们发布了 Causal-Copilot-V2 …

Causal-Copilot: An Autonomous Causal Analysis Agent

[Demo] • [Code] • [Technical Report]


News

04/16/2025: We release Causal-Copilot-V2 and the official Technical Report. The new version supports automatically using 20 state-of-the-art causal analysis techniques, spanning from causal discovery, causal inference, and other analysis algorithms.

11/04/2024: We release Causal-Copilot-V1, the first autonomous causal analysis agent.


Introduction

Identifying causality lets scientists look past correlations and uncover the mechanisms behind natural and social phenomena. Although many advanced methods for causal discovery now exist, their varied assumptions and technical complexity often discourage non‑experts from using them.

Causal‑Copilot addresses this gap. Guided by a LLM, it automates the full causal‑analysis workflow: data inspection, algorithm and hyperparameter selection, code generation, uncertainty assessment, and PDF report creation— all triggered through simple dialogue. By combining LLM‑driven domain knowledge with state‑of‑the‑art causal techniques, Causal‑Copilot lets researchers focus on scientific insight instead of implementation details.

Try out our interactive demo: Causal-Copilot Live Demo


Demo

Video Demo

Report Examples

We provide some examples of our system automatically generated reports for open-source datasets generated as follows:

  • 1. Bioinformatics-Abalone
  • 2. Architecture-CCS
  • 3. Bioinformatics-Sachs

Table of Contents

  • Demo
  • Features
  • Getting Started
  • Usage
  • License
  • Contact

Features

  • Automated Causal Analysis – An LLM automatically picks and tunes the best causal‑analysis algorithms, embedding expert heuristics so users need no specialized knowledge.
  • Statistical + LLM Post‑Processing – Performs bootstrap edge‑uncertainty checks and refines the causal graph (pruning, edge re‑direction) using the LLM’s prior knowledge.
  • Chat‑Style Interface – Users steer the entire analysis via natural dialogue and receive clear visualizations of data stats and causal graphs—no technical setup required.
  • Complete Analysis Report – Outputs a concise PDF that documents methods, shows intuitive visuals, and explains key findings.
  • Extensible Framework – Open interfaces let developers plug in new causal algorithms or external libraries with minimal effort.

Architecture Details

  • Causal‑Copilot adopts a modular architecture built around five primary components—Simulation, User Interaction, Preprocessing, Algorithm Selection, and Postprocessing—that together deliver an end‑to‑end causal analysis pipeline. A large language model (LLM) sits at the core of the framework, coordinating data flow among these modules while tapping into auxiliary resources such as a causality‑focused knowledge base and a library of local algorithms. All modules communicate via unified interfaces that pass structured metadata and intermediate results, allowing the LLM to supervise execution seamlessly. This organization preserves clear separation of concerns, simplifies extension, and makes it straightforward to integrate new capabilities into the system.

  • Causal-Copilot integrates over twenty state-of-the-art causal analysis algorithms, broadly categorized into causal discovery, causal inference, and auxiliary analysis tools.

Autonomous Workflow

  • Powered by an integrated LLM, Causal‑Copilot delivers a fully autonomous causal‑analysis pipeline. A user simply uploads a tabular dataset and a natural‑language query. The LLM—augmented by rule‑based routines—parses the query, cleans the data, infers variable types, and fills in missing values. It then chooses the best causal method, tunes its hyperparameters, and generates the code to run it. After execution (e.g., producing a causal graph), the LLM checks for inconsistencies, optionally queries the user for clarification, and can chain additional steps—such as effect or counterfactual estimation—on top of the discovered structure. The system concludes by compiling an interpretable PDF report that summarizes the data, details intermediate choices, and visualizes the final causal results, making the analysis accessible to non‑experts.

Evaluation on Simulated Data

  • To test Causal‑Copilot thoroughly, we built a concise yet diverse evaluation suite. Synthetic tabular datasets vary in variable count, graph density, functional form (linear vs. non‑linear), and noise levels. Synthetic time‑series data vary in dimensionality, length, lag structure, and noise type. We also create compound benchmarks, e.g., clinical, financial, and IoT scenarios—that bundle multiple challenges to mimic real‑world complexity. Each dataset has a known ground‑truth graph, allowing us to measure how well the automated pipeline discovers causal structure under a wide range of conditions.
  • The results show that our Causal-Copilot can achieve much better performance, indicating the effectiveness of its automatic algorithm selection and hyper-parameter setting strategy, in a autonomous manner.

Getting Started

Online Demo

Try out our interactive demo: Causal-Copilot Live Demo

Local Deployment

We strongly recommend using Docker for the most stable and reliable installation, as it handles all system dependencies including LaTeX packages automatically.

Docker Installation (Recommended)

Prerequisites:

  • Docker installed on your system

For CPU version:

bash
# Build the Docker image
docker build -f Dockerfile.cpu -t causal-copilot-cpu .

# Run the container
docker run -it --rm -v $(pwd):/app -p 7860:7860 causal-copilot-cpu

For GPU version:

bash
# Build the Docker image
docker build -f Dockerfile.gpu -t causal-copilot-gpu .

# Run the container with GPU support
docker run -it --rm --gpus all -v $(pwd):/app -p 7860:7860 causal-copilot-gpu

** Using Ollama with Docker:** If you are running Ollama on your host machine and want to connect to it from inside the Docker container, set the following environment variable in your .env file:

bash
OLLAMA_BASE_URL=http://host.docker.internal:11434

This is because localhost inside a container refers to the container itself, not the host machine. host.docker.internal is a special DNS name that resolves to the host.

On native Linux Docker Engine, add --add-host=host.docker.internal:host-gateway to the docker run command if host.docker.internal does not resolve automatically.

Conda Environment Installation

⚠️ Note: Conda environment installation might not be stable and may have compatibility issues with LaTeX dependencies required for report generation. We recommend using Docker instead.

Prerequisites:

  • Python 3.10 (create a new conda environment first)
  • Required Python libraries (specified in requirements_cpu.txt and requirements_gpu.txt)
  • Required LaTeX packages (tinyTeX)

Step 1: Create Python 3.10 Environment

bash
# Create a new conda environment with Python 3.10
conda create -n causal-copilot python=3.10 -y
conda activate causal-copilot

Step 2: Run Setup Script

For CPU version:

bash
bash setup_cpu.sh

For GPU version (if you have NVIDIA GPU):

bash
bash setup_gpu.sh

✅ Development Verification

For lightweight maintainer checks, install the development tools in a Python 3.10 environment and run:

bash
pip install -r requirements_dev.txt
bash scripts/verify.sh

The default verification command runs syntax-level linting, smoke tests, and Python bytecode compilation for owned project code. LLM, Ollama, and LaTeX integration checks are opt-in because they require external services or system tooling:

bash
RUN_LLM_TESTS=1 pytest causal_discovery/tests/selection_test.py
RUN_OLLAMA_TESTS=1 pytest llm/test_ollama.py
RUN_LATEX_TESTS=1 pytest test_latex_functionality.py

Environment Configuration

Causal-Copilot uses environment variables for configuration. Create a .env file in the project root directory:

** LLM Support:**

  • OpenAI (default): Full support for GPT models with reliable performance
  • OpenRouter: Access to various state-of-the-art LLMs (Claude, Llama, Mistral, etc.)
  • Ollama (local): Run LLMs locally for privacy and cost savings

⚠️ Performance Note: Local LLM processing speed depends on your machine specifications. Instruction-following capabilities may vary across models and can affect analysis quality and runtime duration.

Step 1: Copy the example configuration

bash
cp .env.example .env

Step 2: Configure your settings

The key environment variables you need to configure:

Variable Description Default Required
LLM_PROVIDER LLM provider (openai, ollama, openrouter) ollama ✅
LLM_MODEL Model name (e.g., gpt-4, llama3.2, mistral) llama3.2 ✅
OPENAI_API_KEY OpenAI API key - ⚠️ (if using OpenAI)
OLLAMA_BASE_URL Ollama server base URL http://localhost:11434 ⚠️ (if using Ollama)
OUTPUT_REPORT_DIR Directory for generated reports in chatbot demo output_report ❌
OUTPUT_GRAPH_DIR Directory for generated graphs in chatbot demo output_graph ❌

Example configurations:

For OpenAI:

bash
LLM_PROVIDER=openai
LLM_MODEL=gpt-4o
OPENAI_API_KEY=sk-your-openai-api-key-here

For Openrouter:

bash
LLM_PROVIDER=openrouter
LLM_MODEL=anthropic/claude-sonnet-4
OPENROUTER_API_KEY=sk-or-your-openrouter-api-key-here

For Ollama (local):

bash
LLM_PROVIDER=ollama
LLM_MODEL=llama3.2
OLLAMA_BASE_URL=http://localhost:11434

⚠️ Important Notes:

  • Keep your .env file secure and never commit it to version control
  • For Ollama, make sure you have the model downloaded: ollama pull llama3.2
  • The web interface will guide you through the configuration if variables are missing

Usage

There are two ways to use Causal-Copilot:

1. ️ Command Line Interface (CLI)

Use the CLI for focused causal discovery analysis:

bash
python main.py --data-file your_data.csv --initial_query "your user query"

Features:

  • Primarily focuses on causal discovery algorithms
  • Command-line based interaction
  • Suitable for batch processing and scripting

2. Web Chatbot Interface (Recommended)

Use the web interface for comprehensive causal analysis:

bash
python web_demo/demo.py

Features:

  • Complete causal analysis pipeline including:
    • Causal discovery
    • Causal inference
    • Auxiliary analysis tools
  • Interactive chat-style interface
  • Real-time visualizations
  • Automated PDF report generation
  • User-friendly for non-experts

Access: After running the command, open your browser and navigate to the provided local URL (typically http://localhost:7860 or public gradio set if you set share=True).

License

Distributed under the MIT License. See LICENSE for more information.

Resource

  • We develop the data simulator based on NOTEARS’s data generation process. We leverage comprehensive packages including causal-learn, CausalNex, Gcastle, which provides diverse causal discovery algorithms. We also benefit from specialized implementations such as FGES and XGES for score-based learning, AcceleratedLiNGAM for GPU-accelerated linear non-Gaussian methods, [GPU-CMI

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言