Flow Matching & Rectified Flow
Connecting noise to data using straight vector fields for fast few step generative sampling.
Beyond Traditional Diffusion
Traditional Diffusion Models (DDPM / Score-Based SDEs) transform data into Gaussian noise by repeatedly adding tiny noise steps across 1000 time steps.
Generating an image requires reversing this process step by step along curved stochastic trajectories:
Traditional Diffusion (Curved SDE Paths): Noise ──~──~──~──► Curved Path ──~──~──► Data (Takes 50 to 1000 steps!)
Flow Matching (Straight ODE Paths): Noise ──────────────────────────► Straight Line ──► Data (Takes 1 to 4 steps!)
Flow Matching and Rectified Flow replace curved SDE noise schedules with Straight Vector Field Trajectories, reducing generation time by up to 100 times!
Continuous Normalizing Flows & Vector Fields
A Continuous Normalizing Flow (CNF) defines a time dependent Velocity Vector Field $v_t(x)$.
The movement of a data point $x_t$ over continuous time $t \in [0, 1]$ is governed by an Ordinary Differential Equation (ODE):
$$\frac{d x_t}{d t} = v_t(x_t)$$
- At $t = 0$: $x_0 \sim p_0(x)$ (Simple Gaussian Noise $\mathcal{N}(0, I)$).
- At $t = 1$: $x_1 \sim p_1(x)$ (Real Data Distribution).
The goal of Flow Matching is to train a neural network $v_\theta(x, t)$ to match the true vector field $v_t(x)$.
Conditional Flow Matching (CFM)
Matching marginal vector fields directly is intractable.
Conditional Flow Matching (Lipman et al., 2022) conditions the trajectory on a specific target sample $x_1$:
Define a straight linear interpolation path between random noise $x_0$ and target data sample $x_1$:
$$x_t = (1 - t) x_0 + t x_1$$
The exact target velocity along this straight line path is simply:
$$\frac{d x_t}{d t} = x_1 - x_0$$
Simple Flow Matching Loss Function
$$\mathcal{L}{\text{CFM}}(\theta) = \mathbb{E}{t, x_0, x_1} \left[ | v_\theta(x_t, t) - (x_1 - x_0) |^2 \right]$$
The neural network simply learns to predict the direction $(x_1 - x_0)$ pointing from initial noise $x_0$ directly toward target sample $x_1$!
Rectified Flow & Reflow (Linear Trajectories)
Even with linear interpolation paths $x_t = (1-t)x_0 + t x_1$, different straight trajectory lines can cross each other in space, creating local velocity interference.
Rectified Flow (Liu et al., 2022) uses an iterative procedure called Reflow:
- Train initial Flow Model $v_\theta^{(1)}$.
- Generate synthetic pairs $(x_0, x_1 = \text{ODE}_{\text{solve}}(x_0))$.
- Retrain Flow Model $v_\theta^{(2)}$ on these un-crossed paired trajectories.
Reflow untangles overlapping paths, turning curved vector fields into perfect straight lines.
Once paths are completely straight, sampling requires taking only 1 to 4 Euler ODE steps!
Industry Adoption
Flow Matching and Rectified Flow form the core engine behind modern generative models:
- FLUX.1 (Black Forest Labs): State-of-the-art open weights image generation model.
- Stable Diffusion 3 (Stability AI): Uses Rectified Flow Matching with Multimodal Diffusion Transformers (MMDiT).
- Voicebox (Meta): Non-autoregressive speech generation via Flow Matching.
Say this out loud
Flow Matching learns a continuous velocity vector field pushing Gaussian noise into target data distributions along ODE probability paths. While traditional diffusion follows curved SDE paths requiring 50 to 1000 steps, Rectified Flow straightens trajectories, enabling high quality image and audio generation in 1 to 4 steps in models like Flux 1 and Stable Diffusion 3.
Followups to expect
- How does Flow Matching compare to Consistency Models? Consistency Models learn to map any point along a trajectory directly to origin $x_0$ in 1 step. Flow Matching learns smooth velocity fields that support flexible ODE solvers and fast distillation.
- Can Flow Matching be combined with Transformers? Yes, modern models use Diffusion Transformers (DiT / MMDiT) as the neural backbone $v_\theta(x_t, t)$ to process text prompts and image latent patches.
Check yourself
What core advantage does Rectified Flow / Flow Matching offer over traditional Diffusion Models (DDPM)?