TL;DR
Flow Matching is a way to train a continuous normalizing flow, a model that turns noise into data by following a learned velocity field, without simulating the flow during training. The paper's key move is to regress the network onto a simple target vector field built one training example at a time, from a path that carries a noise sample to a data point. The paper shows this beats diffusion-model training on ImageNet in both likelihood and sample quality, and that choosing straight-line optimal transport paths makes sampling need fewer function evaluations.
Where you'll see it: the training recipe behind many modern image and video generators, and the reason "rectified flow" style models sample in a few ODE steps.
The problem
By 2022 image generation ran almost entirely on diffusion models. They were stable to train, but the training target was tied to a specific stochastic process that adds noise step by step. That tie fixed the set of probability paths the model could travel, and the paths were curved, so sampling needed many small steps.
Continuous normalizing flows (CNFs) were a more flexible alternative. A CNF is a neural network that defines a velocity field, and integrating an ordinary differential equation (ODE) along that field moves a noise sample to a data sample. Maximum likelihood training of a CNF, as in the original neural ODE work, needs an ODE solve inside every gradient step, which is slow and does not scale to high-resolution images. Other simulation-free methods existed, but they either involved intractable integrals or produced biased gradients on minibatches. So the question was whether a CNF could be trained as cheaply as a diffusion model while keeping the freedom to pick any probability path.
Key idea
Build the training target from single examples. Pick a data point , pick a noise sample , and define a path that moves to over time . This path has an exact velocity at every time, and that velocity is a known formula in , and . The network is trained to predict that velocity at the point where the path currently sits.
flowchart LR A["noise x0 ~ N(0, I)"] -->|"conditional path psi_t(x0), sampled per example"| B["data x1"] C["network v_t(x)"] -->|"regress onto known velocity"| D["u_t(x given x1)"]
The surprising part is that regressing onto these per-example velocities gives the same gradients as regressing onto the true marginal velocity field, which is intractable. You never need the marginal field. The paper calls this the Conditional Flow Matching objective. At sampling time you start from fresh noise and integrate with any ODE solver.
The paper's second idea is about which path to choose. Diffusion gives curved paths. The paper picks the path that is the optimal transport (OT) displacement between a Gaussian noise distribution and a narrow Gaussian around the data point. Under that path particles move in straight lines at constant speed, which makes the regression target simpler and the ODE easier to solve.
The method
Setup. The data distribution is unknown, but samples from it are available. The noise distribution is . The model is a vector field with learnable parameters . Time is drawn uniformly from .
Marginal objective. The Flow Matching loss would be
where is the marginal probability path that goes from noise at to approximately the data distribution at , and is the marginal vector field that generates it. Both are mixtures over , so neither has a closed form.
Conditional objective. The paper builds and by marginalizing per-example objects. For each , a conditional path runs from at to a concentrated distribution around at , with a conditional vector field that generates it. Averaging over gives the marginals. The paper proves two results:
- The marginal field generates the marginal path (Theorem 1).
- The loss has the same gradient with respect to as (Theorem 2).
The second result is the reason the method works. The conditional loss is an unbiased minibatch estimator of the gradient of the intractable one, and every term needs only one data sample at a time.
Gaussian paths. The paper restricts the conditional paths to Gaussians, , with , , and , a small positive constant. The simplest flow that pushes the standard Gaussian to this path is the affine map . Differentiating it gives the conditional field. Theorem 3 states that for Gaussian paths the unique field of this form is
where a prime is a time derivative. Reparameterizing with , the CFM loss becomes a regression of onto , with and .
The two instances the paper studies
Diffusion paths. Choosing and to match the variance-preserving diffusion process of Ho et al. gives a conditional field that the paper shows coincides with the probability-flow field used in score-based sampling. Training this field with the flow matching loss, instead of score matching, is one of the paper's comparisons.
Optimal transport paths. Choosing the mean and standard deviation to change linearly,
gives the conditional field
which is defined for all . The flow is . Each sample moves along a straight line from to at constant speed. The paper identifies this flow as the OT displacement map between the two Gaussians, which is why it is the cheapest path to follow with an ODE solver.
Worked example (OT path, one sample). Take , a noise draw , and . To keep the arithmetic exact, set here; the paper uses a small positive value, which changes the numbers slightly.
- Position: .
- Target velocity: with gives .
- Check against the path: . The two agree.
Interpretation: the velocity target is constant along the path, equal to , so the network only has to learn one direction per pair of endpoints. This is the property the paper contrasts with the diffusion target, which is the score and changes direction over time.
Training loop. The algorithm is short:
- Sample a data point , a time and a noise point .
- Compute and the target .
- Take a gradient step on , the mean squared error between predicted and target velocity.
No ODE is solved during training. Sampling solves from to with any solver.
Results
The paper trains the same U-Net architecture with five training methods on CIFAR-10 and ImageNet at 32 and 64 pixels: DDPM, score matching (SM), score flow (SF), flow matching with a diffusion path (FM w/ Diffusion), and flow matching with the OT path (FM w/ OT). The metrics are negative log-likelihood in bits per dimension (NLL, lower is better), Fréchet Inception Distance (FID, lower is better), and the average number of function evaluations (NFE) the adaptive solver needs at its tolerance. All models share architecture, hyperparameters and iteration count, and baselines get extra iterations.
| Model | CIFAR-10 NLL | CIFAR-10 FID | CIFAR-10 NFE | ImageNet-32 NLL | ImageNet-32 FID | ImageNet-32 NFE | ImageNet-64 NLL | ImageNet-64 FID | ImageNet-64 NFE |
|---|---|---|---|---|---|---|---|---|---|
| DDPM | 3.12 | 7.48 | 274 | 3.54 | 6.99 | 262 | 3.32 | 17.36 | 264 |
| Score matching | 3.16 | 19.94 | 242 | 3.56 | 5.68 | 178 | 3.40 | 19.74 | 441 |
| Score flow | 3.09 | 20.78 | 428 | 3.55 | 14.14 | 195 | 3.36 | 24.95 | 601 |
| FM w/ Diffusion | 3.10 | 8.06 | 183 | 3.54 | 6.37 | 193 | 3.33 | 16.88 | 187 |
| FM w/ OT | 2.99 | 6.35 | 142 | 3.53 | 5.02 | 122 | 3.31 | 14.45 | 138 |
FM with OT is best on every metric in this table. The gap in FID is largest on ImageNet-64, where it is 14.45 against 16.88 for the best diffusion-path model and 17.36 for DDPM. The paper notes that its CIFAR-10 FID is higher than earlier published numbers for the same family, which it attributes to an architecture not tuned for CIFAR-10.
ImageNet-128. The paper reports that FM with OT on unconditional ImageNet at 128 by 128 pixels has state-of-the-art FID among the compared methods, except for IC-GAN, which uses class-conditioning with a self-supervised ResNet-50 and is left out of the table. The exact FID value is in the right half of the paper's Table 1; this lesson does not quote it.
Training speed. Figure 5 of the paper shows FID against iterations on ImageNet-64: FM-OT lowers FID faster and to a lower level than the alternatives. For ImageNet-128 the paper compares 500k iterations at batch size 1.5k for FM against 4.36m iterations at batch size 256 for the Dhariwal and Nichol baseline, and reports 33 percent less image throughput for FM, with a model 25 percent larger. The authors also note that the sampling cost of score-matching models changes during training, while it stays constant for flow matching.
Sampling efficiency. Figure 7 (left) compares per-pixel error of low-NFE samples against 1000-NFE reference samples, on ImageNet-32 models with the midpoint solver. The paper says FM with OT needs roughly 60 percent of the function evaluations of diffusion models to reach the same error. Figure 7 (right) shows FID against NFE: FM with OT keeps a decent FID at very low NFE.
Conditional generation. On ImageNet super-resolution from 64 to 256 pixels (Table 2), FM with OT reaches FID 3.4 and Inception score 200.8, against 5.2 and 180.1 for SR3. Its PSNR (24.7) and SSIM (0.747) are lower than SR3's 26.4 and 0.762, and the regression baseline has the best PSNR and SSIM. The paper argues FID and IS are better measures of perceived quality than PSNR for this task.
Likelihood. The NLL column uses uniformly dequantized data and an importance-weighted estimate, evaluated with the dopri5 adaptive solver at tolerance 1e-5. The NLL differences are small: across the methods in the table, the spread is about 0.2 bits per dimension on CIFAR-10 and under 0.1 on ImageNet-32 and ImageNet-64, so the FID and NFE gaps carry most of the story.
Why it mattered
The paper showed that the probability path can be chosen directly, instead of being inherited from a stochastic process. That made it possible to train continuous-time generative models at the scale of diffusion models, with a simpler regression target and no ODE simulation during training. The paper's own evidence is that the straight OT trajectories need fewer solver steps. Later work built on this family of objectives; the paper itself does not report those adoptions, so treat them as outside its scope. Related concurrent work by Liu et al. and by Albergo and Vanden-Eijnden arrived at similar conditional objectives concurrently, as the paper itself notes.
Reading guide
Read the sections in this order. Each row names the lessons that carry the prerequisites for that part of the paper.
- Section 1 (Introduction). Diffusion Model for what the paper is contrasting with, and Neural Ordinary Differential Equation for continuous normalizing flows.
- Section 2 (Preliminaries). Flow Matching for the velocity field and the push-forward of a density, Jacobian Matrix for the change-of-variables determinant, and Probability Density Function for .
- Section 3.1 (Marginal vector field). Law of Total Probability is the reason the marginal path is a weighted average over (equation 6), and the same argument justifies the mixture formula for (equation 8).
- Section 3.2 (Conditional Flow Matching). Mean Squared Error for the squared loss, and Score Matching for the denoising-score-matching analogy the authors draw.
- Section 4 (Gaussian paths and OT). Stochastic Differential Equation for the diffusion processes that Section 4.1 recovers, and Probability Density Function for Gaussian densities and their affine transforms.
- Section 6 (Experiments). Diffusion Model for the baselines, and Score Matching for the score-matching loss. The evaluation metrics are defined in the paper itself.
Check yourself
QuestionRecall: what does the Conditional Flow Matching loss sample to form a training example?Show answer
QuestionComputation: with , take , , and . What are the position and the target velocity?Show answer
QuestionWhy: the paper says the conditional loss has the same gradient as the marginal Flow Matching loss. Why does that matter for training?Show answer
QuestionApplied: you want a generator that needs as few sampler steps as possible. Would you pick a curved diffusion path or the OT path, and what does the paper's evidence suggest?Show answer
Sources
- Lipman, Chen, Ben-Hamu, Nickel, Le. Flow Matching for Generative Modeling. arXiv:2210.02747, 2022. https://arxiv.org/abs/2210.02747
- Chen, Rubanova, Bettencourt, Duvenaud. Neural Ordinary Differential Equations. arXiv:1806.07366, 2018. https://arxiv.org/abs/1806.07366
- Song, Sohl-Dickstein, Kingma, Kumar, Ermon, Poole. Score-Based Generative Modeling through Stochastic Differential Equations. arXiv:2011.13456, 2020. https://arxiv.org/abs/2011.13456
- Optimal transport. https://en.wikipedia.org/wiki/Optimal_transport