Skip to content

About

Flow Matching Tutorial

Resources

Stars

15 stars

Watchers

0 watching

Forks

Repository files navigation

Flow Matching Tutorial

A hands-on tutorial on Flow Matching for generative modeling. Learn to build, train, and understand flow-based generative models through progressive Jupyter notebooks.

What is Flow Matching?

Flow matching learns to transport samples from a simple source distribution (e.g., Gaussian noise) to a complex target distribution by following learned velocity fields. It provides a simple and efficient framework for generative modeling with strong connections to optimal transport theory.


Notebooks

Interactive Notebooks (with exercises)

If you prefer to code along and implement some small parts yourself, start here:

Notebook Description Colab
Flow Matching Basics Introduction to flow matching with straight-line interpolation Open In Colab
Optimal Transport Pairing Improve training efficiency with optimal transport couplings Open In Colab
Latent Distribution Choice Explore componentwise noise adaptation to target geometry Open In Colab
Conditional Sampling Learn conditional generation with conditional optimal transport Open In Colab

Notebook 05 (continuous flows for discrete data, see below) is inference-only and has no exercises variant.

Complete Notebooks (ready to run)

If you prefer to explore the concepts directly, use these:

Notebook Description Colab
Flow Matching Basics Introduction to flow matching with straight-line interpolation Open In Colab
Optimal Transport Pairing Improve training efficiency with optimal transport couplings Open In Colab
Latent Distribution Choice Explore componentwise noise adaptation to target geometry Open In Colab
Conditional Sampling Learn conditional generation with conditional optimal transport Open In Colab
Flows for Discrete Data (Sudoku) Inference with pretrained models vMF (spherical) and masked diffusion, solving Sudoku-Extreme puzzles Open In Colab

Getting Started

Option 1: Google Colab (Recommended)

Click the badge above or open individual notebooks directly in Colab. Each notebook includes setup cells that install dependencies automatically.

Option 2: Local Installation

git clone https://github.com/JChemseddine/fm_tutorial.git
cd fm_tutorial
pip install -r requirements.txt
jupyter notebook

Lectures

The tutorial is accompanies a series of lectures by Prof. Dr. Gabriele Steidl (https://page.math.tu-berlin.de/~steidl/):

Lecture Topic PDF
Lecture 1 Optimal Transport 1_HS_AMSTERDAM_OT.pdf
Lecture 2 Flow Matching 2_HS_AMSTERDAM_FM.pdf
Lecture 3 1D Processes and Noise Adaptation 3_HS_AMSTERDAM_1D.pdf
Lecture 4 Bayesian Inference and Conditional Flow Matching 4_HS_AMSTERDAM_Bayesian.pdf

These lectures provide the mathematical background and theory for the hands-on notebooks.


References

Primary Tutorial Sources

  1. Flow Matching: Markov Kernels, Stochastic Processes and Transport Plans — Christian Wald, Gabriele Steidl, 2025 | arXiv:2501.16839
    • Used throughout the flow matching basics and optimal transport notebooks.
  2. Adapting Noise to Data: Generative Flows from 1D Processes — Jannis Chemseddine, Gregor Kornhardt, Richard Duong, Gabriele Steidl, 2025 | arXiv:2510.12636
    • Used in the latent choice notebook.
  3. Conditional Wasserstein Distances with Applications in Bayesian OT Flow Matching — Jannis Chemseddine, Paul Hagemann, Gabriele Steidl, Christian Wald, 2024 |arXiv:2403.18705
    • Used in the conditional sampling notebook.
  4. Spherical Flows for Sampling Categorical Data — 2026 | arXiv:2605.05629
    • Used in notebook 05. Pretrained checkpoints are hosted on Hugging Face Hub at Jugc/fm-tutorial; 100 held-out Sudoku-Extreme puzzles ship with the repo at data/sudoku_extreme_100.npz. The inference code in flows_categorical/ is copied (with attribution) from the paper's source repo.

Related Work

  • Flow Matching for Generative Modeling — Lipman et al., ICLR 2023 | arXiv:2210.02747
  • Building Normalizing Flows with Stochastic Interpolants — Albergo et al., ICLR 2023 | arXiv:2209.15571
  • Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow — Liu et al., ICLR 2023 | arXiv:2209.03003
  • Continuous Diffusion for Categorical Data (CDCD) — Dieleman et al., 2022 | arXiv:2211.15089
    • Continuous diffusion on unit-norm token embeddings; the setup notebook 05 builds on. -Improving and generalizing flow-based generative models with minibatch optimal transport - Tong et al., 2023 | arXiv:2302.00482
    • Basis for the minibatch OT notebook.
  • Heavy-Tailed Diffusion Models — Pandey et al., 2024 | arXiv:2410.14171
    • Inspired notebook latent_choice.

Libraries


Contact

Questions or suggestions? Write me an email: [email protected]

About

Flow Matching Tutorial

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages