Modern Generative AI

A generative model turns pure noise into data by walking along a learned velocity field. One big step gives a blurry average. Thirty-two small steps give the data.

Learn how a computer draws what you describe: visual tokens, latent variables, VAEs, diffusion, flow matching, text and sound and video, and the knob that steers it all.

Pick a number of steps, then press Generate. Each dot starts as random noise and walks to one of the three blue targets. Then we build, piece by piece, everything underneath: where the field comes from, why noise helps, and how a prompt steers the walk.

You need the idea of a probability (a number from 0 to 1 for how likely something is) and a feel for averages. We build the rest from zero.

Based on Lecture 6.2 of MIT Multimodal AI (Spring 2026), taught by Paul Liang of the MIT Multisensory Intelligence group, and its ten readings. Course site and lecture slides. Every idea is re-taught here in our own words and devices.

Walk noise to data

A toy in two dimensions, not an image model. The three targets are small blobs (spread 0.18). The velocity field is the exact one for this toy, worked out in closed form, so no network is trained here. Each step is an Euler step: move by the field’s arrow times the step size. The score counts dots that end within 0.5 of a target centre.

Chapter 0

How a Computer Draws What You Say

Follow one prompt from words to pixels, and see the four ideas this lesson builds to make that trip possible

You type six words: “an armchair in the shape of an avocado.” Two seconds later a picture appears. It has a green shell, a stone-coloured seat and soft shadows. Nobody ever photographed this chair, because it does not exist.

So where did the picture come from? The computer did not search for it. It did not paste together old photos either. It drew new pixels, one careful step at a time, starting from nothing but random static.

This lesson explains that trip. It follows Lecture 6.2 of MIT’s Multimodal AI course, taught by Paul Liang. The course so far taught a model to read pictures, sound and text together. This lecture flips the arrow. Now the model must write them.

Generating means learning what data looks like

Take a thousand photos of dogs. Each photo is a list of numbers, one per pixel. A generative model is a machine that studies such a pile and learns which lists of numbers look like real dogs. Once it knows, it can hand you a new list that looks real too.

The lecture states this as a goal: learn a probability p(x) for the data x. The word probability here means a score for how likely a picture is to be real. A real-looking photo should score high. A heap of static should score low. Three jobs follow from one score. You can evaluate (is this picture realistic?), sample (give me a new realistic picture) and learn features (what do all these dogs have in common: ears, tails, fur?).

The trip, in numbers

Real systems split the trip into stages. A text encoder turns your words into numbers the model can read. A noise generator makes a block of random numbers. A denoising network then cleans that block again and again. A decoder finally turns the clean block into pixels. Step through one real example below. The shapes are those of Stable Diffusion version 1, the model behind slides 37 to 40.

Follow the prompt

Each box is one stage. The yellow number under it is how many numbers the stage holds. Press a stage to light it and read what happens there.

Shapes are Stable Diffusion v1’s: a prompt cut into 77 tokens, each encoded as 768 numbers; a 64 × 64 × 4 latent; a 512 × 512 × 3 picture. The 50 denoising steps are a common default, not a fixed rule.

Notice the odd part. The model never draws pixels directly. It works on a block of 16,384 numbers that is 48 times smaller than the picture, then a decoder blows it up. Chapter 7 explains why that saves so much work.

Four ideas, in the lecture’s order

The lecture splits into four parts, and so does this lesson. One: text-to-image generation, the early recipes that gave us the avocado chair (Chapter 1). Two: a crash course on modern generative models, from latent variables through VAEs to diffusion and flow matching (Chapters 2 to 6). Three: how the same ideas draw other things, such as text, sound, video and sensor traces (Chapters 7 and 8). Four: how to control what comes out (Chapters 9 and 10).

Logistics, in one paragraph. The slides open with course news: a midterm review on Tuesday 3/17, the midterm on Thursday 3/19, announcements about credits and conflicts, and project mentors released. None of that changes the ideas, so we leave it here.

The lecture also lists ten readings. Where we already have a lesson on one, we link it. Where the reading has no lesson yet, a new lesson in this series covers it. Each chapter says which reading it touches.

The road

  1. Pictures as tokens: how the first text-to-image models turned a picture into a short list of integers.
  2. Latent variables: the hidden knobs behind data, and a mixture of bumps that fits them.
  3. The VAE: an encoder, a decoder, and a loss with two forces.
  4. Diffusion: add noise on purpose, then learn to take it away.
  5. Three ways to predict: clean image, noise or velocity, and the score behind them.
  6. Flow matching: learn a velocity field and follow it with an ODE.
  7. Latent diffusion and text: work in a small space, steer with a prompt.
  8. Beyond images: diffusion for text, sound, video, sensors and everything at once.
  9. Guidance: the dial between obeying the prompt and staying varied.
  10. Five ways to steer: the lecture’s map of conditioning, and what is still open.
  11. The whole lecture on one page: numbers, code and what comes next.
Which sentence best describes what a generative model learns?

Chapter 1

Turn a Picture into Words a Model Can Write

Cut a picture into a short list of integers, and a language model can draw by writing one integer after another

Imagine you run a language model. It is very good at one act: it reads a list of integers and writes the next integer. Words are integers, so it writes sentences. Now someone asks it for an avocado chair. The model has no way to write a picture, because a picture is not a short list of integers.

Or is it? The first big text-to-image systems answered with one trick. Turn the picture into a list of integers first. Then the language model can write the picture the way it writes a sentence.

The codebook: a dictionary of small picture pieces

Here is the trick in plain words. Cut the picture into a grid of small square patches. Keep a fixed codebook: a numbered dictionary of typical patches, such as “plain green” or “bright edge sloping left”. For each patch in the picture, find the dictionary entry that looks most like it and write down only that entry’s number. The number is a visual token.

The lecture shows this on slide 11 with a cat and a shop front. An image encoder reads the picture and outputs a short list such as [98] [3] [990]. An image decoder reads the list and redraws the picture. The lecture calls it “a list of digits, [0 to 8192], each digit a visual token”. The model that learns this encoder, this decoder and this dictionary is a discrete variational autoencoder (a discrete VAE, which Chapter 3 explains in full).

The numbers behind DALL-E

The slides cite DALL-E (Ramesh et al., ICML 2021). In that system a 256 × 256 colour picture holds 256 × 256 × 3 = 196,608 numbers. The encoder shrinks it to a 32 × 32 grid of tokens, so 32 × 32 = 1,024 integers. Each integer is one of 8,192 dictionary entries, which takes 13 bits to write (213 = 8,192). So the whole picture becomes 1,024 × 13 = 13,312 bits, about 1.7 kilobytes.

That is the whole price of the trick. You lose detail, because each 8 × 8 patch is replaced by its nearest dictionary entry. You gain a picture that a language model can write. Try the trade yourself on a toy picture.

Shrink a picture to tokens

Left: a 16 × 16 picture. Right: the picture rebuilt from tokens, with each token’s number written in its cell when the cells are large enough. Drag the dictionary size and watch the rebuild sharpen.

4

Toy: 256 cells of an invented sunset, one colour per cell, and a codebook of average colours found by a small k-means run in your browser. Real DALL-E tokens stand for 8 × 8 patches and are learned by a network, not by k-means. The numbers 196,608, 1,024 and 8,192 are from the DALL-E paper as the lecture cites it.

