NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Efficient Causal Graph Discovery Using Large Language Models

Thomas Jiralerspong, Xiaoyin Chen, Yash More, Vedant Shah, Yoshua Bengio

TL;DR

Discovering causal relationships typically requires either massive amounts of observational data or an impractical number of queries ($O(n^2)$) when prompting Large Language Models (LLMs) pairwise. This paper introduces a Breadth-First Search (BFS) prompting framework that constructs Directed Acyclic Graphs (DAGs) in only $O(n)$ LLM queries while enforcing acyclicity. The method achieves state-of-the-art causal discovery performance across small, medium, and large graphs—scaling successfully to a complex medical network with over 200 variables where prior methods fail.

What Problem Does This Paper Address?

Causal graph discovery aims to identify cause-and-effect relationships among variables, representing the underlying data generation process as a DAG. Traditional statistical and optimization methods (such as GES, PC, NOTEARS, and DAGMA) rely heavily on numerical data, struggling with sample efficiency, confounding, and computational scaling on large graphs.

Recent work showed that LLMs can deduce causal relationships from semantic metadata (e.g., variable names and medical descriptions) alone. However, these methods queried the LLM on every pair of variables, requiring $\binom{n}{2} \in O(n^2)$ calls. On a graph with 221 nodes, that translates to over 24,000 queries—rendering pairwise LLM discovery prohibitively slow and expensive.

Methods

The authors cast causal structure learning as a graph search problem traversed in topological order using BFS within a single multi-turn chat session:

  1. Initialization: The LLM receives descriptions of all candidate variables and is prompted to identify "root" causes—variables unaffected by any other variable in the system. These are added to a BFS queue.
  2. Expansion: The algorithm pops a node from the queue and prompts the LLM (conditioned on the edges found so far) to output all variables directly caused by this node in a single generation.
  3. Insertion & Cycle Prevention: Although prompted to respect the DAG structure, LLMs occasionally output edges that introduce cycles. To strictly guarantee acyclicity, each candidate edge undergoes a Depth-First Search (DFS) cycle check before being added to the graph. Valid child nodes not yet visited or queued are added to the BFS frontier.
  4. Statistical Augmentation (Optional): When observational data is available, Pearson correlation coefficients between the active node and candidate targets are appended to the expansion prompt, providing numerical grounding.

Because each variable is visited once as a cause, the entire graph is constructed in $O(n)$ queries rather than $O(n^2)$.

[Initialization] Find root variables -> Add to BFS Queue
      |
      v
[Expansion] Pop node -> LLM predicts all downstream effects at once
      |
      v
[Insertion] DFS Cycle Check -> Discard if cyclic -> Add valid edges & enqueue children

Datasets

The authors evaluated the method across three established real-world benchmarks:

  • Asia (8 nodes, 8 edges): A small diagnostic graph linking smoking and travel to lung diseases.
  • Child (20 nodes, 25 edges): A medium-sized network diagnosing congenital heart disease in newborns.
  • Neuropathic Pain (221 nodes, 770 edges): A large, realistic clinical graph modeling nerve roots, discoligamentous injuries, and patient symptoms.

No new datasets were introduced; graph structures and variable descriptions were sourced from existing literature (bnlearn and prior causal discovery benchmarks).

Key Insights and Ideas

  • Batching causal effects via topological traversal: Instead of asking "Does A cause B?" across all combinations, asking "What does A cause?" in a BFS order cuts the query complexity from quadratic to linear ($O(n)$).
  • LLMs require explicit algorithmic guardrails: Even when given the current graph history and told to produce a DAG, LLMs still hallucinate feedback loops. Pairing the LLM with an external cycle check is critical to enforce mathematical validity.
  • Common sense vs. data trade-offs: On small, intuitive systems (Asia), adding correlation data actually degraded performance (F-score dropped from 0.93 to 0.89) by introducing statistical noise into strong semantic priors. On larger, less intuitive graphs (Child), observational correlations boosted the F-score from 0.46 to 0.63.

Key Results

The framework was evaluated using Normalized Hamming Distance ratio (NHD Ratio, lower is better) and F-score against pairwise LLM prompting and standard numerical algorithms (GES, PC, NOTEARS, DAGMA):

Dataset Metric Best Baseline (Numerical / Pairwise) Proposed Method (No Data) Proposed Method (+ Data)
Asia (8 nodes) F-score / NHD Ratio 0.82 / 0.18 (GES, 10k samples) 0.93 / 0.067 0.89 / 0.11
Child (20 nodes) F-score / NHD Ratio 0.58 / 0.42 (GES, 10k samples) 0.46 / 0.54 0.63 / 0.37 (10k samples)
Neuropathic Pain (221 nodes) F-score / NHD Ratio 0.08 / 0.92 (PC, 1k samples)* 0.351 / 0.643 Omitted (budget constraints)

*On Neuropathic Pain, pairwise LLM prompting and GES were computationally intractable, and PC ran out of memory on 10k samples. Numerical methods that finished barely beat a random baseline (NHD Ratio > 0.90).

Limitations and Future Work

  • Semantic dependence: Because this approach leverages linguistic and domain knowledge, it only works on real-world systems with descriptive variable names, failing on anonymized or synthetic variables ($X_1, X_2$).
  • LLM opacity and hallucination: Predictions lack direct mechanistic provenance, relying on the model's unverified training distribution.
  • Context window limits: Maintaining history in a single multi-turn chat environment can become constrained on extremely large graphs.
  • Future Directions: Integrating more formal statistical conditional independence tests into the expansion step, testing open-source LLMs, and employing advanced search techniques like Tree of Thoughts.

Summary updated

BibTeX
@inproceedings{jiralerspong2024efficient,
  author = {Thomas Jiralerspong and Xiaoyin Chen and Yash More and Vedant Shah and Yoshua Bengio},
  title = {{Efficient Causal Graph Discovery Using Large Language Models}},
  booktitle = {AGI @ ICLR},
  year = {2024},
  url = {https://openreview.net/forum?id=5RBUTx75yr},
}
Figure