Velocity fields in generative models
The velocity-fields section showed how a 2D wind pattern transports air through space. Generative models use the same mathematical object:Weather. tells air where to move. Diffusion and flow matching. tells probability mass, or a generated sample, where to move.In weather, the atmosphere determines the wind. Leaves, raindrops, and dust move with the wind field at their current positions. In generative modeling, you design the field. You choose a velocity field that moves particles from Gaussian noise to the data distribution. The particles in flow matching play the role of the leaves. Each particle is a sample carried by the learned field . It starts as a Gaussian draw and ends as a generated data point. Only the starting positions are Gaussian. Once the field moves them, the particle distribution is no longer Gaussian. At an intermediate time , the particles are samples from the deformed distribution . At , they are samples from a distribution that approximates the data. All randomness comes from the initial draw. The ODE then determines each particle’s trajectory. Flow matching learns a continuous-time vector field that transports samples from a simple source distribution to a target data distribution. It generalizes diffusion models. Diffusion fixes a stochastic forward process and learns to reverse it. Flow matching directly parameterizes the deterministic ODE from noise to data. Training uses a regression objective on conditional vector fields. Several generative systems use flow matching for images, video, audio, speech, and molecular structures. Examples include Meta’s Movie Gen, Stable Diffusion 3, and Flux.
Definition
A time-dependent velocity field is a function that assigns a velocity vector to every point at every time . A particle whose trajectory is driven by this field obeys the ordinary differential equation Given an initial sample from a source distribution (typically a standard Gaussian), the ODE produces a unique trajectory . The map is called the flow induced by .Distribution transport
The flow transports the entire source density forward in time. At each , the pushforward is a probability density on . It describes the particle distribution at time . For a suitable velocity field, the pushforward at matches the data distribution: The pair is linked by the continuity equation: This equation also describes mass conservation in a fluid. Geometrically, the divergence of the mass flux determines the local rate of change of density. Designing the velocity field defines a fluid flow that transforms noise into data.Generation as trajectory integration
Once the learned velocity field approximates a transport field, you can sample from the model by integrating the ODE numerically. The simplest method is Euler integration with step size : This is the same loop used for the storm example. At each step, evaluate the field at the current position and move a short distance in that direction. Start from and continue until . The result is a sample whose distribution approximates . Higher-order solvers (Heun, RK4, adaptive Dormand-Prince) can integrate the same field with fewer steps and lower truncation error. You can choose the solver independently of the velocity field.Views of a velocity field
A velocity field has three common representations:- Vector field view. At each , draw the arrow . Quiver plots are this view.
- Streamline view. Fix and trace integral curves of .
- Particle view. Release a cloud of particles at and follow them as they advect under . Trajectory plots are this view.
The learned velocity field
The network does not denoise or predict a discrete sequence of tokens. It regresses one scalar-valued function per output dimension: where is a target velocity field induced by a chosen probability path between and . The flow-matching training objective requires a probability path and its corresponding target velocity. The Lipman et al. references below describe this construction.References
- Paper: Lipman et al. (2024). Flow Matching Guide and Code. This self-contained review covers the mathematical foundations, design choices, and extensions. It includes a PyTorch reference implementation. Sections 2-3 cover velocity fields and the continuity equation.
- Foundational paper: Lipman et al. (2023). Flow Matching for Generative Modeling.
- Code:
facebookresearch/flow_matching, the companion library with examples for image and text generation.

