Abstract
Causal decision-making is fundamental to scientific inquiry and policy development, yet general-purpose Large Language Models (LLMs) often struggle with the rigorous requirements of causal inference. We present LLM4Causal, a specialized agent framework that fine-tunes LLMs to perform end-to-end causal analysis. By decomposing the process into request interpretation, tool execution, and result explanation, LLM4Causal overcomes common pitfalls such as hallucination and code execution errors. Evaluated against state-of-the-art models like GPT-4, LLM4Causal demonstrates superior performance across a variety of causal tasks, including graph learning and mediation analysis.
1. Introduction
Determining causal relationships—moving beyond simple correlation—is a cornerstone of data-driven decision-making. While general LLMs like GPT-4 exhibit impressive reasoning capabilities, they frequently fail when applied to formal causal inference. These failures typically manifest as a confusion between correlation and causation, the hallucination of statistical interpretations, or an inability to reliably utilize specialized causal software libraries such as CausalML or econml.
As shown in Figure 1, existing models often provide vague answers or fail to execute necessary code due to environment restrictions or lack of specific knowledge about cutting-edge methods. LLM4Causal aims to democratize causal tools by providing a natural language interface that manages the entire analytical pipeline, from raw query to verified statistical result.
2. The LLM4Causal Framework
The core of LLM4Causal is a three-stage framework built by fine-tuning a Llama-2-7B model using Low-Rank Adaptation (LoRA). This architecture moves the mathematical heavy lifting out of the LLM's internal weights and into a deterministic code environment.
As illustrated in Figure 2, the process consists of three distinct steps:
- Step 1: Interpret User Request: The model translates natural language queries into a structured JSON format. This involves task classification (e.g., Average Treatment Effect, Causal Graph Learning) and attribute extraction (identifying variables and datasets).
- Step 2: Assign and Execute Causal Tools: Based on the extracted JSON, the system selects and executes appropriate algorithms (e.g., PC algorithm, Doubly Robust estimators) from established causal libraries.
- Step 3: Interpret the Output: The model translates raw numerical results back into fluent, human-readable explanations, ensuring the user understands the "why" behind the statistical result.
3. Benchmarking and Datasets
To facilitate training and evaluation, the researchers introduced two new high-quality benchmark datasets:
- Causal-Retrieval-Bench: Contains 1,500 pairs of causal questions and JSON summaries across five core tasks: Causal Graph Learning (CGL), Average Treatment Effect (ATE), Heterogeneous Treatment Effect (HTE), Mediation Analysis (MA), and Off-Policy Optimization (OPO).
- Causal-Interpret-Bench: Comprises 400 human-revised interpretations designed to help the model avoid common pitfalls like non-fluency and incompleteness in its explanations.
4. Key Results and Insights
LLM4Causal-Mixed, trained simultaneously on retrieval and interpretation, achieved an average "Win Rate" of 80.6% across all tasks. This significantly outperformed GPT-4, which struggled with complex tasks like Mediation Analysis (10% win rate) and Causal Graph Learning (0% win rate due to code execution failures).
Furthermore, LLM4Causal demonstrated 98% accuracy in entity extraction, compared to 77% for GPT-4-turbo. Expert evaluations confirmed that the model's interpretations were comparable or superior to those of GPT-4, with a markedly lower incidence of hallucinations and statistical errors.
5. Conclusion
LLM4Causal represents a significant step toward making advanced causal inference accessible to non-experts. By combining the linguistic flexibility of LLMs with the precision of specialized statistical tools, the framework provides a robust solution for end-to-end causal analysis. Future work will focus on expanding the task scope, enabling dynamic tool discovery, and improving interactivity for ambiguous user queries.
Summary updated