Part XXIII — Modern Architectures, Generative Models & LLM Engineering · Chapter 5

Text-conditioned diffusion

Hook

The diffusion chapter's denoiser always undid noise the same way, regardless of what it was denoising toward. A real image generator starts from the same random noise every time and still needs to draw something different for "a cat" than for "a dog" — so what changes?

Intuition
same starting noise (x_T=2) → final value 3.637

The exact same starting noise, run through the exact same reverse-diffusion formula from the earlier chapter — the only thing that changes between runs is which caption's predicted-noise sequence gets used at each step.

Formalize

Nothing about the reverse step changes:

xt1=xtβtϵ^(xt,t,c)αtx_{t-1} = \frac{x_t - \sqrt{\beta_t}\,\hat\epsilon(x_t, t, \mathbf{c})}{\sqrt{\alpha_t}}
  • xtx_t — the noisy value at diffusion step tt.
  • xt1x_{t-1} — the slightly-less-noisy value this reverse step produces.
  • tt — the current diffusion timestep.
  • αt\alpha_t, βt\beta_t — the same noise-schedule coefficients from the earlier diffusion chapter, controlling how much signal versus noise remains at step tt.
  • ϵ^(xt,t,c)\hat\epsilon(x_t, t, \mathbf{c}) — the denoiser's predicted noise, now taking the caption embedding c\mathbf{c} as an extra input.
  • c\mathbf{c} — the text embedding of the caption being generated toward — the one new ingredient this chapter adds.
  1. One new input: the caption embedding

    The only addition is c\mathbf{c} — a text embedding fed into the denoiser alongside xtx_t and tt. Nothing else about the reverse step's math changes.

  2. Same state, different prediction, different image

    A denoiser trained on captioned images learns to predict different noise, at the same (xt,t)(x_t, t), depending on c\mathbf{c} — which means the same starting noise unrolls into a different final image for every different caption.

Play
unconditional (dashed), 'a cat' (bold), 'a dog' (faint) — one shared starting point, three diverging paths

One shared starting point, three trajectories. The unconditional path (no caption at all) takes a middle course; "a cat" and "a dog" each pull the same starting noise toward a different final value, in opposite directions.

Worked example

Shared starting noise xT=2.0x_T = 2.0, same noise schedule as the earlier chapter, three different predicted-noise sequences:

  1. No conditioning: a generic middle-ground result

    Predicting zero noise at every step reduces the reverse formula to just xt1=xt/αtx_{t-1}=x_t/\sqrt{\alpha_t}. Unrolling from x4=2.0x_4=2.0 with α=[0.9,0.8,0.7,0.6]\alpha=[0.9,0.8,0.7,0.6], from t=3t=3 down to t=0t=0:

    1. x3=2.0/0.62.582x_3 = 2.0/\sqrt{0.6} \approx 2.582
    2. x2=2.582/0.73.086x_2 = 2.582/\sqrt{0.7} \approx 3.086
    3. x1=3.086/0.83.450x_1 = 3.086/\sqrt{0.8} \approx 3.450
    4. x0=3.450/0.93.637x_0 = 3.450/\sqrt{0.9} \approx 3.637

    A plain, unconditioned denoising.

  2. 'A cat': the same starting noise, steered higher

    Swapping in the cat-conditioned noise sequence [1.2,0.8,0.5,1][-1.2, 0.8, -0.5, 1] (read at each step from t=3t{=}3 down to t=0t{=}0) — otherwise identical math. Just the first step already diverges from the unconditional case: x3=(2.00.4×(1.2))/0.6(2.0+0.759)/0.7753.562x_3 = (2.0-\sqrt{0.4}\times(-1.2))/\sqrt{0.6} \approx (2.0+0.759)/0.775 \approx3.562, compared to 2.5822.582 with no conditioning. Carrying the same three remaining steps forward reverses the same x4=2.0x_4=2.0 to 4.330\approx4.330 instead.

  3. 'A dog': the same starting noise, steered lower

    The dog-conditioned sequence is [0.7,0.3,0.9,0.6][0.7, -0.3, 0.9, -0.6]. Its first step: x3=(2.00.4×0.7)/0.6(2.00.443)/0.7752.010x_3 = (2.0-\sqrt{0.4}\times0.7)/\sqrt{0.6} \approx (2.0-0.443)/0.775 \approx2.010 — barely moved from 2.02.0, unlike the cat case's big jump. Carrying the same three remaining steps forward pulls that same x4=2.0x_4=2.0 down to 2.789\approx2.789 — on the opposite side of the unconditional baseline from the cat result.

Same schedule, same formula, same starting noise. Three different captions, three different destinations.

Checkpoint

Find the caption that steers the final value above the unconditional baseline (3.637).

Pick a caption to try it
Summary
ϵ^(xt,t,c)— add one argument to the denoiser, and the entire generation becomes steerable\hat\epsilon(x_t, t, \mathbf{c}) \quad\text{— add one argument to the denoiser, and the entire generation becomes steerable}

Text-conditioned diffusion isn't a different algorithm from plain diffusion — it's the identical reverse process with one extra input threaded through the noise predictor. That single addition is what turns a denoiser into a generator you can actually direct: same random seed, same math, a different picture for every different prompt. The next chapter turns to a modality with its own extra structure that neither images nor audio have on their own: time unfolding across a whole sequence of frames.