Designing a Conditional Prior Distribution for Flow-Based Generative Models

Noam Issachar, Mohammad Salama, Raanan Fattal, Sagie Benaim

TL;DR

Standard flow-based and diffusion generative models needlessly map generic Gaussian noise to specific conditional targets, leading to long integration paths and slow sampling. This paper proposes Conditional Prior Distribution (CPD), which starts the flow from a condition-specific Gaussian centered near the "average" target data point for that class or text prompt. By dramatically shortening flow trajectories, the method achieves higher-quality images with significantly fewer sampling steps (NFEs) and faster training convergence.

What Problem Does This Paper Address?

Continuous Normalizing Flows (CNFs) trained via Flow Matching typically transform a standard, condition-agnostic Gaussian prior $\mathcal{N}(0, I)$ into a multimodal data distribution. Even in conditional generation (e.g., class-conditional or text-to-image), models still start from this generic noise distribution and inject the prompt via cross-attention.

Because the initial noise has no knowledge of the prompt, any noise sample can be mapped to any target mode, resulting in long, winding trajectories. In numerical Ordinary Differential Equation (ODE) integration, longer paths lead to higher global truncation errors, forcing samplers to take many small steps (high Number of Function Evaluations, or NFE). Previous attempts to straighten paths (like minibatch Optimal Transport) incur quadratic computational costs and struggle to scale in high dimensions without enormous batch sizes.

Methods

The authors introduce Conditional Prior Distribution (CPD) for flow matching, constructing an informative prior $p_0(x_0|c)$ tailored to the input condition $c$:

  • Discrete Conditioning (e.g., ImageNet classes): The prior modes are estimated directly from training data in latent space. Each class $c$ defines a Gaussian cluster $\mathcal{N}(\mu_c, \Sigma_c)$, where $\mu_c = \mathbb{E}[x_1|c]$ and $\Sigma_c = \text{cov}[x_1|c]$.
  • Continuous Conditioning (e.g., text-to-image): To handle unseen text prompts, the prompt $c$ is mapped through a pre-trained CLIP text encoder $E(c)$, followed by a lightweight mapper network $P_\theta$ (a linear layer plus two ResNet blocks). $P_\theta$ is trained with an $L_2$ regression loss to predict the mean data representation $\mathbb{E}[x_1|c]$. The prior covariance is modeled as an isotropic Gaussian $\Sigma_c = \sigma^2 I$.
  • Conditional Joint Flow Matching: The vector field interpolates directly between the condition-dependent initial Gaussian at $t=0$ and the target data point $x_1$ at $t=1$, maintaining straight paths with closed-form marginals.
Standard Flow Matching:   N(0, I) ---------------------------> Target Mode c (Long, random paths)
CPD (Ours):               N(μ_c, Σ_c) [Near average c] -------> Target Mode c (Short, direct paths)

Datasets

The authors evaluate their method on:

  • 2D Synthetic Toy Dataset: A mixture of isotropic Gaussians mapped to 2D target squares.
  • ImageNet-64: Class-conditional generation with over 1.28M training images across 1,000 categories (resized to $64 \times 64$).
  • MS-COCO (2017 Split): Text-to-image generation using 118k training images and 5k validation images. All real-world experiments are conducted within the latent space of a pre-trained autoencoder.

Key Insights and Ideas

  • Truncation Error is Path-Dependent: ODE truncation error bounds scale with path length and the Lipschitz constant of the velocity field. Shortening the Euclidean distance between prior and target samples allows coarser integration step sizes without accumulating fatal discretization errors.
  • Conditioning Already Segments Data Space: Instead of running expensive mini-batch Optimal Transport to find good noise-to-data pairings, the conditioning label itself naturally partitions the data. Centering noise around the conditional centroid provides a computationally free distance reduction.
  • The "Average Image" Seed: For text prompts, the mapper $P_\theta$ outputs a blurry, representative "centroid" image for that text concept. Adding variance $\sigma$ around this centroid provides the stochastic diversity needed for generation while keeping endpoints close.

Key Results

  • Shorter Transport Distances: CPD reduces the average distance between prior and target samples to 570 on ImageNet-64 and 510 on MS-COCO, beating both standard Flow Matching (640 / 630) and BatchOT (632 / 604).
  • Superior Quality at Low NFEs:
  • At NFE = 15, CPD achieves an FID of 13.62 on ImageNet-64 (where baselines fail to break below 16.10).
  • At NFE = 15 on MS-COCO, CPD reaches an FID of 18.05, while baseline flow matching remains above 28.32.
  • CPD matches or outperforms baseline convergence quality in roughly half the sampling steps (converging near 15–20 steps).
  • Faster Training: Models reach lower FID scores earlier in training epochs compared to standard flow matching and DDPM.
  • Ablations: On MS-COCO, a prior standard deviation of $\sigma = 0.7$ achieved the best trade-off (FID 7.55, KID 0.61, CLIP 15.85). Replacing the pre-trained CLIP text embedding with a bag-of-words representation severely degraded performance (FID worsened to 16.33).

Limitations and Future Work

  • Simplified Covariance Structure: For continuous conditions (text), the prior variance is treated as a fixed isotropic scalar hyperparameter ($\sigma^2 I$), which may fail to capture complex, multimodal conditional distributions.
  • Hyperparameter Tuning: The sampling quality and diversity depend on tuning $\sigma$; setting it too low limits sample diversity, while setting it too high sacrifices path shortness.
  • Future Directions: Expanding beyond simple Gaussian Mixture structures to model multi-modal conditional distributions, and extending the framework to other conditional modalities such as depth maps or segmentation masks.

Summary updated

BibTeX
@article{issachar2025designing,
  author = {Noam Issachar and Mohammad Salama and Raanan Fattal and Sagie Benaim},
  title = {{Designing a Conditional Prior Distribution for Flow-Based Generative Models}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=Teh9Bq4giF},
}
Figure