---
title: Energy-Based Generative Flow Networks
url: https://www.emergentmind.com/topics/energy-based-generative-flow-networks-eb-gfn
type: topic
---

# Energy-Based Generative Flow Networks

Energy-Based Generative Flow Networks (EB-GFN) are a probabilistic modeling paradigm that combines energy-based models (EBMs) with the sequential, trajectory-based sampling framework of generative flow networks (GFlowNets). The central objective is to train models capable of sampling high-dimensional, often discrete objects $x$ with marginal distribution proportional to the Boltzmann weight $\propto \exp(-E(x))$, where $E(x)$ is a parameterized energy function or neural potential. Unlike conventional MCMC-based approaches, EB-GFN amortizes the typically expensive negative-sampling and mixing behavior into a learned stochastic policy over a finite sequence of actions, enabling scalable and diverse sampling from complex, multimodal distributions [2202.01361].

## 1. Mathematical Foundations

Energy-based generative flow networks formalize sampling from a discrete input space $\mathcal{X}$ using both an energy function $E_\theta(x)$ (EBM) and a flow-based sampler (GFlowNet). The energy model defines the unnormalized distribution
\[
p_\theta(x) \propto \exp(-E_\theta(x)),
\]
with intractable normalizer $Z_\theta = \sum_x \exp(-E_\theta(x))$.

A GFlowNet models the construction of $x$ as a trajectory $\tau = (s_0 \to s_1 \to \cdots \to s_D = x)$ over a directed acyclic graph, with $s_0$ the root and $s_D$ the terminal state. The GFlowNet defines a flow $F$ over trajectories, parameterized as forward and backward policies $P_F$, $P_B$, and scalar $Z$, such that
\[
P_F(\tau) = \prod_{t=0}^{D-1} P_F(s_{t+1}|s_t), \qquad P_B(\tau) = \prod_{t=0}^{D-1} P_B(s_t|s_{t+1}).
\]
The induced marginal distribution $P_T(x) = \sum_{\tau:\tau_D=x} P_F(\tau)$ is trained to approximate $p_\theta(x)$ [2202.01361].

## 2. Training Objectives and Joint Algorithms

Training of EB-GFNs typically employs a joint optimization of both energy and flow parameters:
- **Trajectory balance (TB)** objective for the GFlowNet, requiring that for each $\tau$ terminating at $x$,
  \[
  \ell_\text{TB}(\tau;\theta,\phi) = \bigg[\log Z_\phi + \sum_{t=0}^{D-1} \log P_F(s_{t+1}|s_t; \phi) - \big(\log R_\theta(x) + \sum_{t=0}^{D-1} \log P_B(s_t|s_{t+1}; \phi)\big)\bigg]^2,
  \]
  with $R_\theta(x) = \exp(-E_\theta(x))$.

- **Approximate MLE for the EBM**, replacing the intractable expectation over $p_\theta$ with negative samples from $P_T$:
  \[
  \Delta\theta \propto \mathbb{E}_{x^+\sim p_\text{data}}[\nabla_\theta E_\theta(x^+)] - \mathbb{E}_{x^-\sim P_T}[\nabla_\theta E_\theta(x^-)].
  \]

Algorithmic training alternates between GFlowNet and EBM steps, frequently using GFlowNet-guided large-block Gibbs moves to sample negatives efficiently—even allowing amortization of negative-sample generation into the learned forward policy $P_F$ [2202.01361, 2211.00568].

## 3. Energy Decomposition and Partial Inference

A principal innovation in EB-GFN methodology is the transition-based energy decomposition, notably the Learned Energy Decomposition GFlowNet (LED-GFN) variant [2310.03301]. Instead of assuming terminal energy evaluation is always accessible and informative, LED-GFN posits a learnable decomposition:
\[
E(x) \approx \Phi_\theta(\tau) := \sum_{t=0}^{T-1} \phi_\theta(s_t \to s_{t+1})
\]
with $\phi_\theta$ parameterized as a neural network over state transitions. This reparameterization yields a set of flow-consistency constraints:
\[
\log \tilde F(s) + \log P_F(s'|s) + \phi_\theta(s \to s') = \log \tilde F(s') + \log P_B(s|s')
\]
where $\tilde F(s)$ absorbs accumulated local potentials.