With 4 entries the sky turns into flat bands and the sun merges with the hills. This is the failure mode of discrete tokens. The symptom is banding: smooth gradients become steps. The measurement is the average colour error, which falls as the dictionary grows. The fix is a bigger dictionary or smaller patches, and both cost more tokens for the language model to write.

The same trick for sound

Slide 12 pauses to remind you that you have seen this move before. HuBERT (Hsu et al., 2021) listens to speech and groups short slices of audio with k-means clustering, a method that sorts points into a chosen number of groups. Each group gets a number. The model then learns to guess the hidden numbers from the audio around them. These cluster numbers are hidden units. They are exactly a codebook for sound. Discrete units are a general way to make any signal speakable by a language model.

Write the picture token by token

Now the writing step, on slide 13. Put the prompt first: “An armchair in the shape of an avocado.” The model predicts the first image token, say [56]. Append it. Predict the next, [73]. Append. Then [67], and so on, 1,024 times. This is autoregressive generation: each new token is predicted from everything written so far. It is the same loop a chat model uses for words. Finally the decoder from the last section turns the 1,024 tokens into pixels.

This recipe is simple and it works, but it has a cost. To draw 1,024 tokens, the model must run 1,024 times, one after another. Chapter 8 returns to this cost.

Two more recipes on the same slides

DALL-E 2 (slide 10; Ramesh et al., 2022) keeps the idea of a middle representation but changes the pieces. Step one: a CLIP encoder maps a picture into one list of numbers, an embedding, that sits close to the embedding of its caption. Step two: a model predicts the CLIP image embedding from the text. Step three: a diffusion model (Chapter 4) draws the picture from that embedding. So the lecture’s phrase, “directly training diffusion models with conditional information”, means that the diffusion model sees a CLIP embedding while it draws.

Slide 14 then names the third recipe: decode the picture with a diffusion model that works on a smaller space, from Rombach et al. (CVPR 2022). That is latent diffusion, Chapter 7.

The earlier slides, 7 and 8, show a fourth route for chat models. Koh et al. (NeurIPS 2023) glue a frozen language model to a frozen image generator with a small adapter layer: a thin trained piece between two big fixed ones. The language model writes special image-marker tokens. The adapter turns their hidden state into the input the generator expects. The model can also choose to retrieve an existing image instead of drawing a new one. That is the “text-to-image retrieval or generation” choice on slide 6.

Why do early text-to-image models first turn a picture into a short list of discrete tokens?

Chapter 2

Hidden Knobs Behind Every Picture

Explain data with a few hidden choices, then fit those choices with a mixture of bumps

Look at a page of face photos. Each face is different. One has dark eyes and short hair, turned left. Another has green eyes and long hair, facing the camera. Thousands of pixels change from face to face, yet the real differences are few: gender, eye colour, hair colour, pose.

Nobody wrote those factors beside the photos. Slide 16 says it plainly: unless images are annotated, the factors of variation are not explicitly available. They are latent, which means hidden. The idea of a latent variable model is to invent a small hidden list z and say that the pixels x are produced from it.

A generator in two moves

A latent variable model draws data in two moves. Move one: choose the hidden knobs z. Move two: produce the picture x from z. The first move needs a probability for z, called the prior. The second needs a probability for x given z, written p(x | z) and read “the chance of x, given z”. If you know both, you can sample: draw a z, then draw an x. The lecture also points out the bonus. When z is meaningful, you can control the output by changing z.

The simplest case: a mixture of Gaussians

Start with the plainest hidden knob there is: a choice of one group out of K. Slide 17 calls it a mixture of Gaussians. A Gaussian is the familiar bell-shaped bump with a centre (the mean μ) and a width (the spread, written Σ, or σ in one dimension). The generative process has two steps. First, pick a component k by sampling z. Then draw a point from that component’s bump.

p(x)
How likely the point x is under the whole model. Slide 19 calls this “combining simple models into more expressive ones”.
∑k=1K
Add up over the K groups. We do not know which group made x, so we count every group.
p(z = k)
The chance of picking group k. It is the weight of that bump. The weights add up to 1.
N(x; μk, Σk)
The height of bump k at x: a bell with centre μk and width Σk.

A worked example, every step. Take two bumps with equal weight 0.5. Bump 1 is centred at 0, bump 2 at 4, both with spread 1. How likely is x = 3? Bump 1 at 3 has height e−4.5 / √(2π) = 0.0111 / 2.5066 = 0.00443. Bump 2 at 3 is one unit from its centre, so its height is e−0.5 / 2.5066 = 0.6065 / 2.5066 = 0.24197. Weight and add: 0.5 × 0.00443 + 0.5 × 0.24197 = 0.1232. Nearly all of that comes from bump 2. So the chance that bump 2 made this point is 0.24197 / (0.24197 + 0.00443) = 0.982. This ratio is the responsibility of bump 2 for the point.

Fitting the bumps: expectation maximization

Real data comes without labels. We see the points but not which bump made each one. Slide 19 gives the standard remedy, expectation maximization (EM). It is a loop of two steps, and each step helps the other.

  1. Expectation (E step). With the bumps as they are now, compute each point’s responsibility for each bump, as above. This is a soft guess of “who made whom”.
  2. Maximization (M step). Treat those guesses as truth. Move each bump’s centre to the responsibility-weighted average of the points, set its width to match, and set its weight to the share of points it owns.
  3. Repeat. Better bumps give better guesses, and better guesses give better bumps.

Fit the bumps

The dots are 60 data points. The warm curve is the mixture; the faint curves are its bumps. Choose how many bumps, then press E step and M step in turn, or Run 10. Dots take the colour of the bump that owns them most.

Toy data: 60 invented points from three groups centred near −3, 0.5 and 4, drawn from a fixed seed so the page is the same on every visit. The fit starts from a deliberately poor guess (centres bunched together, width 1). Log-likelihood is the average of log p(x) over the points; higher means a better fit. EM is computed exactly in your browser.

Watch what happens with three bumps. They start bunched near the middle and drift apart, each one claiming a cluster, and the average log-likelihood climbs and flattens. With one bump the curve stays a single wide hill that cannot show the three groups. With two, one bump has to cover two clusters.

That gives the failure mode. The symptom: a bump that sits on top of two clusters. The measurement: the log-likelihood stops improving at a value below what more bumps reach. The fix: use more components, restart from different starting points, or, as the next chapter does, give up a finite list of groups and use continuous knobs.

What a mixture cannot do

A mixture has only K hidden choices. Faces need more: eye colour and hair colour and pose together would need a separate bump for every combination. The number of bumps explodes. We want the hidden knobs to be a short list of numbers instead of one pick from a list, so that a few knobs make an enormous number of combinations. That change turns a mixture into a variational autoencoder, and it is the next chapter.

In one round of expectation maximization, what does the E step compute?

Chapter 3

The Variational Autoencoder

Squeeze a picture into a few numbers, rebuild it, and pay a price that keeps those numbers tidy

Take a face photo of 28 × 28 pixels. That is 784 numbers. Now try to describe it with just two numbers and rebuild the photo from them alone. Two numbers cannot hold every pixel, so the machine must learn which two things matter most. That is the plan of an autoencoder: a squeeze, then a rebuild.

The variational autoencoder, or VAE, adds one twist. The two numbers are not a single point. They are the centre of a small cloud. We will see why that twist is the whole point.

