From a storm to generative AI
The velocity-fields page showed how a 2D wind pattern transports air through space. The same mathematical object appears in generative modeling:Weather. tells air where to move. Diffusion and flow matching. tells probability mass, or a generated sample, where to move.In weather you do not get to choose the wind: the atmosphere imposes it. The leaves, raindrops, and dust that the storm carries are passive passengers, each one sampling the wind field at its current position and drifting accordingly. In generative modeling the roles flip: you design the wind. You choose a velocity field whose particles, released from Gaussian noise, end up distributed like real data. The particles in flow matching play the role of the leaves: each particle is a sample carried by the learned field , starting from a Gaussian draw and ending at a generated data point. One subtlety worth pinning down up front: only the starting positions are Gaussian. Once the field begins to advect them, the cloud of particles is no longer Gaussian. At intermediate time the particles are samples from the deformed distribution , and by they are samples from a distribution that approximates the data. The randomness lives entirely in the initial draw; after that, the trajectory of each particle is determined by the ODE. That is the setup of flow matching: a generative modeling framework that learns a continuous-time vector field transporting samples from a simple source distribution to a target data distribution. It generalizes diffusion models: where diffusion fixes a stochastic forward process and learns to reverse it, flow matching directly parameterizes the deterministic ODE that connects noise to data, and is trained with a simple regression objective on conditional vector fields. Flow matching has emerged as the production-grade choice in several recent generative systems across images, video, audio, speech, and molecular structures, including 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 .What the field does to a distribution
The flow does more than move individual particles; it transports the entire source density forward in time. At each , the pushforward is a probability density on that describes where the swarm of particles is at time . If the velocity field is chosen well, then at the pushforward matches the data distribution: The pair is linked by the continuity equation: This is the same equation that describes mass conservation in a fluid. Read geometrically: the local rate of change of density is determined by the divergence of the mass flux . Designing a velocity field is, in effect, designing a fluid flow that morphs noise into data.Generation as trajectory integration
Once you have a learned velocity field that approximates a true transport field, sampling from the model amounts to numerical ODE integration. The simplest scheme is Euler integration with step size : This is the same loop you ran on the storm: at each step, evaluate the field at the current position and take a small step in that direction. Starting from and stepping until , you obtain a sample that is approximately distributed according to . Higher-order solvers (Heun, RK4, adaptive Dormand-Prince) integrate the same field with fewer steps and lower truncation error. The choice of solver is decoupled from the choice of velocity field, which is a practical advantage of the flow-matching formulation.Three views of the same object
A velocity field shows three complementary faces:- 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.
What gets learned
The network is not asked to denoise or to predict a discrete sequence of tokens. It is asked to regress one scalar-valued function per output dimension: where is a target velocity field induced by a chosen probability path between and . Constructing that target, picking the path and writing down the corresponding velocity, is the heart of the flow-matching training objective and is covered in the Lipman et al. references below.Pointers
- Paper: Lipman et al. (2024). Flow Matching Guide and Code. Comprehensive, self-contained review covering mathematical foundations, design choices, and extensions, with a PyTorch reference implementation; Sections 2-3 cover velocity fields and the continuity equation in detail.
- 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.