To enforce a stable, dense local credit, LED-GFN applies a smoothness regularization:
\[
\mathcal{R}(\theta) = \lambda \sum_{t=1}^{T-1} \|\phi_\theta(s_{t-1}\to s_t) - \phi_\theta(s_t\to s_{t+1})\|^2
\]
and fits $\sum_{t}\phi_\theta(s_t\to s_{t+1})\approx E(x)$ via a least-squares objective with Bernoulli-masked terms to avoid degenerate decompositions [2310.03301].

## 4. Variational and Flow-Contrastive Perspectives

The relation between GFlowNets and variational inference is captured through trajectory-wise KL divergence objectives. The forward KL ($P\parallel Q$), reverse KL ($Q\parallel P$), and mixed convex combinations are all interpretable as generative flow network losses, specifically trajectory balance [2210.07992]. Control variates and learned scalar baselines are deployable to reduce the variance of TB/variational-gradient estimators.

Alternatively, flow-contrastive estimation (FCE) establishes an adversarial joint training between energy-based and flow-based models, coupling their updates such that the EBM performs noise-contrastive estimation with the flow as a noise source, while the flow model approximately minimizes Jensen-Shannon divergence to the data [1912.00589].

## 5. Joint Modeling of Structured Outputs and Conditional Distributions

Energy-based GFlowNets have been effectively extended to the modeling of joint distributions over complex objects and attributes. For example, Joint Energy-Based GFlowNets (JEB-GFN) optimize a joint energy $E_\phi(x,y)$ over pairs $(x,y)$, treating $R(x, y) = \exp(-E_\phi(x,y))$ as GFlowNet reward, and train both sampler and energy synchronously. This joint modeling enables both unconditional and conditional sampling, avoids reward–sampler mismatch, and yields consistent marginals [2211.00568].

Empirical studies in applications such as antimicrobial peptide design demonstrate that JEB-GFN approaches produce higher-scoring, more diverse, and more novel candidates than either baseline GFlowNets with fixed predictors or semi-supervised variational autoencoders, especially in active learning settings [2211.00568].

## 6. Practical Considerations and Empirical Performance

EB-GFNs have been validated on a range of high-dimensional discrete tasks, including Ising models, multimodal synthetic densities, discrete image data (Omniglot, MNIST variants), molecular docking, RNA sequence design, and combinatorial optimization problems [2202.01361, 2310.03301]. Key findings include:

- Significant gains in mode discovery, sample diversity, and coverage over standard GFlowNet, forward-looking GFlowNet, MCMC-based contrastive divergence, and other learned local samplers.
- Stability in training due to mixing forward and backward sampled trajectories and smoothness-regularized potentials.
- Efficient amortization of negative-sample generation, eliminating the necessity for lengthy MCMC.
- Robust matching or improvement over oracle-aided baselines even when intermediate energy estimates are available (“ideal local credit”) [2310.03301].

## 7. Limitations and Future Directions

EB-GFN methodologies are currently most mature for purely discrete domains. The challenges in scaling include computational costs of MCMC-based negative sampling for long trajectories, limitations of discrete transition modeling, and integration with continuous-variable spaces. Active research directions involve hybrid discrete–continuous proposal mechanisms, improving negative sampling efficiency, and theoretical analysis of sample complexity and convergence rates in joint energy/sampler optimization [2211.00568].

A plausible implication is that as these architectures advance, EB-GFNs may present a general-purpose, amortized alternative to conventional MCMC and EBMs, particularly in structured and combinatorial domains that resist both tractable likelihood modeling and efficient direct sampling.

Source: https://www.emergentmind.com/topics/energy-based-generative-flow-networks-eb-gfn