Mixture to VAE: knobs that are numbers

Slide 20 starts from the mixture of Chapter 2 and changes one thing. Instead of picking a group from a list, put a prior on z: draw z from the standard bell curve N(0, I), a bump centred at zero with width one in every direction. Then let a neural network turn z into the picture. The network outputs a mean μθ(z) and a spread Σθ(z) for the pixels. The lecture notes the key gain: even though each p(x | z) is a simple bump, the mixture over all z is rich, because z can take infinitely many values.

Two networks that answer opposite questions

Slide 21 draws the pair. The decoder, also called the generative network, answers: given z, what does x look like? Its probability is written p(x | z; θ). The encoder, or inference network, answers the reverse: given x, which z could have made it? Its probability is q(z | x; φ). The semicolon marks the network weights (θ for the decoder, φ for the encoder).

Follow one photo through the four steps the slide lists, with shapes. One: take a datapoint x, 784 numbers. Two: the encoder maps x to a mean μ and a spread σ, here two numbers each. Three: draw noise ε from N(0, 1), then compute z = μ + σ · ε. This is the reparameterization trick. It writes the random draw as fixed numbers plus noise from outside the network, so training can pass gradients (the signals that say how to change each weight) back through μ and σ. Four: the decoder reads z and rebuilds x̂, 784 numbers.

A loss with two forces

L
The score a VAE tries to raise. It is a lower bound on log p(x), called the evidence lower bound (ELBO).
Eq(z|x)[ log p(x | z) ]
Reconstruction. Draw z from the encoder, then ask how well the decoder rebuilds x. The slide labels it “x to z to x”.
DKL( q ‖ p )
How far the encoder’s cloud is from the prior N(0, I). The slide labels it “prior over z, standard Gaussian”. It is zero only when the two match.

The two terms pull against each other. Reconstruction wants a tiny, precise cloud, so the decoder sees exactly the right z. The KL term wants every cloud to look like the prior, wide and centred at zero. For one latent number, the KL has a closed form: ½(μ² + σ² − ln σ² − 1). A worked case: μ = 1 and σ = 0.5 give ½(1 + 0.25 + 1.386 − 1) = 0.818. Now balance the pull yourself.

Balance the two forces

Pink: the prior N(0, 1). Warm: your encoder’s cloud for one image. Blue dashed line: the value of z that rebuilds this image perfectly, 1.5. Drag the centre and the width, then the weight on the KL term.

0.00
1.00
1.00

Toy with one latent number and a decoder that returns z itself, so the rebuild error is (μ − 1.5)² + σ². The loss shown is that error plus β times the exact KL above (the lecture’s loss has β = 1; a weight other than 1 is the β-VAE of slide 35). The best cloud is worked out in closed form: μ = 2 × 1.5 / (2 + β) and σ² = β / (β + 2).

Set β to 0 and snap to the best cloud. The cloud becomes a razor line sitting on 1.5. The rebuild is perfect, but every image would sit at its own private spot far from the prior, so nothing keeps the space smooth. Now set β to 8. The cloud swells toward the prior and the centre slides toward zero. The prior is happy, but the decoder now sees almost the same z for every image, so it rebuilds an average.

Why the prior matters, and why VAE samples look soft

Slide 22 puts two plots of the latent space side by side. With the KL term, the coloured clusters of different digits sit packed around the centre with no gaps. Without it, the clusters spread into islands with empty ocean between them. At sampling time you draw z from the prior. In the packed space almost every draw lands on a cluster and decodes to a real-looking picture. In the island space many draws land in the ocean and decode to junk. That is the benefit slide 23 lists: a smoother latent space permits sampling, and it can pull the different dimensions of z apart so each one controls one factor.

The failure mode is blur. Symptom: samples look soft, like a photo shot through fog. Measurement: the reconstruction term averages over everything the cloud could mean, and the average of several sharp pictures is a blur (the table on slide 35 says “blurry samples, limited expressiveness”). Fix: lower β for sharper but untidier results, or change the model family. Diffusion, the next chapter, is that change.

Slide 23 sums up the VAE in five ideas: an encoder-decoder structure, a simple latent z, a complex decoder from a neural network, a reconstruction objective, and a prior over z. The speed is a strength. Sampling is one pass: draw z, run the decoder, done. Keep that in mind, because every method after this one pays in speed to buy sharpness.

In a VAE, what does raising the weight on the KL term do?

Chapter 4

Diffusion: Add Noise on Purpose, Then Learn to Undo It

Ruin a picture in a thousand tiny steps, then train a network to repair one step at a time

Picture a photo on a screen. Each second, a pinch of static lands on it. After a few seconds you still see a face. After a minute you see a smudge. After a thousand pinches you see only snow. Now run the film backwards. If a machine could remove just one pinch of static from any snowy frame, then a thousand of those machines in a row could turn snow into a face.

This is the idea behind diffusion models. The slide calls it “generative modeling via denoising”. Ruining pictures is easy and needs no learning. Repairing one tiny step is a much smaller job than drawing a whole picture from nothing. So we learn only the repair.

The forward path: a fixed ladder of noise

Call the clean picture x0. Make x1 by shrinking x0 a little and adding a little Gaussian noise. Make x2 from x1 the same way, and so on up to xT. This is the diffusion process, drawn along the bottom of slide 24: q(xt | xt−1) = N(√αt · xt−1, (1 − αt) I). Read it as: the new picture is the old one scaled by √αt (a number just under 1), plus noise of variance 1 − αt (a small number). The numbers αt are the noise parameters.

Slide 28 says how to choose them: α1 > α2 > … > αT. In words, add smaller noise at the beginning and gradually increase it as the samples get noisier. The original DDPM paper (Ho et al., 2020) used T = 1,000 and a noise variance that grows from 0.0001 to 0.02 in a straight line.

Because each step is a Gaussian, we can jump straight to any step. Let ᾱt be the product of α1 through αt. Then xt = √ᾱt · x0 + √(1 − ᾱt) · ε, with ε one draw of standard noise. The first term is how much of the picture survives. The second is how much noise has arrived. Slide the step below and watch the trade.

Climb the noise ladder

The picture is xt. The curves show the weight on the picture (blue) and on the noise (purple) at every step, with a marker at your step. Drag the step from 0 to 1,000.

300

The schedule is DDPM’s: 1,000 steps, noise variance rising linearly from 0.0001 to 0.02, and the product ᾱt computed exactly in your browser. The 20 × 20 picture and its noise are invented and fixed by a seed, so the same step always looks the same.

At step 300 the picture weight is still about 0.6, and you can see a shape. At step 500 it drops to about 0.28 and the shape is a ghost. At step 1,000 it is about 0.006 and the picture is gone. That last number matters: the end of the ladder must be pure noise, because that is where sampling will start.

The reverse path: the part we learn

Now the repair. Slide 24 draws the reverse process along the top: pθ(xt−1 | xt). A neural network reads the noisy picture xt and the step number t, and outputs the cleaner picture one step back. Sampling then needs no data at all. Draw xT from pure noise, apply the network to get xT−1, and repeat until x0. For T = 1,000 that is a thousand network runs, one after another.

Why this counts as a VAE

