# Flow matching explained with a tiny model you can run

Train a tiny flow-matching model, animate its real checkpoints in Manim, and turn the result into an editable explainer with reusable prompts and source files.

Author: John Holliman

Canonical: https://voyager.so/blog/flow-matching-explained

Published: 2026-10-06T11:35:42-07:00
Updated: 2026-10-06T11:35:42-07:00

A cloud of noise becomes two curved bands. The interesting part is what the model learned: which direction to move at each position and time.

![A real tiny flow-matching model is explained through a training example, saved checkpoints and sampled paths](https://cdn.moda.app/voyager/blog/flow-matching-explained/intro-76ae0b1fef1fcf92.webp)

[Video: A real tiny flow-matching model is explained through a training example, saved checkpoints and sampled paths](https://cdn.moda.app/voyager/blog/flow-matching-explained/flow-matching-7d84dbd65a9bffd4.mp4)

One training example, four saved checkpoints and new noise following the trained model. The film is silent.

You can make this explainer with a small neural network, its saved checkpoints and Manim. The animation follows the trained model's calculations, so you can change the experiment and see what actually changes.

## What is flow matching learning?

Think of a moving point asking for directions. The model receives its current position and a time between zero and one, then predicts a velocity. Following those predictions moves a batch of new noise samples toward the shape of the training data.

During training, we draw a noise point and a data point independently. Pick a random time, find the position between them, and teach the model the displacement from noise to data. Repeat with many pairs. The model must learn a direction that works across the examples it sees at each position and time.

This is a small version of the construction in the [Flow Matching paper](https://arxiv.org/abs/2210.02747). It is a two-dimensional teaching example, not an image generator.

## Run the experiment before animating it

A [recent Manim explainer shared on X](https://x.com/Audiofool934/status/2106358936618299607) combined actual flow-matching training with animation. That is a useful distinction: a beautiful arrow diagram can explain the training rule, but only running a model shows what it learned.

Use this prompt with a coding agent:

```text
Build a reproducible 2D flow-matching experiment in PyTorch.
Draw Gaussian noise and two-moons data independently.
Train a time-conditioned MLP to predict x1 - x0 from
x_t = (1-t)*x0 + t*x1 and time t, using squared error.

Save checkpoints and integrate each learned velocity field
with RK4 from the same new noise samples. Export the sample
positions and final-model paths to JSON for an animation.
Keep the sampling function independent of target data.
```

Our network has 19,202 parameters. Its four saved checkpoints make a simple teaching sequence: the untrained model, two early checkpoints, then the learned crescent shape. Use the same starting noise at every checkpoint so a changing random draw does not obscure the change in the model.

Three checks keep the explanation honest:

* **Separate training from sampling.** A line between a known noise point and a known data point illustrates a training example. A generated sample follows the model's changing predictions.
* **Compare shapes, not partners.** New samples are not assigned a particular destination point. Check whether the generated distribution resembles fresh target data.
* **Check the solver.** Increase the integration steps and see whether the paths materially change before treating them as the model's behavior.

## Turn the saved numbers into a short film

Give the animation agent the exported data, not permission to invent a convincing transformation:

```text
Make a short Manim explainer with three beats:
one training example, four real saved checkpoints,
and new samples following the final learned field.

Use the exported numerical paths for sampling. Do not tween
noise directly into target points. Keep headings large,
hold each checkpoint long enough to compare, and distinguish
a training-example arrow from the model's sampled motion.
```

![New noise samples move along the trained velocity field into two curved bands](https://cdn.moda.app/voyager/blog/flow-matching-explained/sampling-poster-c29134e44d17702e.webp)

[Animation: New noise samples move along the trained velocity field into two curved bands](https://cdn.moda.app/voyager/blog/flow-matching-explained/sampling-loop-77734117f2a88340.mp4)

[Download GIF](https://cdn.moda.app/voyager/blog/flow-matching-explained/sampling-optimized-b03dbab297e8e078.gif)

These paths come from numerically following the learned field. The model receives position and time at each step.

This is useful for a lesson, a research update or a technical product explanation: viewers can connect the rule to its consequence, and you can trace every moving point back to the experiment.

## Revise the explanation without rebuilding the whole film

Our first cut gave the final shape too little time to register. We asked Voyager to hold it for two more seconds and move the initial noise farther from the subtitle.

The scene source, training outputs and edit live in the same project. Voyager rerendered the Manim scene as a transparent movie, relinked that source in the native Video timeline and extended its background to match. The opening image stayed in place. The saved model and numerical paths did not need to run again.

Use this adapted revision prompt with your own scene:

```text
Hold the final sampled shape two seconds longer and keep
the initial noise clear of the subtitle. Preserve the
training outputs and opening clip. Rerender only the Manim
scene as a transparent movie, replace its source in the
existing Video edit, and match the background duration.
```

Revise the explanation in Python while keeping it inside an editable film. You can do the same steps in separate tools; Voyager keeps the managed render and timeline revision in the project conversation.

![Voyager desktop plays the revised flow-matching film before the sampling section opens full-screen](https://cdn.moda.app/voyager/blog/flow-matching-explained/demo-poster-db49a8eecb53bb8f.webp)

[Video: Voyager desktop plays the revised flow-matching film before the sampling section opens full-screen](https://cdn.moda.app/voyager/blog/flow-matching-explained/voyager-manim-demo-v2-4942e0d06ca9880e.mp4)

A brief hold on the saved revision summary, then review in the actual Voyager app. The sampling section opens full-screen.

[Download the experiment and film kit](https://cdn.moda.app/voyager/blog/flow-matching-explained/flow-matching-kit-d18dd96449373d45.zip). It includes the training script, four checkpoints, numerical paths, Manim source, transparent master and a recipe that rebuilds the editable cut. Unzip it and open `index.html` to watch offline; the README covers rerendering.

For a simpler data-to-motion project, start with our [animated chart from a CSV](/blog/animated-chart-from-csv).

The useful habit is simple: compute first, animate second. When a point moves, you should be able to explain whether it is illustrating a rule or following a model's prediction.


## Make your next project in Voyager

Create an account, download Voyager, and start making.

[Sign up](/sign-up)