Bayesian Network Structure Discovery Using Large Language Models

Yinghuan Zhang, Yufei Zhang, Parisa Kordjamshidi, Zijun Cui

TL;DR

This paper introduces a novel two-phase framework, PromptBN and ReActBN, that leverages Large Language Models (LLMs) for Bayesian Network (BN) structure discovery. PromptBN generates a complete, acyclic graph from variable metadata alone in a single LLM call, while ReActBN refines this graph using LLM reasoning combined with observational data. This approach significantly improves BN discovery, especially in low-data or out-of-distribution scenarios, by placing LLMs at the core of the learning process.

What Problem Does This Paper Address?

Discovering the underlying probabilistic relationships between variables in complex systems is crucial for understanding and modeling them. Traditional methods for learning these relationships, known as Bayesian Network structure learning, often demand vast amounts of observational data or rely on manual, error-prone expert input. While recent work has explored using LLMs, they've typically been relegated to auxiliary roles. This paper tackles the challenge of directly and efficiently inferring BN structures using LLMs, addressing the limitations of data dependency and manual knowledge integration. Specifically, it aims to overcome the combinatorial complexity of graph generation and the difficulty of enforcing structural constraints like acyclicity within LLM interactions.

Methods

The paper proposes a two-phase framework:

  • PromptBN (Phase 1): This data-free approach uses LLMs to directly elicit a Bayesian Network structure. It employs a "meta-prompting" strategy where the LLM is given variable metadata (name, description, distribution) and tasked with generating a complete, directed acyclic graph (DAG). Crucially, PromptBN enforces global consistency and acyclicity through dual validation and achieves a remarkable $\mathcal{O}(1)$ query complexity by generating the entire graph in a single LLM inference.
  • ReActBN (Phase 2): This phase refines the structure learned by PromptBN when observational data is available. It utilizes a "Reason-and-Act" (ReAct) inspired agentic workflow. ReActBN iteratively reasons about potential structural modifications (adding, deleting, or flipping edges) based on statistical feedback (e.g., Bayesian Information Criterion scores) and LLM-driven insights, allowing the LLM to remain central in the decision-making loop for a more integrated and interpretable approach.

Datasets

The paper evaluates its methods on ten datasets:

  • Classical Benchmarks: Asia, Cancer, Earthquake, Child, Insurance, Alarm, and Hailfinder (from Bnlearn).
  • Newer Benchmarks: Blockchain, consequence-Covid (referred to as covid), and disputed3 (from BnRep). These newer datasets are highlighted for their potential to assess generalization and out-of-distribution performance, as they are less likely to be present in LLM pre-training corpora.

Key Insights and Ideas

  • LLMs as Core Learners, Not Just Tools: The paper demonstrates that LLMs can be central to BN structure discovery, not just auxiliary tools for pre-processing or post-processing. PromptBN's ability to generate a complete DAG from metadata alone is a significant step in this direction.
  • $\mathcal{O}(1)$ Query Complexity for Data-Free Discovery: PromptBN's achievement of constant query complexity for generating a full DAG is a major breakthrough, making LLM-based structure learning far more efficient and scalable than previous methods that required numerous queries.
  • ReActBN Balances Reasoning and Data: The ReActBN framework effectively combines the symbolic reasoning capabilities of LLMs with the statistical evidence from observational data, leading to superior performance, especially in low-data regimes.
  • Robustness to Out-of-Distribution Data: The performance on newer, less common datasets suggests that the proposed framework generalizes well and is not simply memorizing patterns from well-known benchmarks.
  • Contamination Tests Validate Reasoning: Experiments designed to test for memorization show that PromptBN relies on genuine relational reasoning from metadata rather than simply recalling pre-learned structures.

Key Results

  • Superior Performance: ReActBN consistently outperforms state-of-the-art data-only, LLM-only, and hybrid baselines across various datasets, particularly in low-data or no-data scenarios. For instance, it achieves exact recovery on the Cancer network (SHD=0) and the best results on 6 out of 9 classical datasets.
  • Data-Free Excellence: PromptBN demonstrates strong performance even without any observational data, achieving exact recovery on Asia (SHD=0) and high fidelity on Cancer (SHD=0.6).
  • Scalability: The $\mathcal{O}(1)$ query complexity of PromptBN and the efficient iterative nature of ReActBN make them highly scalable compared to other LLM-based approaches.
  • Generalization: On newer, out-of-distribution datasets, PromptBN shows substantial improvements over existing LLM-only methods, and ReActBN remains competitive, highlighting robustness under distribution shifts.

Limitations and Future Work

  • LLM Contamination: The authors acknowledge that the undisclosed training corpora of LLMs mean potential contamination cannot be fully ruled out, though their contamination tests suggest reasoning, not memorization, is the primary driver of performance.
  • LLM Choice Impact: While PromptBN performs well across various LLMs, the paper notes that more advanced models don't always guarantee better performance, suggesting further research into optimal LLM selection for this task.
  • Future Work: The paper implicitly suggests future work could involve exploring more sophisticated ReAct-style reasoning strategies, investigating different scoring functions, and further analyzing the interplay between LLM capabilities and data availability for optimal BN discovery.

Summary updated

BibTeX
@article{zhang2026bayesian,
  author = {Yinghuan Zhang and Yufei Zhang and Parisa Kordjamshidi and Zijun Cui},
  title = {{Bayesian Network Structure Discovery Using Large Language Models}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2026},
}
Figure