Slide 25 lines diffusion up against Chapter 3. It is like a VAE, with three differences. One: the latent has exactly the same size as the data, so there is no squeeze. Two: the encoder q is not learned. It is the fixed noising rule above. Three: the noise settings change with t so that the last latent, xT, is a standard Gaussian. Slide 26 therefore calls it a “multi-level VAE”: a stack of a thousand small VAE steps. Its training score is again an evidence lower bound, with a reconstruction term, a prior-matching term, and, summed over all steps, a denoising matching term: how close the network’s repair is to the true repair, given the clean picture. Slide 27 puts the intuition in one line: a network predicts a cleaner xt−1 from a noisy xt, consistent with the noise-adding process.

The training loop, in code

In practice the lecture’s denoising term simplifies to something small. Pick a random step, build the noisy picture in one jump, and ask the network to name the noise that was added. This is the one-line trick that made diffusion practical.

python# one training step; x0: (B, 3, H, W) clean pictures, T = 1000
t   = torch.randint(0, T, (B,))                         # one random step per picture
eps = torch.randn_like(x0)                              # the noise we add, (B, 3, H, W)
a   = abar[t].view(B, 1, 1, 1)                          # product of alphas, (B, 1, 1, 1)
xt  = a.sqrt() * x0 + (1 - a).sqrt() * eps             # jump straight to step t
loss = ((model(xt, t) - eps) ** 2).mean()               # predict the noise
loss.backward()

The failure mode here is a ladder that stops short. Symptom: samples come out with washed-out brightness or a faint ghost of structure. Measurement: ᾱT, which should be near zero, as at the end of the device above. If it is not, the last latent still holds some picture, but sampling starts from pure noise, so training and sampling disagree. Fix: choose the noise schedule so that ᾱT is close to zero.

Diffusion buys sharpness and pays in speed. A VAE needs one pass to sample. Diffusion needs T. Keep that price in view. Chapter 6 is about getting most of the quality back with far fewer passes.

Slide 25 lists three differences between a diffusion model and a VAE. Which one is NOT among them?

Chapter 5

Three Ways to Say the Same Repair

Name the clean picture, the noise or the velocity, and see how each answer rewrites the others

A friend hands you a smudged photo and asks you to fix it. You could answer in three ways. You could say, “here is what it looked like clean.” You could say, “here is the static someone added.” Or you could say, “here is which way, and how fast, each pixel must move to get back.” Any one answer lets your friend work out the other two.

Slide 29 lists exactly these three equivalent formulations of the network’s job. Each turns the same noisy input xt into a different output. The lecture credits the picture to Li et al. (2025), “Back to Basics: Let Denoising Generative Models Denoise”.

The three targets

  1. Original image prediction. The network outputs x̂θ(xt, t) ≈ x0. The output is a picture, the same shape as the input.
  2. Noise prediction. The network outputs ε̂θ(xt, t) ≈ ε, the static that was added. This is the choice in Chapter 4’s code.
  3. Velocity estimation. The network outputs v̂θ(xt, t) ≈ v, where the slide writes v = x − ε: clean picture minus noise. It is the direction from the noise toward the data.

Why is v a velocity? Let time run from t = 0 (pure noise) to t = 1 (clean). Draw a straight line between a noise draw ε and a clean picture x: xt = t · x + (1 − t) · ε. How fast does xt move as t grows? Differentiate: the speed is x − ε. It does not depend on t, so it is a constant velocity along a straight road. Chapter 6 builds a whole method on this line.

Converting between them

Given xt and one target, solve for the others. Rearranging the line above gives ε = (xt − t · x) / (1 − t) and v = (x − xt) / (1 − t). A worked example, every step. Let the clean value be x = 1 and the noise ε = −0.5, at t = 0.6. Then xt = 0.6 × 1 + 0.4 × (−0.5) = 0.4. The velocity is v = 1 − (−0.5) = 1.5. Check the converters: ε = (0.4 − 0.6) / 0.4 = −0.5, and v = (1 − 0.4) / 0.4 = 1.5. Both match.

Notice the division by 1 − t, or by t when going the other way. At the ends of the path one of these is tiny, so a small slip can turn into a big one. That is the failure mode, and the device below measures it.

Same slip, three read-outs

Choose which target the network gets slightly wrong. The bars show the size of the slip it causes in each of the three read-outs. Drag the time from noisy (0) to clean (1).

0.20

Exact algebra on the straight path xt = t·x + (1 − t)·ε, for a slip of 0.10 in the chosen target. It shows how a fixed slip is rewritten by the converters above. It does not show a trained network’s real error, which depends on its loss and its data.

Read the bars with the slip in the noise at t = 0.2. A slip of 0.10 in ε turns into a slip of 0.40 in the clean picture, because the converter divides by t and multiplies by 1 − t, and 0.8 / 0.2 = 4. Move to t = 0.9 and the same slip in ε shrinks to 0.01 in the picture. Now choose the slip in the velocity instead. At every t the two other bars stay at or below 0.10. This is why many modern systems train on velocity: its slips never grow when translated. The names differ, the information is the same, and the choice decides how errors spread.

From steps to a smooth curve: differential equations

Slide 30 makes a leap. Chapter 4 used a thousand separate steps. Imagine more and more steps, each smaller, until the ladder is a smooth ramp. The discrete process becomes a stochastic differential equation (SDE): a rule for how a picture drifts and jiggles as continuous time passes.

dx
The tiny change in the picture during a tiny slice of time dt. Run time backwards, from noise (t = T) to data (t = 0).
f(x, t)
The drift the forward noising used: how the picture shrinks as noise comes in.
g2(t)
The strength of the noise at time t, squared. The forward SDE of slide 32 is dx = f(x, t) dt + g(t) dw.
∇x log pt(x)
The score function, boxed on slide 32. At each point it is an arrow that points toward more likely pictures at noise level t. This is the one thing the network learns.
g(t) dw
Fresh random noise, added as time runs backwards.

The score and the noise target are the same thing in different units. The score points from the noisy picture toward the clean one, and the noise ε is what you subtract; they differ by a known factor that depends on t. So noise prediction in Chapter 4 was score learning all along. Slide 31 lists what the continuous view buys: higher-quality samples, exact log-likelihood, and controllable generation. The last one is Chapter 9. Slide 32 sums it as an “infinite-layer” latent variable model: a VAE with a layer for every instant.

On the straight path xt = t·x + (1 − t)·ε, what is the velocity v, and why is it called a velocity?

Chapter 6

Flow Matching: Learn the Roads, Then Drive

Learn one velocity arrow for every place and moment, then carry noise to data by following the arrows

Picture a city at dawn. Ten thousand cars sit in a parking lot on one side. By noon they must be spread across the town in the right pattern: so many at the harbour, so many downtown. Chapter 4’s diffusion is like telling each car to wander and then slowly teaching it to wander home. Flow matching asks a simpler question: what is the best road map?

Slide 33 puts the two ideas side by side. Diffusion adds noise to data in training and learns to reverse the process step by step. Flow matching learns a continuous vector field, an arrow at every place and every moment, that carries noise straight into data by solving an ordinary differential equation. The lecture says this avoids the step-by-step forward process and gives faster sampling.

Driving the road map

An ordinary differential equation (ODE) is a rule that says, at each place and time, how fast to move and which way. Slide 34 writes it: start from noise X0 ~ pinit, then d/dt Xt = utθ(Xt). Here uθ is the learned velocity field. Time runs from 0 to 1, and X1 is the sample.

