GFlowNet-EM for Learning Compositional Latent Variable Models

Edward J. Hu, Nikolay Malkin, Moksh Jain, Katie E. Everett, Alexandros Graikos, Yoshua Bengio

Latent variable models (LVMs) are foundational to unsupervised learning, enabling the representation of high-dimensional data through simpler, hidden structures. However, when these hidden structures are discrete and compositional—such as the branching tree of a sentence's grammar or the arrangement of objects in a visual scene—traditional training methods often hit a computational wall.

In the ICML 2023 paper, "GFlowNet-EM for Learning Compositional Latent Variable Models," Edward J. Hu and colleagues introduce a novel framework that leverages Generative Flow Networks (GFlowNets) to train these complex models more effectively. By using GFlowNets as amortized samplers, the authors successfully navigate the "intractable E-step" in Expectation-Maximization (EM), outperforming standard variational methods in both grammar induction and image modeling.

The Problem: The Intractable E-Step

The gold standard for training LVMs is the Expectation-Maximization (EM) algorithm, which operates in two alternating steps:

  1. E-step: Calculate the posterior distribution (the probability of different hidden structures given the observed data).
  2. M-step: Update the model parameters to maximize the likelihood of those hidden structures generating the data.

The primary bottleneck lies in the E-step. If the hidden structure is a tree, the number of possible configurations for a single sentence grows combinatorially. Calculating the exact posterior becomes computationally intractable. To circumvent this, researchers typically rely on Variational EM, which assumes the hidden variables are independent (the "mean-field" assumption). While mathematically convenient, this assumption is fundamentally flawed for compositional data; in a parse tree, the choice of one branch depends heavily on the others. This "expressivity gap" severely limits the learning capacity of the model.

The GFlowNet-EM Framework

To bridge this expressivity gap, the authors propose GFlowNet-EM, which replaces the traditional approximate posterior with a GFlowNet.

Why GFlowNets?

GFlowNets are designed to sample complex objects (like trees or graphs) by constructing them sequentially. They are trained to sample an object with a probability proportional to a given "reward" function. In the context of EM, this reward is the joint probability of the data and the latent structure.

Key Innovations

  • Amortized Posterior Sampling: Instead of executing a slow, exhaustive search for every new data point, the GFlowNet learns a policy to construct the posterior distribution efficiently.
  • The Sleep Phase: To prevent "posterior collapse"—a common failure mode where the model repeatedly selects a single structure—the authors incorporate a "sleep phase." The generative model "dreams" by generating data from its current internal state, and the GFlowNet is trained to recover that state, ensuring robust exploration.
  • Adaptive Thresholding: Jointly training a sampler and a generative model is notoriously unstable. The framework employs a loss-based threshold to determine when the GFlowNet is sufficiently "ready" to permit an update to the generative model.

Experimental Validation

The authors evaluated GFlowNet-EM across three distinct domains to test its versatility and performance:

  1. Hierarchical Mixture Model: A synthetic Gaussian dataset designed to demonstrate that factorized (independent) posteriors fail when strong dependencies exist between latent variables.
  2. Penn Tree Bank (PTB): A standard natural language processing benchmark used for Grammar Induction (discovering the underlying syntactic rules of a language without explicit supervision).
  3. Static MNIST: The classic handwritten digit dataset, utilized to test Discrete Variational Autoencoders (VAEs).

Key Insights and Results

The empirical results highlight several major advantages of the GFlowNet-EM approach:

  • Breaking the Independence Constraint: Unlike VQ-VAEs or standard Variational EM, GFlowNet-EM does not require latent variables to be independent. This enables the model to capture the combinatorial reasoning necessary for complex structures.
  • Superior Grammar Induction: GFlowNet-EM successfully induced non-context-free grammars, which are highly expressive but notoriously difficult to train. It achieved a lower Negative Log-Likelihood (NLL) per word ($\le 5.46$) compared to standard marginalization methods ($5.61$).
  • Integrating Global Priors: The framework makes it easy to incorporate "black-box" priors. By adding an Energy-Based Model (EBM) prior to encourage trees that resemble human-annotated structures, the model's "Sentence F1" score jumped significantly from 39.51 to 48.41.
  • Enhanced Image Modeling: In Discrete VAE experiments on MNIST, GFlowNet-EM significantly outperformed the popular VQ-VAE baseline, reducing the NLL from 82.96 to 70.67 (at a codebook size of 10). This indicates that the GFlowNet's expressive posterior allows the decoder to learn vastly superior representations.

Limitations and Future Directions

While GFlowNet-EM represents a significant step forward, it comes with trade-offs:

  • Computational Cost: The method is computationally heavier than baselines like VQ-VAE. Constructing a single latent sample requires multiple forward passes, leading to longer training times (e.g., 3 hours versus 15 minutes for MNIST).
  • Hyperparameter Sensitivity: Jointly training the GFlowNet and the generative model requires meticulous tuning of learning rates and the adaptive thresholding schedule.
  • Scaling Challenges: While successful on MNIST and PTB, scaling the framework to high-resolution images or massive language datasets remains an open challenge.

Future work will likely explore hybrid latent spaces—combining discrete and continuous variables—to mitigate computational costs while retaining the expressive power of GFlowNet-EM.

Summary updated

BibTeX
@inproceedings{hu2023gflownet,
  author = {Edward J. Hu and Nikolay Malkin and Moksh Jain and Katie E. Everett and Alexandros Graikos and Yoshua Bengio},
  title = {{GFlowNet-EM for Learning Compositional Latent Variable Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=3_8dz2eoEek},
}
Figure