Stanford CME296 Diffusion & Large Vision Models | Spring 2026 | Lecture 3 - Flow matching

By Unknown Author

Share:

Key Concepts

  • Flow Matching: A generative modeling paradigm that learns a vector field (velocity) to transport an initial distribution (e.g., Gaussian noise) to a target data distribution.
  • Vector Field ($u_t(x)$): A function defining the direction and speed of particles at any point in space and time.
  • Probability Path ($p_t(x)$): The continuous evolution of the probability density from the initial distribution ($p_0$) to the target distribution ($p_1$).
  • Continuity Equation: A fundamental PDE relating the temporal evolution of density to the divergence of the probability flux ($p_t \cdot u_t$).
  • Lipschitz Continuity: A condition on the vector field ensuring that trajectories are unique for a given initial condition.
  • Conditional Flow Matching (CFM): A tractable training objective that simplifies the learning of the vector field by conditioning on target data points ($x_1$).
  • Reflow: An iterative procedure to "straighten" the trajectories of a trained flow model, enabling faster inference.

1. The Flow Matching Paradigm

Flow matching aims to transport an initial distribution $p_0$ (typically Gaussian noise) to a target distribution $p_1$ (clean data). Unlike diffusion models that rely on stochastic differential equations (SDEs) to add and remove noise, flow matching focuses on learning a deterministic vector field that guides particles along a trajectory from $p_0$ to $p_1$.

  • Trajectory ($x_t$): The path taken by a sample from $t=0$ to $t=1$.
  • Flow ($\psi_t(x_0)$): A function mapping an initial condition $x_0$ to its position at time $t$.
  • Key Distinction: While diffusion models use a "compass" (the score function) to navigate toward high-density regions, flow matching uses "velocity instructions" (the vector field) to move particles directly toward the target.

2. Mathematical Framework

The core of flow matching is the Continuity Equation, which ensures mass conservation during transport: $$\frac{\partial p_t(x)}{\partial t} + \nabla \cdot (p_t(x) u_t(x)) = 0$$ This equation links the macro-perspective (density evolution) to the micro-perspective (individual particle movement via the ODE $dx = u_t(x) dt$).

3. Training Methodology: Conditional Flow Matching

Directly maximizing the likelihood of the data is computationally expensive due to the need to solve ODEs during training. Flow matching bypasses this by using Conditional Flow Matching (CFM):

  • Simplification: Instead of mapping $p_0$ to $p_1$ directly, the model learns to map $p_0$ to a single point $x_1$ (a Dirac distribution).
  • Tractable Loss: The loss function is simplified to the expected squared distance between the learned vector field $u_t^\theta(x)$ and the conditional vector field: $$\mathcal{L}{CFM} = \mathbb{E}{t, x_1, x} | u_t^\theta(x) - (x_1 - x_0) |^2$$
  • Equivalence: It is mathematically proven that optimizing this conditional loss is equivalent to optimizing the global flow matching loss, providing the same gradients for the model parameters $\theta$.

4. Reflow: Improving Inference Efficiency

Standard flow models often produce curved trajectories, requiring many steps for numerical ODE solvers (like Euler) to reach the target.

  • The Process: After training an initial model, one can sample new trajectories, use the endpoints as new "target" pairings, and retrain the model.
  • Outcome: This "straightens" the paths. Straighter paths allow for high-quality generation in very few inference steps, significantly speeding up the sampling process.

5. Comparison with Diffusion and Score Matching

The lecture synthesizes the three paradigms:

  • Diffusion (DDPM): Focuses on learning a reverse noise-removal process using L2 regression on noise.
  • Score Matching: Learns the gradient of the log-density ($\nabla \log p_t(x)$) to act as a compass toward high-density regions.
  • Flow Matching: Learns the velocity field to transport density deterministically.
  • Unified View: The paper Stochastic Interpolants suggests that noise, score, and velocity are deeply linked; knowing any two allows for the derivation of the third.

Synthesis/Conclusion

Flow matching represents a shift toward deterministic, efficient generative modeling. By framing the generation process as a transport problem governed by a vector field, it achieves high performance with simpler, more tractable training objectives. The "Reflow" technique further optimizes this by straightening trajectories, making flow matching a highly competitive alternative to traditional diffusion-based generative models.

Chat with this Video

AI-Powered

Hi! I can answer questions about this video "Stanford CME296 Diffusion & Large Vision Models | Spring 2026 | Lecture 3 - Flow matching". What would you like to know?

Chat is based on the transcript of this video and may not be 100% accurate.

Related Videos

Ready to summarize another video?

Summarize YouTube Video