You cannot solve this exactly, so you take small steps. The Euler method is the simplest: look at the arrow where you stand, move along it for a short time h, and repeat. In symbols Xt+h = Xt + h · utθ(Xt). The slide’s algorithm sets h = 1/n, draws X0 from the noise, loops n times (update X, then advance t by h), and returns X1. The hero at the top of this page runs exactly this loop. Try 1 step there, then 32.

With a single step you jump along the arrow at the start, which points toward the average of all the data. Every dot lands on the middle of the three targets. That is a blurry average, the same blur you met in VAEs. With 32 steps the dots follow the bending roads and settle on the targets. Euler steps are cheap, so the cost of quality is simply how many times you ask the network for an arrow.

Where the arrows come from

We want the arrow field that carries noise into data. Nobody can write it down, so we teach a network to match it. The training recipe is almost embarrassingly simple.

  1. Pair. Draw a noise sample x0 and a real data sample x1, independently.
  2. Interpolate. Pick a time t between 0 and 1, and set xt = (1 − t)·x0 + t·x1, a point on the straight line between them.
  3. Target. The velocity along that line is x1 − x0, the same v as in Chapter 5.
  4. Regress. Train the network so uθ(xt, t) matches the target by squared error.

Here is the puzzle. Each pair gives an arrow only for its own line. But at one place and time, many different pairs have lines passing through, each with a different arrow. The network can output only one. What does least-squares training give it? The average of all the arrows that cross there. That average is the true marginal velocity field. Click the canvas below to see it happen.

Average the crossing arrows

Faint lines: random noise-to-data pairs. Dots: where each pair sits at time t. Click or tap anywhere to pick a spot. Blue arrows are the pairs near the spot; the warm arrow is their average, which is what the network learns.

0.50

Same toy as the hero: three blobs of spread 0.18, noise with spread 1. 3,000 invented pairs, fixed by a seed; “near” means within 0.3 of the spot at time t. The exact field is the closed form for this toy. The sampled average is an estimate and wobbles when few pairs are near.

The failure mode is easy to see in the device at t = 0.2 near the middle. Pairs that go to different targets cross there, so the average of their arrows is short and compromises between the targets. A short arrow moves a dot only a little, and the road bends. Symptom: with too few Euler steps the dots overshoot or stop between targets. Measurement: the hero’s score, 0 of 360 dots on a target at one step and 354 of 360 (98%) at 32. Fix: more steps, or straighter roads, which is what the rectified flow of slide 35 pursues.

The code

python# flow matching: one training step and the sampler; x1: (B, D) data
x0 = torch.randn_like(x1)                               # noise, (B, D)
t  = torch.rand(B, 1)                                   # one time per example, (B, 1)
xt = (1 - t) * x0 + t * x1                              # point on the straight line
loss = ((net(xt, t) - (x1 - x0)) ** 2).mean()           # match the velocity

def sample(net, B, D, n=8):
    x, h = torch.randn(B, D), 1.0 / n
    for i in range(n):                                # Euler, as on slide 34
        x = x + h * net(x, torch.full((B, 1), i * h))
    return x

The three families on one page

Slide 35 is a comparison table, here in our own words, with the lecture’s claims.

FeatureVAEDiffusionFlow matching
Core ideaEncode and decode through a latentAdd noise, learn to reverse itLearn a flow from noise to data
Training goalRebuild the input and keep the latent near the priorLearn the score (gradient) of the dataMatch a velocity field
Sampling speedVery fast, one passSlow, many denoising stepsFaster, solve an ODE
StrengthSimple, fast, easy to readVery high qualityHigh quality and faster
WeaknessBlurry samples, limited rangeCostly and slow to sampleNewer, still developing
ExamplesVAE (2013), β-VAEDDPM, Stable DiffusionFlow Matching (2023), Rectified Flow

The readings on flow matching

Flow Matching for Generative Modeling (Lipman et al., arXiv 2210.02747) is the paper that made the recipe above standard. It trains with simple per-pair targets and allows many kinds of paths, including diffusion paths and straighter ones. Our full lesson: Flow Matching.

Flow Matching Guide and Code (arXiv 2412.06264) is a self-contained review of the mathematics, the design choices and the extensions, with a PyTorch package of examples for image and text generation. Lesson: Flow Matching Guide and Code.

Unraveling the Connections Between Flow Matching and Diffusion Probabilistic Models (link as the syllabus gives it) studies how the two families relate. You have already met the heart of it: Chapter 5 showed that noise, score and velocity targets convert into one another. Lesson: Unraveling FM and DPM.

Exploring Diffusion and Flow Matching Under Generator Matching (arXiv 2412.11024) places both under one framework of generative Markov processes. Its authors use it to explain why flow matching can be more robust in practice and how to mix deterministic and random parts into new model classes. Lesson: Generator Matching.

Each training pair gives a different arrow, x1 − x0, for a line through a given point. Why does the trained network end up with a single useful velocity there?

Chapter 7

Draw in a Small Space and Let the Prompt Steer

Run the expensive loop on a compressed picture, and feed the words in through attention

A single 512 × 512 colour picture holds 786,432 numbers. A diffusion network must read all of them and write all of them back, about fifty times for one picture. Most of those numbers are tiny details your eye cannot tell apart. Spending a big network on them is like proofreading a novel letter by letter when you only want to check the plot.

Rombach et al. (CVPR 2022), cited across slides 37 to 40, had a simple answer: do not run the loop on pixels. Compress the picture first, run diffusion on the small version, and expand it at the end. They called the result latent diffusion. Stable Diffusion is built this way.

Two kinds of compression, two jobs

Slide 37 splits the work in two. An autoencoder does the perceptual compression: it throws away detail you cannot see, such as exact noise grain, and keeps the picture’s look. The diffusion model then does the semantic compression: it learns what a picture means, which shapes go with which objects. The plot on the slide shows distortion against bits per dimension, with a sweet spot where the autoencoder gives up little and the diffusion model gets a much smaller job.

The data flow, with Stable Diffusion v1’s shapes: an encoder E maps the picture x of shape (512, 512, 3) to a latent z of shape (64, 64, 4). That is a factor of 8 on each side, 8 × 8 = 64 times fewer positions, and 786,432 / 16,384 = 48 times fewer numbers (the latent has 4 channels instead of 3). Diffusion runs on z. At the end a decoder D maps z back to (512, 512, 3). Slide the compression below and read what it does to the work.

Shrink the space

Bars use a log scale, so each gridline is 10 times more. Top: the numbers the network reads in one step. Bottom: image positions that attention compares in pairs. Drag the compression factor f.

8

A 512 × 512 × 3 picture; latent side 512 / f with 4 channels (f = 8 with 4 channels is Stable Diffusion v1; the channel count at other f is held at 4 for illustration). Pairs are positions squared, the cost of one full self-attention layer; real pixel-space models avoid full attention at the top resolution, so the pixel-space bar is a ceiling, not a measured cost.

At f = 8 the network reads 16,384 numbers instead of 786,432, and a full attention layer compares 4,096 positions in pairs instead of 262,144: about 4,000 times fewer pairs. That saving is a big part of why Stable Diffusion runs on a consumer graphics card.

