Stephen Welch: How Diffusion Models Turn Text into Images and Video

CLIP embeddings, noisy random walks and guidance explain how models turn a prompt into a generated image.

SWStephen Welch登壇者 · Welch Labs
チャンネル
3Blue1Brown
公開日
2025年7月25日
動画
37:20
読了時間
6 分
スライド
9
原文
英語
YouTube で開く
スクロールすると動画は右下に小さくなって再生を続けます。字幕は閲覧言語に合わせて切り替わります。
閲覧言語2 言語で読めます
この記事はまだ日本語に翻訳されていないため、英語の原文を表示しています。
要約

30 秒でわかる

In a guest lesson for 3Blue1Brown, Stephen Welch explains contrastive image–text representations, diffusion sampling and classifier-free guidance using a two-dimensional toy dataset. He connects the algorithms to Brownian motion and explains why deterministic sampling is not the same as simply removing noise from a stochastic sampler.

  1. 1CLIP’s shared spaceContrastive training aligns matching image and caption vectors while separating nonmatching pairs.
  2. 2Learn to reverse noiseDDPM trains a model to estimate the noise added to a clean example.
  3. 3A two-dimensional analogyPixel values become coordinates, so noise is a random walk and denoising becomes a vector field.
  4. 4Why sampling noise mattersRemoving noise from the DDPM sampler can pull examples toward an average; the video notes the analogy’s limits.
  5. 5A deterministic alternativeDDIM changes the update rule and step scaling rather than simply deleting DDPM’s random step.
  6. 6GuidanceClassifier-free guidance amplifies the difference between conditioned and unconditioned predictions.

ポイント

  1. CLIP trains image and text encoders to align matching pairs in a shared embedding space.
  2. Diffusion models learn how to move noisy samples toward the data distribution, with noise level as an input.
  3. DDPM adds random noise during sampling; simply deleting that step changes the process and can degrade results.
  4. DDIM uses a differently scaled deterministic trajectory to approximate a matching distribution with fewer steps.
  5. Conditioning and classifier-free guidance steer generation toward a prompt; negative prompts provide another direction to avoid.
全文

チャプターごとに整えた全文を読む

文字起こしのみ
01

From noise to video

Welch introduces iterative generation and its connection to diffusion.

AI image and video generators can turn text into remarkably detailed scenes. Stephen Welch introduces diffusion as a connection to Brownian motion run in reverse in a high-dimensional space. The physical analogy leads to practical algorithms, not merely a metaphor.

As an example, Welch shows the open WAN 2.1 video model responding to prompts about an astronaut. Its generation process starts from random noise and repeatedly applies a transformer, gradually shaping the sample into a video. The video description notes that the displayed noise is decoded from a compressed latent representation.

Iterative generation
スライド 1 / 9Iterative generationA transformer repeatedly updates a noisy video sample.

Each model pass produces an update; repeated iterations add visible structure. This raises two questions: how can a model reverse a random process, and how does text steer that process toward a requested scene? Welch approaches them through CLIP, diffusion and guidance.

02

CLIP and shared embeddings

Contrastive training relates image and text representations.

OpenAI’s CLIP, released in 2021, uses an image encoder and a text encoder trained on image-caption pairs. Each produces a vector in a shared space. The training objective makes matching image and caption representations similar and pushes nonmatching pairs apart.

In a batch, arrange image vectors against caption vectors in a matrix. Matching pairs lie along the diagonal; other entries are nonmatches. The contrastive objective uses both kinds of pair, with cosine similarity measuring how closely the vectors point in the same direction.

Contrastive pairs
スライド 2 / 9Contrastive pairsA matrix of image and caption representations distinguishes matching from nonmatching pairs.

Cosine similarity is the cosine of the angle between vectors; identical directions have similarity one. The learned space lets the model compare descriptions with pictures, even though the geometry is high dimensional and the two-dimensional illustrations are only an aid to intuition.

Welch subtracts the embedding of a photo without a hat from one with a hat. Among several hundred words, “hat” is the strongest match to the difference vector in his experiment, followed by related words. This illustrates that some meaningful image differences correspond to directions in the learned space.

