Introduction to Flow Matching and Diffusion Models
MIT Computer Science Class 6.S184: Generative AI with Stochastic Differential Equations
Diffusion and flow-based models have become the state of the art for generative AI across a wide range of data modalities, including images, videos, shapes, molecules, music, and more! This course aims to build up the mathematical framework underlying these models from first principles. At the end of the class, students will have built a toy image diffusion model from scratch, and along the way, will have gained hands-on experience with the mathematical toolbox of stochastic differential equations that is useful in many other fields. This course is ideal for students who want to develop a principled understanding of the theory and practice of generative AI.
Course Notes
The course notes serve as the backbone of the course and provide a self-contained explanation of all material in the class. In contrast, lectures slides will generally not be self-contained and are intended to provide accompanying visualizations during the lecture. You may view the notes by clicking on the colored link below.
Lectures
| Lecture | Topic | Slides | Recording |
|---|---|---|---|
| 1 |
Flow and Diffusion Models
|
[slides 1] |
|
| 2 |
Constructing a Training Target
|
[slides 2] |
|
| 3 |
Training Flow and Diffusion Models
|
[slides 3] |
|
| 4 |
Building an Image Generator
|
[slides 4] |
|
| 5 |
Generative Robotics
|
N/A |
|
| 6 |
Generative Protein Design
|
[slides 6] |
|
Labs
There are 3 labs given as exercises accompanying the class to give you hands-on practical experience. The labs will guide you through building a flow matching and diffusion model from scratch step-by-step. To do the exercises, perform the following steps:- Click on the "Open in Colab" link to open the lab in Google Drive.
- Click on the "Open in Google Colaboratory" link at the center top of the page. A Jupyter notebook should appear.
- Click on "File" → "Save a copy in Drive" to save a copy of the lab to your own Google Drive.
- Follow the instructions in the lab to complete the exercises.
Lab 1: Working with SDEs
Lab 2: Flow Matching and Score Matching
Lab 3: Conditional Image Generation
Stuck? Solutions can be found here.
Instructors
This class was co-taught by Peter and Ezra. We are fortunate to have Tommi Jaakkola as our sponsor and advisor.
Prerequisites: Linear algebra, real analysis, and basic probability theory. Students should be familiar with Python and have some experience with PyTorch.
Questions? Email either Peter or Ezra!
Remark about LLMs: This course does not cover large language models (LLMs). LLMs involve discrete data such as text, while this course focuses on data lying in continuous spaces such as images, videos, and protein structures.
Acknowledgements
We would like to thank the following individuals and organizations:- Professor Tommi Jaakkola
- Lisa Bella, Ellen Reid, and the team at MIT EECS
- Christian Fiedler, Tim Griesbach, Benedikt Geiger, and Albrecht Holderrieth
- Elaine Mello (MIT Open Learning)
- Ashay Athalye (Students for Open and Universal Learning)
- Cameron Diao, Tally Portnoi, Andi Qu, Roger Trullo, Ádám Burián, Zewen Yang, and many others
- The Missing Semester
- Participants in MIT 6.S184/6.S975 (IAP 2025)
To cite this course, please use:
@misc{flowsanddiffusions2025,
author = {Peter Holderrieth and Ezra Erives},
title = {Introduction to Flow Matching and Diffusion Models},
year = {2025},
url = {https://diffusion.csail.mit.edu/}
}
Licensed under CC BY-NC-SA.