The failure mode is squeezing too hard. Symptom: faces and small text look smeared even when the layout is right. Measurement: the rebuild error of the autoencoder alone, with no diffusion at all, because the decoder can never do better than that. Fix: a milder factor. Rombach et al. compared factors from 1 to 32 and found that mild factors, roughly 4 to 16, gave the best trade.

How words get in: cross-attention

Now steering. The slide-37 picture shows conditioning inputs (a semantic map, text, other representations, images) entering the denoising network through cross-attention. Attention (the mechanism inside transformers) lets each position look at a set of other positions and take a weighted mix of what it finds. In self-attention the picture looks at itself. In cross-attention the picture looks at the prompt.

With shapes: the 64 × 64 latent becomes 4,096 positions, each a vector, and these make the queries Q, shape (4096, d). The prompt, cut into 77 tokens and encoded, makes the keys K and values V, each (77, d). The result is softmax(Q KT / √d) V, shape (4096, d). Read it as: every spot in the picture asks, “which words matter for me?”, and pulls in a blend of their values. The spot that will become the avocado shell attends to “avocado”; the spot that will become the seat attends to “armchair”.

Which text encoder?

Slide 36 compares two designs. DALL-E 2 runs diffusion on top of frozen CLIP embeddings. Imagen (Saharia et al.) runs it on top of frozen T5 embeddings, a text-only language model. The slide’s test prompts show the effect. For “a black apple and a green backpack” the DALL-E 2 sample swaps the colours (marked wrong) while Imagen gets them right. For “a horse riding an astronaut” both sample the more common scene, an astronaut riding a horse, and both are marked wrong. A bigger, text-trained encoder binds colours to objects better. An odd role reversal still defeats both.

Slides 38 to 40 then show what one latent diffusion design can do by changing the condition: text prompts, from a model with 1.45 billion parameters trained on LAION (a set of 400 million image-caption pairs), a coloured semantic map turned into a landscape, and a layout of boxes turned into a crowded scene from the COCO dataset.

Readings that rebuild the denoiser

Scalable Diffusion Models with Transformers (Peebles and Xie, arXiv 2212.09748) replaces the usual convolutional U-Net with a plain transformer that reads the latent as patches. The condition enters through adaptive normalization layers. Bigger transformers gave better pictures in a steady way, and the largest, DiT-XL/2, reached an FID of 2.27 on class-conditional ImageNet at 256 × 256. Our lesson: DiT.

Scaling Rectified Flow Transformers for High-Resolution Image Synthesis (Esser et al., arXiv 2403.03206), the Stable Diffusion 3 paper, joins Chapter 6 to this chapter. It trains with a straight-line flow and uses a transformer whose image tokens and text tokens have their own weights but attend to each other. Lesson: Stable Diffusion 3.

Flow Matching in Latent Space (Dao et al., arXiv 2307.08698) applies flow matching inside a pretrained autoencoder’s latent space, for lower cost at high resolution. It also tries conditions: class labels, inpainting and semantic maps. Lesson: Flow Matching in Latent Space.

In latent diffusion, what is the job of the autoencoder, and what is the job of the diffusion model?

Chapter 8

Diffusion for Text, Sound, Video and Sensors

Swap Gaussian static for masks, and the same denoising idea writes whole sentences at once

A chat model writes one word at a time, left to right. If it writes a wrong word early, it cannot go back; every later word builds on the mistake. A human editor works differently. She drafts the whole page roughly, then sharpens many places at once, fixing early lines when late lines show the problem.

Slide 41 asks whether a language model can work like the editor. Diffusion language models start from a fully hidden sequence and refine the whole sequence over a few passes. The lecture lists four hoped-for gains: they can fix earlier mistakes, they are more controllable, they give more diversity, and they can be faster.

What replaces Gaussian noise

Slide 42 lists the changes against image diffusion. Images are continuous pixels, so Gaussian noise makes sense: nudge a brightness from 0.50 to 0.53. Text is discrete: a token is an integer, and 4,012 plus a little noise is not another word. So the noise must be categorical: with some probability, swap a token for a blank mask symbol, or for a random token. Masking is the usual choice.

There are two families, as the slide notes. Continuous diffusion language models (Li et al., Diffusion-LM, NeurIPS 2022) keep Gaussian noise but run it on word embeddings, and need a rounding step at the end that snaps each vector to its nearest word. Discrete models corrupt the tokens directly and need no rounding.

Masked diffusion, step by step

Slide 43 shows the scheme of LLaDA (Nie et al., NeurIPS 2025) in three panels. (a) Pretraining. For each text, pick a mask ratio t between 0 and 1 at random, and hide each token with probability t. A transformer, with no left-to-right limit, predicts the hidden tokens; the loss counts only those and divides by t. (b) Fine-tuning. Keep the prompt visible and mask only the answer. (c) Sampling. Start with the whole answer masked (t = 1). Each pass, predict every mask, keep the confident guesses, and put some back under a mask (remasking), until nothing is masked (t = 0). Because it can remask a token it doubts, it can fix an earlier mistake.

A worked example. A 12-token answer at t = 0.5 has about 6 masks. The network sees 6 real tokens, and must fill 6. This is like BERT’s fill-in-the-blank, with one change that matters: the blank ratio is random, from nearly none to everything, so the model learns to start from a blank page.

Fill the blanks

Dashed boxes are masked tokens. Choose how to fill them, then press Next pass. Warm boxes are filled. The teal box is the one filled most recently.

4

Illustrative: the sentence is invented and the confidence of each token is a made-up number in [0, 1] (small words high, rare words low). Masked diffusion fills the most confident masked tokens each pass; a real model recomputes confidence every pass, and LLaDA can also remask. Left to right always writes one token per pass.

Choose 4 passes and press the button four times. Each pass fills three tokens, starting with the small, certain words (“The” and the two “the”s). Left to right needs twelve passes for the same sentence. That is the speed hope. The failure mode is the price: drag the passes down to 1 and every token is guessed at once, with no chance to look at its neighbours. Symptom: repeated or clashing words. Measurement: sample quality falls as tokens per pass rise. Fix: more passes, or remasking the doubtful tokens. LLaDA 8B was strong at the lecture’s test of reversal tasks, because nothing in the model prefers left to right.

The reading on text

Large Language Diffusion Models (Nie et al., arXiv 2502.09992) trains LLaDA from scratch with the recipe above. The authors report that the 8B model is competitive with LLaMA3 8B in in-context learning, follows instructions after fine-tuning, and beats GPT-4o on a reversal poem completion task, where the model must continue a poem backwards. Lesson: LLaDA. For a longer course on the same topic: Diffusion Language Models.

Sound, video and sensors

Slide 44 points to a tutorial on diffusion for audio (ICASSP 2025). For music, the slide frames the choice between autoregressive models and diffusion models. Audio is long, so models often denoise a compressed latent of a spectrogram, the same trick as Chapter 7.

Slide 45, video (Melnik et al., 2024 survey), shows text-to-video and video-to-video clips and names what is still hard: temporal coherence (does the runner keep the same face?), physical consistency (does the ball fall?) and viewpoint dynamics. Slide 46, sensors (Su et al., 2025), shows diffusion forecasting a time series: noise a window of past readings and denoise future ones, with the history as the condition.