CLIP can classify an image by comparing its embedding with candidate text labels and selecting the most similar one. But these encoders map images and text into the space; by themselves they do not generate an image from an embedding.

03

DDPM and random walks

A toy dataset makes denoising and time-dependent vector fields visible.

Denoising Diffusion Probabilistic Models, or DDPM, provide a way to generate images. Training begins with clean examples and adds scaled random noise. The neural network learns to estimate the total noise added, rather than merely recovering the immediately previous step.

DDPM sampling also adds random noise during generation. In Welch’s Stable Diffusion example, removing that step from the DDPM update produces a small, blurry tree. The video’s technical notes add that a mismatch between the actual and expected noise levels is a likely cause of that particular degradation.

A generated tree
スライド 3 / 9A generated treeThe Stable Diffusion example illustrates the effect of changing the sampling process.

Why predict the total noise rather than only the last small step? Welch uses a different but related view: the model learns a time-varying vector field that directs noisy samples toward the data distribution. That view also connects to broader flow-based approaches.

Imagine an image with only two grayscale pixels. Their intensities become x and y coordinates on a plane. A collection of images becomes a set of points; for the toy example, Welch arranges them along a spiral.

Adding noise changes pixel values in random directions. Repeated additions move a point on a random walk, analogous to Brownian motion. Learning to denoise means learning how to move noisy points back toward the spiral’s distribution, not reconstructing the particular random path exactly.

For a given noisy point, many possible training paths may have passed nearby. Although each final step is random, their average contains a direction toward the data. Predicting total added noise gives a lower-variance training signal for learning this direction.

A random walk and its total displacement
スライド 4 / 9A random walk and its total displacementThe diagram contrasts the last step with the vector back to the clean starting point.

The learned direction also depends on the noise level. Far from the original data the field points broadly toward the spiral’s center; at lower noise it can resolve finer structure. Providing the time or noise level as an input lets one model learn both.

A time-dependent vector field
スライド 5 / 9A time-dependent vector fieldThe learned directions begin to resolve the spiral’s structure as noise decreases.

In DDPM sampling, start with a random point, move a little along the learned field, and add a scaled random step. Repeating this process gradually brings a cloud of points back to the spiral, with the random step decreasing as sampling proceeds.

If Welch removes the random step without changing the rest of the DDPM update, the points cluster near the mean rather than covering the spiral. He uses this to build intuition for blurry averaged images, while emphasizing that the two-dimensional analogy does not fully explain high-dimensional behavior.

The reverse transition can be approximated by a Gaussian distribution for sufficiently small steps. The model predicts its mean; adding appropriately scaled zero-mean noise samples the transition instead of always taking that mean. This explains the noise term in the stochastic DDPM procedure.

DDPM’s early drawback was computational cost: high-quality generation required many neural-network evaluations. Later work showed that a related deterministic process could generate high-quality samples without injecting noise at every step.

04

Deterministic sampling

An alternative trajectory motivates DDIM and fewer generation steps.

The stochastic process can be described by a stochastic differential equation. Using the Fokker–Planck connection, researchers derived an ordinary differential equation whose evolving probability distribution matches the stochastic one under the theoretical assumptions. Individual sample paths need not match.

The practical DDIM approach resembles DDPM but changes step scaling as well as omitting random additions. These smaller, differently scheduled steps follow the learned field more appropriately. It is not equivalent to deleting a line of noise code from the original DDPM sampler.

Deterministic trajectories
スライド 6 / 9Deterministic trajectoriesDDIM-like paths land across the toy data distribution without a random step at each update.

In the spiral example, DDIM’s deterministic paths cover the desired distribution; in the tree example it restores a coherent image. The same trained model can be sampled with fewer steps. The theoretical claim concerns distributions, not identical individual images.

Welch describes WAN’s approach as related to flow matching and then returns to text control. CLIP can represent a prompt, while diffusion can generate images; combining these ideas allows a text representation to influence the trajectory of generation.

05

Conditioning and guidance

Text embeddings, classifier-free guidance and negative prompts steer outputs.

