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

Bayesian Structure Learning with Generative Flow Networks

Tristan Deleu, António Góis, Chris Chinenye Emezue, Mansi Rankawat, Simon Lacoste-Julien, Stefan Bauer, Yoshua Bengio

Abstract

In Bayesian structure learning, we are interested in inferring a distribution over the directed acyclic graph (DAG) structure of Bayesian networks, from data. Defining such a distribution is very challenging, due to the combinatorially large sample space, and approximations based on MCMC are often required. Recently, a novel class of probabilistic models, called Generative Flow Networks (GFlowNets), have been introduced as a general framework for generative modeling of discrete and composite objects, such as graphs. In this work, we propose to use a GFlowNet as an alternative to MCMC for approximating the posterior distribution over the structure of Bayesian networks, given a dataset of observations. Generating a sample DAG from this approximate distribution is viewed as a sequential decision problem, where the graph is constructed one edge at a time, based on learned transition probabilities. Through evaluation on both simulated and real data, we show that our approach, called DAG-GFlowNet, provides an accurate approximation of the posterior over DAGs, and it compares favorably against other methods based on MCMC or variational inference.

Introduction

Discovering the causal or statistical relationships between variables is a fundamental task in many scientific disciplines. These relationships are typically represented as a Bayesian Network, which uses a Directed Acyclic Graph (DAG) to encode dependencies. However, "structure learning"—the process of identifying the underlying DAG from observational data—is notoriously difficult. The space of possible graphs grows super-exponentially with the number of variables, making exhaustive search impossible.

Furthermore, real-world data often exhibits epistemic uncertainty, where multiple distinct graphs explain the observations equally well. Traditional approaches like Markov Chain Monte Carlo (MCMC) often struggle with slow mixing and getting trapped in local modes. Variational Inference (VI) methods, while faster, frequently rely on continuous relaxations that do not strictly guarantee acyclicity. This paper introduces DAG-GFlowNet, a novel framework that treats graph discovery as a sequential generative process, ensuring acyclicity while efficiently sampling from the posterior distribution.

Methodology: DAG-GFlowNet

The core idea of DAG-GFlowNet is to learn a stochastic policy that constructs a DAG by adding one edge at a time, starting from an empty graph. This transforms the static search problem into a sequential decision process.

Sequential construction of a DAG in DAG-GFlowNet, ensuring acyclicity by masking invalid transitions.

Key Technical Components

  • Acyclicity by Construction: To maintain the DAG property, the model employs a mask at each step to filter out any edges that would introduce a cycle. This ensures that every terminal state in the generation process is a valid DAG.
  • Detailed-Balance Loss: The authors utilize a "detailed-balance" formulation for the GFlowNet objective. The model learns to balance the "flow" into and out of states such that the terminal flow is proportional to the Bayesian score (reward) of the resulting graph.
  • Linear Transformers: Handling the $d^2$ possible edges for $d$ nodes is computationally expensive. By using Linear Transformers, the authors reduce the complexity from $O(d^4)$ to a more manageable scale, allowing the model to handle larger graphs.
  • Off-Policy Learning: Drawing from Reinforcement Learning, the framework uses a replay buffer and target networks to stabilize training and encourage exploration of the graph space.

Experimental Evaluation

The performance of DAG-GFlowNet was assessed across various benchmarks, including simulated Linear-Gaussian networks (5, 20, and 50 nodes) and the Sachs protein signaling dataset.

Results

On small graphs ($d=5$) where the exact posterior can be computed, DAG-GFlowNet demonstrated exceptional accuracy. The learned distribution achieved a Pearson correlation of $r > 0.99$ with the true posterior across various graph features, including edge, path, and Markov properties.

Correlation between the exact posterior and the distribution learned by DAG-GFlowNet for different graph features.

In larger settings ($d=20$), DAG-GFlowNet outperformed or matched state-of-the-art MCMC (e.g., Gadget) and VI (e.g., DiBS) methods. Specifically, it showed superior performance in Expected Structural Hamming Distance (E-SHD) and AUROC. On the Sachs dataset, the model successfully identified multiple Markov Equivalence Classes (MECs), proving its ability to capture diverse modes of the posterior rather than collapsing to a single high-scoring graph.

Discussion and Future Work

DAG-GFlowNet offers several advantages over traditional methods. Its ability to generate independent, identically distributed (IID) samples once trained avoids the correlation issues inherent in MCMC. Additionally, the modular nature of Bayesian scores allows for efficient "delta score" calculations during the edge-addition process.

However, challenges remain. While Linear Transformers improve scalability, the state space growth still limits the approach to graphs with dozens of nodes. Furthermore, very "peaky" posteriors resulting from large datasets can make training more difficult. Future research may explore learning "essential graphs" directly to represent equivalence classes, potentially simplifying the search space and further improving scalability for high-dimensional causal discovery.

Summary updated

BibTeX
@inproceedings{deleu2022bayesian,
  author = {Tristan Deleu and António Góis and Chris Chinenye Emezue and Mansi Rankawat and Simon Lacoste-Julien and Stefan Bauer and Yoshua Bengio},
  title = {{Bayesian Structure Learning with Generative Flow Networks}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2022},
  url = {https://openreview.net/forum?id=HElfed8j9g9},
}
Figure