Stable Diffusion from Scratch.

Build a text-to-image model one block at a time.

parts
5
reading time
66 min
level
Intermediate
status
complete
last part
Jan 2025
01

About this series

Stable Diffusion looks like magic until you take it apart. This series does exactly that: we start from the building blocks every modern generative model reuses (convolutions, attention, autoencoders), then assemble them into the full latent diffusion pipeline with classifier-free guidance, a UNet denoiser and CLIP text conditioning.

Each part mixes intuition, the equations that matter, and code you can run. Read them in order if you’re new to generative models, or jump straight to the block you need.

02

The parts

Read in order, each part builds on the previous one.

  1. 01

    Introduction and Prerequisites

    A warm-up: why Stable Diffusion is worth taking apart, what the series covers, and how to follow along.

    4 min read read →
  2. 02

    Convolution Layers Explained

    Understand the role of convolutional layers in the architecture of Stable Diffusion models.

    10 min read read →
  3. 03

    Attention Mechanisms Explained

    Understand the role of the attention mechanism in the architecture of Stable Diffusion models.

    17 min read read →
  4. 04

    Variational Auto-Encoders

    Why do we need an auto-encoder for Stable Diffusion? From plain autoencoders to the reparameterization trick.

    15 min read read →
  5. 05

    Diffusion, Classifier-Free Guidance, UNet and CLIP

    Putting it all together: diffusion models, classifier-free guidance, the UNet architecture, and CLIP's role in Stable Diffusion.

    20 min read read →