Regularized Offline GFlowNets

Haozhi Wang, yunfeng shao, Jianye Hao, Yinchuan LiOpenReview 2023 · Submission to Tiny Papers @ ICLR

Generative Flow Networks (GFlowNets) are a powerful class of models designed to sample diverse objects with probabilities proportional to their rewards. Traditionally, they rely on "online" sampling—interacting directly with an environment to explore and learn. However, in many real-world applications like drug discovery or industrial logs, we only have access to static, "offline" datasets.

The challenge is that offline datasets rarely cover the entire state space. When a standard GFlowNet is trained on this limited data, it often struggles to generalize to out-of-distribution (OOD) actions. It might assign high "flow" to actions it has never seen, leading to unstable training and poor performance. This is a classic problem in offline Reinforcement Learning, but it has remained largely unresolved for GFlowNets until now.

To address this, researchers have proposed Regularized Offline GFlowNets (RO-GFlowNets). By penalizing OOD actions using a learned density model, the algorithm avoids the "hallucination" of flows in unseen states, leading to faster convergence and better discovery of diverse, high-reward modes.

Methods

The core idea behind RO-GFlowNets is to constrain the learned policy so it doesn't stray too far from the actions present in the offline dataset. The approach involves three main steps:

  1. Density Estimation: A separate neural network is trained to approximate the action distribution of the offline dataset. Essentially, this network learns what actions the original data-collector took in any given state.
  2. Constrained Optimization: Training is formulated as a constrained problem. The goal is to minimize the standard flow-matching loss while ensuring the learned policy stays within a certain "distance" of the offline data distribution.
  3. Action Masking: During training and sampling, a threshold ($\delta$) is used. If the density model indicates an action is highly unlikely (probability below $\delta$), that action is masked out. This forces the model to ignore OOD state-action pairs and focus on the reliable data it actually possesses.

Datasets and Key Insights

The researchers evaluated their method using a Hyper-Grid environment, a standard benchmark for GFlowNets where an agent moves through a multi-dimensional grid to find high-reward cells ("modes"). They tested on two types of offline data: a Random Dataset (sparse coverage) and a Random-Optimal Dataset (a mixture of optimal and random policies representing good but incomplete data).

Several key insights emerged from the study:

  • The "OOD Penalty" is Essential: Without regularization, GFlowNets "hallucinate" flows in unknown regions, ruining the consistency of the flow network. By explicitly modeling the data distribution, RO-GFlowNets stay grounded in reality.
  • Model-Based Approaches Fall Short: Compared against a model-based approach (MO-GFlowNets) that tries to learn a transition model of the environment, the authors found that errors in the learned transition model compound quickly, making it less effective than direct regularization.
  • The Threshold Trade-off: There is a "Goldilocks" zone for the threshold $\delta$. If it is too low, OOD actions leak in; if it is too high, the model becomes too restrictive and fails to sample diversely.

Key Results

RO-GFlowNets demonstrated significant improvements over baseline methods in both accuracy and mode discovery.

Superior Accuracy: In the Hyper-Grid task, RO-GFlowNets achieved a significantly lower $\ell_1$-error (a measure of how closely the learned sampling matches the true reward distribution) compared to vanilla offline GFlowNets.

L1 Error comparison showing RO-GFlowNets achieving significantly lower error.

Mode Discovery: On the random-optimal dataset, RO-GFlowNets successfully found nearly all 16 modes (high-reward peaks), whereas the baseline methods often found fewer than five.

Mode discovery performance showing RO-GFlowNets finding nearly all 16 modes.

Convergence Speed: The regularization allowed the model to converge much faster by preventing the optimization process from wasting time on impossible or unknown state-action transitions.

Limitations and Future Work

While RO-GFlowNets offer a robust solution for offline training, the current research focuses on discrete environments (like the grid world). Extending this regularization to continuous action spaces—such as robotic control or continuous molecular folding—remains a challenge.

Furthermore, like all offline methods, RO-GFlowNets are inherently limited by dataset quality. If the offline dataset contains zero samples near a high-reward mode, the model will likely never find it. Future work will likely explore extending these principles to more complex, continuous-space tasks to broaden the applicability of offline GFlowNets.

Summary updated

BibTeX
@misc{wang2023regularized,
  author = {Haozhi Wang and yunfeng shao and Jianye HAO and Yinchuan Li},
  title = {{Regularized Offline GFlowNets}},
  year = {2023},
  url = {https://openreview.net/forum?id=kbhUUAMZmQT},
  howpublished = {OpenReview},
  note = {Submitted to Tiny Papers @ ICLR},
}
Figure