DALL·E 2 used an approach called unCLIP to generate images guided by a shared image–text representation. One general way to steer a denoiser is conditioning: provide text information as an additional input while training on paired images and captions.

Text-conditioned generation
スライド 7 / 9Text-conditioned generationA text encoder and diffusion model are combined to guide an image.

Conditioning can be implemented in different ways, including cross-attention or adding text representations to inputs. The description notes a detail for Stable Diffusion: its text conditioning uses an earlier sequence representation rather than simply the final 512-dimensional CLIP embedding.

Conditioning alone may not strongly enforce every prompt detail. In Welch’s desert example, it can produce sand and a shadow without the requested tree. A toy spiral divided into people, dog and cat regions makes the problem visible: class-conditioned trajectories do not always reach the intended region.

Classifier-free guidance compares two predictions: one with the requested condition and one without it. During training, the condition is omitted for some examples, allowing the same network to produce both types of prediction.

Conditioned and unconditioned directions
スライド 8 / 9Conditioned and unconditioned directionsThe vector difference is used to strengthen guidance toward a class.

Subtract the unconditioned direction from the conditioned direction to isolate a component associated with the prompt, then scale that difference and combine it with the base prediction. Increasing guidance steers samples more strongly toward the requested class. Implementations use different scaling conventions.

In the toy dataset, guided cat and dog samples land more reliably in their respective regions. In the desert example, increasing guidance makes the tree appear and grow more detailed. Stronger guidance changes the result; the video does not claim unlimited guidance always improves it.

Guidance scale
スライド 9 / 9Guidance scaleIncreasing guidance changes how closely the generated tree follows the prompt.

WAN also uses a negative prompt: instead of comparing against an empty condition, it uses a description of unwanted features and steers away from that direction. Welch notes examples such as extra fingers and backward walking, and shows that removing the negative prompt changes the generated scene.

06

Conclusion and guest-video context

Welch reflects on the combined ideas and the host introduces the guest series.

The striking result is that several separately developed ideas fit together: a text encoder represents the prompt, and a learned diffusion or flow field shapes noise toward an image. Geometric intuitions that are easy to draw in two dimensions can help explain operations in much larger spaces.

The 3Blue1Brown host introduces Welch as the guest creator behind Welch Labs and explains that the guest series was commissioned during parental leave. Other planned videos explore statistical mechanics and the connection between modern art and group theory.

同じチャンネルの記事

スライド 20 枚40:44EN
3Blue1Brown· 2026年10月16日Grant Sanderson: There's never been a better time to go into mathGrant Sanderson, Constantin Kogler · 3Blue1BrownStudents fear AI has solved mathematics. Grant Sanderson argues the opposite: even if machines prove theorems better than we do, the institution of math stays valuable—and this is a rare moment when newcomers can reshape it.MathematicsAI for scienceHuman-AI Collaboration+2
スライド 29 枚51:55EN
3Blue1Brown· 2026年9月18日The last IMO problem AI could not solveGrant Sanderson · 3Blue1BrownGrant Sanderson walks through IMO 2025 Problem 6 — a tiling puzzle that frontier models missed — and the visual patience it takes to prove a construction is optimal.MathematicsAI researchReasoning & test-time compute+2
0:55EN
3Blue1Brown· 2026年7月24日The 64 Sugar Cubes Puzzle: Six Equal DistancesA 4×4×4 block has three colors; prove that six same-colored pairs share a distance.MathematicsEducation
スライド2:25EN
3Blue1Brown· 2026年6月12日How Shannon Measured the Entropy of EnglishA guessing game helped Claude Shannon estimate how much information English text contains, and why prediction is central to compression.MathematicsAI History
スライド1:02EN
3Blue1Brown· 2026年6月10日A Robot Walk and the Puzzle of Optimal Binary EncodingHow few bits does it take to send directions that occur with unequal frequencies?MathematicsScience Communication
スライド 4 枚32:19EN
3Blue1Brown· 2026年6月7日Reinventing Entropy: Why Prediction Helps Compress LanguageA robot’s movement code leads from prefix-free encoding to Shannon information and the entropy of language.MathematicsScience Communication