Two more readings carry conditional flow matching into new media. FlowMotion (arXiv 2504.01338) generates 3D human motion from text, adds a training goal that predicts the target motion directly, and reports the best jitter on the KIT dataset. Lesson: FlowMotion. MusFlow (arXiv 2504.13535) makes music from images, story text or captions. Small networks align each input to an audio embedding space, and flow matching rebuilds a compressed mel-spectrogram. Lesson: MusFlow.

One model for every modality

Slides 47 and 48 end the tour with MMaDA (Yang et al., 2025), a multimodal large diffusion language model. One masked-diffusion transformer reads and writes text and image tokens. It reasons in text, answers questions about images, and generates images from text, all by the same unmask-the-blanks procedure. The last slide shows the Hugging Face diffusers library, a modular toolbox of pretrained pipelines and swappable schedulers, the pieces that choose the step sizes.

Why does diffusion for text usually corrupt tokens by masking instead of adding Gaussian noise?

Chapter 9

Guidance: A Dial Between Obeying and Varying

Turn one number up to make the model follow the prompt harder, and measure what that costs

You ask for “a shiny, delicious burger.” The model draws a burger, but a plain one. You ask again and get a burger with a salad. The model is following your prompt loosely, because many pictures fit the words. You want it to try harder.

So we need a dial for obedience. The tool is guidance, and it comes straight from a rule about probabilities. The cost of turning the dial too far is variety, and the way to see it is with the lecture’s own scorecard.

The scorecard: how to judge a generator

Slide 49 lists four evaluation metrics. Each answers a different question.

Keep two of them in mind: CLIP score, which rewards obeying the prompt, and recall, which rewards variety. They pull in opposite directions, and guidance is the dial between them.

Where guidance comes from

Chapter 5 gave us the score, the arrow toward more likely pictures. We want the score of pictures that fit a condition y, written ∇log p(x | y). Bayes’ rule splits it in two: ∇log p(x | y) = ∇log p(x) + ∇log p(y | x). The first part is the ordinary, unconditional arrow. The second part is a new arrow that points toward pictures that make the condition more likely.

Classifier guidance

Slide 50 uses the split directly. Train one unconditional generator. Train a separate classifier, a model that answers “how likely is label y for this input?”, and run it on noisy inputs too. At every step, add the classifier’s gradient to the generator’s score, scaled by a number γ: ∇log p(xt | y) = ∇log p(xt) + γ∇log p(y | xt). The slide’s example is text. A pretrained model continues “The food tastes”, and a sentiment classifier scores each candidate: “shiny” and “delicious” get y = +1, “terrible” gets y = −1. The gradient pushes the continuation toward “delicious”. The method is from Dhariwal and Nichol (2021), “Diffusion Models Beat GANs on Image Synthesis”. The price: you must train and carry a second model, and it must work on noisy data.

Classifier-free guidance

Slide 51 asks: do we need two separate generative models, one conditional and one unconditional? No. Train one network and, during training, hide the condition at random, say 10% of the time, replacing it with a constant (the slide: “unconditional training can be seen as setting y = constant”). The one network now knows both arrows. Rewrite the classifier term as the difference between the two: guided score = ∇log p(x) + γ( ∇log p(x | y) − ∇log p(x) ). The same line, regrouped: γ ∇log p(x | y) + (1 − γ) ∇log p(x). At γ = 0 you get the unconditional model. At γ = 1 you get the plain conditional model. Above 1 you extrapolate, going past the conditional arrow, away from the unconditional one. The GLIDE paper (Nichol et al., 2022) compared both methods and preferred classifier-free guidance, and the slide says so.

Try it on a one-dimensional toy where the answer is exact. Two classes sit at −2 and +2. The prompt asks for the right-hand class.

Turn the guidance dial

Grey: the unconditional model (both classes). Blue dashed: the plain conditional model (right class only). Warm: what guidance at your strength samples. Drag γ and watch the warm curve move and narrow.

1.00

Toy: classes N(−2, 1) and N(+2, 1), equally likely. The guided density is proportional to p(x | y)γ · p(x)1 − γ, which is what the formula above samples; it is normalised on a grid in your browser. “On the right side” is the share of mass above 0, a stand-in for obeying the prompt; the spread is the standard deviation, a stand-in for variety.

At γ = 0 the warm curve is the grey one: half the mass (50.0%) sits on the wrong side and the spread is 2.24. The prompt is ignored. At γ = 1 it matches the dashed blue curve: 97.7% of the mass is on the right and the spread is 1.00. At γ = 4 it reaches 99.9% on the right, but the spread has shrunk to 0.90 and the centre has moved from 2.00 to 2.12, away from the other class. Obedience is almost used up, while variety keeps falling and the samples drift toward the extreme. In a real model with thousands of dimensions, this drift shows up as over-bright, over-smooth pictures.

That is the failure mode of too much guidance. Symptom: over-bright, over-smooth, near-identical pictures. Measurement: CLIP score keeps rising while recall and FID get worse past a sweet spot. Fix: sweep γ and pick the value where FID is lowest or where people prefer the pictures. In practice the guidance scale of Stable Diffusion in the diffusers library defaults to 7.5, in this same convention.

The code

python# classifier-free guidance at one sampling step
eps_c = net(xt, t, cond=prompt_emb)                      # conditional guess,  (B, C, H, W)
eps_u = net(xt, t, cond=null_emb)                        # unconditional guess, same shape
eps   = eps_u + gamma * (eps_c - eps_u)                  # gamma = 1: plain; gamma > 1: push harder
# training: with probability p_drop (e.g. 0.1), swap prompt_emb for null_emb

Guidance costs two network passes per step instead of one, so a 50-step picture takes 100 passes (often run as one batch of two). It also needs the condition to be droppable in training, which is why prompts are randomly blanked.

In classifier-free guidance, what happens at γ greater than 1?

Chapter 10

Five Ways to Steer a Generative Model

Match a situation to the cheapest way of telling the model what you want, and see what is still unsolved

You are handed a generative model and a goal. Perhaps the goal is “draw what this caption says.” Perhaps it is “answer a question about this photo.” Perhaps you may not retrain the model at all. The right way to steer depends on what you own: data, compute, a frozen model, a label classifier.

The last slides of the lecture give a map of five ways. First, a quick look at the families they steer.

The families, in the lecture’s summary

Slide 52 sums up the three likelihood-based families, models that learn a score for how likely data is. Each has a cost. Autoregressive models (Chapter 1’s token writers) get exact inference by the chain rule of probability; they are easy to train and give an exact likelihood, but slow to sample, since tokens come one by one. VAEs (Chapter 3) use approximate inference through the evidence lower bound; they are fast and easy to train, but generation quality is lower. Diffusion models (Chapters 4 to 6) use approximate inference by modelling noise; quality is high, but sampling is slow. You have now met every row, and you know the trade: speed and quality pull against each other.

The five ways

Slides 53 to 56 add one way at a time to the same list.

  1. Conditioning. Feed the condition y to the network as an input, from the start of training. For diffusion the slide writes p(x0:T | y) = p(xT) ∏ pθ(xt−1 | xt, y): every denoising step also sees y. Chapter 7’s cross-attention is this.
  2. Adapting. Keep a big pretrained model frozen, which gives p(x), and train a small adapter beside it that turns the condition into something the frozen model understands. The slide’s example: a frozen vision-language model plus a small trained adapter answers “What color is the car?” with “Blue”. The adapter changes p(x) into p(x | c).
  3. Representation tuning. Leave the weights alone and steer the model’s internal numbers. The slide draws a learned shift applied inside the model, next to its attention, to move p(x) toward p(x | c).
  4. Classifier gradient tuning. Use a separate classifier’s gradient to bend each step toward the label (Chapter 9), with the unconditional generator untouched.
  5. Classifier-free tuning. Use the generator’s own conditional and unconditional guesses, and extrapolate between them with γ (Chapter 9).

