Applied AI Vol. 2

Flow Matching and Rectified Flow: Straighter Paths From Noise to Data

Instead of learning to reverse a noising process, learn a velocity field that carries noise to data along near-straight lines.

Applied AI Vol. 2 · 5 min read

Flow matching reframes generation as moving samples along a learned vector field, often with simpler training and fewer sampling steps than classic diffusion.

The idea

Pick a noise sample x0 and a data sample x1, and connect them with a path. In the simplest case the path is a straight line, so the point at time t is (1 − t) times x0 plus t times x1, and its velocity is constant, x1 minus x0.

Train a network to predict that velocity from the point and the time, by regressing on it with a squared error loss. Over many random pairs, the network learns an average velocity field that transports the noise distribution to the data distribution.

Sampling

To generate, draw noise and integrate the ordinary differential equation defined by the learned velocity from t = 0 to t = 1, using a numerical solver. Because paths are close to straight, fewer solver steps may be needed than for a curvy trajectory.

Rectification

Random pairings of noise and data produce crossing paths, so the learned field is an average and its trajectories are still curved. Rectified flow retrains using pairs generated by the current model, which straightens the paths and can allow very few steps.

Relationship to diffusion

  • Diffusion can be viewed as a particular choice of path and weighting within a broader family.
  • Deterministic ODE sampling gives repeatable outputs for a fixed seed.
  • In both families, evaluation should cover sample quality, diversity and cost per sample.

More guides from this book