The first is the heaviest and gives the most control. The last four let you reuse a model that already exists. Try matching five situations to the five ways.

Pick the way to steer

Read the situation, then press the way of steering that fits it best. The first match that you press counts.

The five situations are invented to show the lecture’s five labels. Real projects often combine several, and more than one answer can be defensible.

The failure mode of steering is asking a model for something it never learned. An adapter cannot add a concept the frozen model cannot express. Symptom: the output ignores or garbles the condition. Measurement: a low CLIP score, or no change when you vary the condition. Fix: move up the list, to conditioning during training, or add data that covers the concept.

What is still open

Slide 57 ends the lecture with a hard goal: generate several modalities at once while staying coherent within each and across them. Its example is a single scene: “Big dog on the beach. Waves crashing, people playing volleyball…” The picture shows a dog, the sea and a volleyball game. The sound track has “woof”, “crash”, “bounce” and “whoosh”. Each sound must line up with its cause in the picture, at the right moment, with the right logic: the bounce comes after the hit.

Slide 60 turns this into six directions. One: synchronized generation over multiple modalities. Two: what is special about diffusion from a multimodal view? Three: combining generation with explicit reasoning, so scenes can be composed. Four: better fusion and alignment of representations. Five: more control, both fine-grained and from few examples. Six: human-centred evaluation, because FID and CLIP score are only proxies for what people want.

You own a large frozen generator and a small set of examples with a new kind of condition, and you may not change the generator’s weights. Which of the lecture’s five ways fits best?

Chapter 11

The Whole Lecture on One Page

Review the numbers, the code and the checklist, then follow the links onward

You can now reproduce Lecture 6.2 from memory. A model learns what real data looks like, then draws new data by starting from noise and walking toward the data. The walk can be written as a thousand denoising steps or as a few steps along a learned velocity field. A prompt steers the walk, and a dial controls how hard.

The one-paragraph summary

A generative model learns p(x). Early text-to-image systems turned pictures into visual tokens and wrote them like words. Latent variable models explain data through hidden knobs; the VAE makes those knobs continuous and pays a KL price for tidiness, at the cost of blur. Diffusion adds noise on a fixed ladder and trains a network to undo one step; the target can be the clean picture, the noise or the velocity, and the score ties them together. Flow matching regresses a velocity field on straight lines and samples with an ODE, so fewer steps give good samples. Latent diffusion runs the loop in a small space and takes the prompt by cross-attention. Masking carries the idea to text, and the same recipe reaches sound, video and sensors. Guidance trades variety for obedience.

The numbers that matter

WhatNumberWhy it matters
DALL-E picture to tokens196,608 numbers to 1,024 tokens from 8,192 codes (13 bits each)A language model can write a picture as integers
Mixture, worked examplep(3) = 0.1232; responsibility 0.982E step: who made this point?
VAE KL, worked exampleμ = 1, σ = 0.5 gives 0.818The price of a cloud far from the prior
DDPM scheduleT = 1,000; variance 0.0001 to 0.02; picture weight about 0.006 at the endThe ladder must end in pure noise
Velocity on a straight pathv = x − εThe target flow matching regresses
Euler samplerh = 1/n; X += h · u(X, t)n network calls per sample
Stable Diffusion v1 shapes786,432 pixels to 64 × 64 × 4 = 16,384 latent (48× fewer)Why latent diffusion is cheap
DiT-XL/2FID 2.27, ImageNet 256 × 256A transformer denoiser scales
LLaDA8B parameters, masked diffusion, beats GPT-4o on a reversal poem taskText without left-to-right writing
Classifier-free guidanceε = εu + γ(εc − εu); two passes per stepOne dial from varied to obedient
MetricsFID lower is better (below 10 is strong); CLIP score higher is betterQuality and prompt match are measured apart

The core as one sampler

This sketch joins Chapters 6, 7 and 9: a flow sampler with Euler steps, in a latent space, with classifier-free guidance. net, text_enc and vae stand for pretrained models.

pythondef generate(prompt, n=30, gamma=5.0):
    c  = text_enc(prompt)                                # (77, 768), Ch 7
    u  = text_enc("")                                  # the null prompt, Ch 9
    z  = torch.randn(1, 4, 64, 64)                       # noise in the latent space, Ch 7
    h  = 1.0 / n
    for i in range(n):                                 # Euler steps, Ch 6
        t  = torch.full((1,), i * h)
        vc = net(z, t, cond=c)                           # velocity with the prompt
        vu = net(z, t, cond=u)                           # velocity without it
        z  = z + h * (vu + gamma * (vc - vu))            # guided step
    return vae.decode(z)                                # (1, 3, 512, 512)

A checklist for reading any generative model

  1. What is the data space? Pixels, tokens, a latent, a spectrogram, a time series?
  2. What is the noise? Gaussian, a mask, or a start from a prior sample?
  3. What does the network output? Clean sample, noise, score or velocity?
  4. How many network calls per sample? One, tens, or a thousand?
  5. How does the condition enter? Input, adapter, activations, classifier or both guesses?
  6. How is it judged? FID, CLIP score, precision and recall, or human taste?

Where it sits, and where to go next

These ideas connect to lessons we already have. VAE and VQ-VAE and CLIP cover Chapters 1 to 3. Diffusion and Flow Matching are the Gleam-level versions of Chapters 4 to 6. The MIT 6.S184 series goes deeper: Flow and Diffusion Models, Score Matching and Guidance, Architectures and Latent Space and Discrete Diffusion. Our DiT Gleam and the Stable Diffusion 3 lesson cover the denoiser in Chapter 7.

This lecture’s ten readings, in the order of the syllabus: Scalable Diffusion Models with Transformers, Flow Matching in Latent Space, Scaling Rectified Flow Transformers, Large Language Diffusion Models, Flow Matching for Generative Modeling, Flow Matching Guide and Code, FlowMotion, MusFlow, Unraveling the Connections Between Flow Matching and Diffusion and Exploring Diffusion and Flow Matching Under Generator Matching. The lecture’s own resources list adds the annotated diffusion post on Hugging Face, Lilian Weng’s and Yang Song’s blog posts on diffusion and score models, and Calvin Luo’s diffusion tutorial, from which several slides draw their figures.

The takeaway. Every generator in this lecture does one thing: it turns a simple random start into data, with a rule it learned from examples. VAEs do it in one jump and blur. Diffusion does it in many careful steps. Flow matching does it along learned straight roads. Latent spaces make it cheap, and guidance makes it obey.

Now press Present or Teach and explain, from memory, how noise becomes a picture: the noise ladder, what the network predicts, and how few steps flow matching needs. Then go back to the dots at the top, set 2 steps and 32 steps, and say why the same velocity field gives such different pictures.

MIT Multimodal AI, Lecture 6.2: Modern Generative AI
Course site and lecture slides · Course: MIT Multimodal AI (Spring 2026), Paul Liang, MIT Multisensory Intelligence group · Back to Gleams