skip to content

Search

← From Noise to Image

Part II — The Diffusion Revolution (2015–2022)

DALL-E and GLIDE

Discrete-token text-to-image versus text-conditioned diffusion — the fork in the road.

2021 16 min read 2 papers

It is February 2021. A twelve-billion-parameter transformer, trained to treat a caption and an image as one sequence of tokens, produces recognizable illustrations of things that have never existed — an armchair shaped like an avocado, a snail made of a harp — from nothing but a sentence. Ten months later, a different team at the same lab answers the same brief with the opposite architecture: no tokens, no autoregression, just a diffusion model learning to denoise its way toward whatever a sentence describes. The fork in the road this chapter documents did not stay forked for long, but for one year the field ran both experiments at once.

Where We Were

By early 2021, three separate research threads had each solved part of the text-to-image problem without solving all of it. GAN-based text conditioning, covered in First Words to Pictures, had gotten as far as StackGAN’s 256×256 stacked generators (December 2016) and AttnGAN’s per-word attention (November 2017), but adversarial training’s instability at scale kept a hard ceiling on how far anyone had pushed a GAN-based pipeline toward open-ended, unconstrained captions — the datasets that worked best were narrow ones like bird and flower photographs, not the full breadth of what a person might type.

A second thread had nothing to do with images at all. Van den Oord et al.’s VQ-VAE (November 2017) had shown that an image could be compressed into a small grid of discrete codes drawn from a learned codebook, and that an autoregressive prior — the same chain-rule factorization a language model uses — could then be trained over that grid instead of over raw pixels, cutting the number of sequential sampling steps by roughly fifty-fold for a typical configuration (Pixels One at a Time). That result mattered for a specific reason: once an image is a sequence of discrete tokens, generating one is no longer a computer-vision problem. It is a language-modeling problem, and by 2020 language modeling had a proven scaling recipe — GPT-3, a 175-billion-parameter transformer trained on internet text, had just demonstrated that making an autoregressive transformer bigger and feeding it more data reliably made it better, with no architectural changes required.

A third thread supplied a missing tool rather than a missing architecture. CLIP, released in January 2021, trained an image encoder and a text encoder jointly with a contrastive objective on hundreds of millions of image-caption pairs scraped from the internet, producing a shared embedding space in which a matching image and caption land close together and a mismatched pair lands far apart (CLIP: Bridging Text and Image). CLIP was not built to generate anything. It was built to score — to answer “how well does this image match this caption” for any image and any caption, without task-specific fine-tuning. A model with that scoring ability, released the same month as a wave of new generative work, was exactly the missing piece both halves of this chapter would reach for, in two different ways.

Diffusion itself, meanwhile, had just proven it could produce images at all without a discriminator: DDPM matched GAN-level quality on unconditional CIFAR-10 generation in June 2020 (Diffusion Foundations), but as of early 2021 nobody had yet pointed a diffusion model at open-ended natural-language captions.

Two lineages and one shared tool converge on text to image By December 2021 both a proven scaling recipe and a proven denoiser exist; only the backbone choice is still open. Grey monospace text is the chapter's number for that moment. 2020-05 GPT-3 scaling transformers works 175B params, no new arch 2020-06 DDPM diffusion matches GANs unconditional CIFAR-10 2021-01 CLIP scores any image, caption the missing scoring tool 2021-02 DALL-E tokens plus a transformer 12B params 2021-05 ADM guidance beats GANs ImageNet, classifier guided 2021-12 GLIDE text guided diffusion this chapter's second half autoregressive, token based diffusion, denoising based a shared scoring tool, not a generator Two backbones reach the same brief at the same lab within the same year.
Two backbones reach the same brief at the same lab within the same year, with CLIP as a shared tool neither one needed to exist. PNG ↓

The question the field had not yet answered was architectural, not conceptual: everyone agreed that text-to-image generation at GPT-3 scale was worth attempting, and that some way of scoring or conditioning on CLIP’s shared embedding space would help. What nobody knew in early 2021 was which generative backbone — the discrete-token autoregressive transformer that language modeling had already proven at scale, or the denoising diffusion process that had just matched GANs without a discriminator — would carry that scale furthest.

The Breakthrough

DALL-E (Ramesh et al., 2021) answered by reusing the VQ-VAE playbook from Pixels One at a Time almost unchanged, at a much larger scale. Training happened in two stages. Stage one trained a discrete variational autoencoder (dVAE) — the same discrete-codebook idea as VQ-VAE, optimized here with a Gumbel-softmax relaxation rather than a straight-through estimator — to compress a 256×256 RGB image into a 32×32 grid of tokens, each token one of 8,192 codebook entries. Stage two froze that dVAE and trained a 12-billion-parameter, GPT-3-styled decoder-only transformer — 64 self-attention layers, using row, column, and convolutional sparse-attention patterns across its layers to keep the cost of attending over a long sequence manageable — on a single concatenated stream of up to 256 BPE-encoded text tokens followed by the 1,024 image tokens from stage one, 1,280 tokens total. The transformer’s only job, exactly as in any autoregressive language model, was to predict each token in that stream from everything before it. Training data was 250 million text-image pairs collected from the internet.

Generation ran that transformer forward from a caption, sampling image tokens one at a time, then decoded the sampled 32×32 grid back into pixels through the dVAE’s decoder. Because sampling is stochastic, the same caption could produce many different completions, and DALL-E’s paper reported results generated with reranking: draw up to 512 candidate images per caption, then use CLIP — released by the same lab one month earlier — to score how well each candidate matched the caption, and keep the top-scoring ones. Nothing about the transformer itself required CLIP; CLIP’s role was purely a post-hoc filter, picking the best of many autoregressive rolls of the dice.

DALL-E turns text-to-image into a language modelling problem A frozen image tokenizer and an ordinary autoregressive transformer, with CLIP only reranking afterward. Grey monospace text is the paper's own scale for that stage. dVAE encoder 256x256 image to tokens 32x32 grid, 8192 vocab Caption up to 256 BPE tokens feeds the same token stream 12B transformer one stream: caption tokens then 1024 image tokens 64 layers, sparse attention Sample tokens 1024 tokens, one at a time autoregressive, stochastic dVAE decoder tokens back to pixels same frozen network CLIP reranks scores up to 512 candidates keeps the best caption match a post-hoc filter only Final image the top-ranked candidate one of up to 512 rolls trained once, frozen input data the autoregressive transformer a post-hoc judgement, not training
Text-to-image becomes a language modelling problem once an image has a token vocabulary. CLIP only reranks afterward; it never trains the transformer. PNG ↓

The result was a model that had never been trained on MS-COCO’s captions at all, evaluated in a genuinely zero-shot setting, reaching an FID on that benchmark within two points of the best prior approach trained specifically for it. Against DF-GAN, the strongest contemporary GAN baseline in the paper’s own comparison — a direct descendant of the StackGAN and AttnGAN lineage from First Words to Pictures — human evaluators picked DALL-E’s samples as more realistic 90% of the time and as the better caption match 93% of the time. The autoregressive, discrete-token recipe that language modeling had already proven at scale worked for images too, once an image had a token vocabulary to be autoregressive over.

GLIDE (Nichol et al., 2021), submitted ten months later by an overlapping set of authors at the same lab, asked whether the same problem could be solved without tokenizing the image at all. Its name, spelled out in the paper, is Guided Language to Image Diffusion for Generation and Editing, and its architecture is the ADM-style guided diffusion U-Net from Guidance — with one substitution: instead of conditioning on a fixed label yy from a thousand-class vocabulary, GLIDE conditions on an arbitrary caption. A transformer text encoder (24 residual blocks, width 2048) reads the caption; its final token’s embedding is used the way a class embedding is used elsewhere in the ADM architecture, and the full sequence of token embeddings from its last layer is made available to the diffusion U-Net as extra context at every attention layer, letting the denoising network draw on individual words rather than only a single pooled vector — the same instinct AttnGAN’s word-region attention captured for GANs in First Words to Pictures, now running inside a denoising network rather than a generator. (The formal cross-attention mechanism that later diffusion models use for text conditioning is developed in full in Latent Diffusion and Stable Diffusion; GLIDE’s version is an earlier, less formalized instance of the same idea.) The base model has 3.5 billion parameters — 2.3 billion in the diffusion U-Net, 1.2 billion in the text transformer — trained for 2.5 million iterations at batch size 2,048, plus a separate 1.5-billion-parameter diffusion model that upsamples the base model’s output from 64×64 to 256×256.

GLIDE conditions a diffusion U-Net on a caption, not a class The text transformer's output feeds the same U-Net every step; guidance nudges the mean before the loop repeats. Grey monospace text names the paper's scale for that stage. Caption the text prompt arbitrary natural language Text transformer 24 residual blocks width 2048 Final token embedding used like a class label a single pooled vector Full token sequence extra attention context every word, every layer Noisy image xt current diffusion state 64x64 base resolution ADM diffusion U-Net 2.3B parameters 3.5B total with text encoder Guidance classifier-free, default preferred over CLIP guidance Reverse diffusion step writes the next xt-1 feeds back into the loop text and image inputs text encoder two conditioning signals from one encoder denoising network and its guidance
GLIDE swaps DALL-E's discrete tokens for a denoising loop conditioned on the same text encoder's output twice over, once pooled and once per word. PNG ↓

The paper’s central experiment compared two ways of steering that diffusion process, both descended from the guidance mechanisms taught in full in Guidance: classifier-free guidance, whose formula that chapter already develops, and a text-native adaptation of classifier guidance that substitutes a CLIP alignment score for a classifier’s log-probability — the new mechanism this paper contributes, developed with its own equation below. Human evaluators preferred classifier-free guidance’s outputs over CLIP guidance’s on both photorealism and caption match, and GLIDE shipped with classifier-free guidance as its default — the paper’s authors note this finding surprised them, since CLIP guidance seemed the more direct way to bring CLIP’s text-image alignment signal into the sampling loop. Against DALL-E itself, at matched 256×256 resolution, human evaluators preferred GLIDE’s samples for photorealism 87% of the time and for caption similarity 69% of the time — a result the paper frames explicitly against parameter count: “GLIDE was trained with roughly the same training compute as DALL-E but with a much smaller model (3.5 billion vs. 12 billion parameters).” The diffusion recipe, with guidance, beat the autoregressive recipe at roughly a quarter of the parameters, for similar training compute.

GLIDE also demonstrated an editing capability neither DALL-E nor any prior text-to-image GAN offered as a first-class feature: fine-tuning the same diffusion model for text-driven inpainting, by erasing random regions of training images and feeding the model the remaining pixels plus a mask channel as additional conditioning, alongside the caption. The resulting model could take a real photograph, an erased region, and a text prompt, and fill in only that region consistently with the prompt and the surrounding pixels — the direct ancestor of the editing techniques covered in Editing. For public release, OpenAI trained and shipped a smaller, 300-million-parameter model, GLIDE (filtered), on a newly gathered dataset of several hundred million images — deliberately kept disjoint from the dataset used to train the base model, DALL-E, and CLIP — with images of people, violent content, and hate symbols filtered out before training, rather than releasing the full 3.5-billion-parameter model — an early instance of a safety trade-off, shipping a weaker model rather than the strongest one trained, that recurs throughout this book’s later chapters on evaluation and provenance.

The Mathematics

DALL-E’s two-stage training is justified by a single evidence lower bound over the joint distribution of an image xx, its caption yy, and the dVAE’s discrete image tokens zz, factorized as pθ,ψ(x,y,z)=pθ(x∣y,z) pψ(y,z)p_{\theta,\psi}(x,y,z) = p_\theta(x \mid y,z)\,p_\psi(y,z). Notation follows Ramesh et al. (2021); the general evidence-lower-bound idea this instantiates is taught in full in Variational Autoencoders.

ln⁡pθ,ψ(x,y)  ≥  Ez∼qϕ(z∣x)[ln⁡pθ(x∣y,z)  −  β DKL(qϕ(y,z∣x) ∥ pψ(y,z))]\ln p_{\theta,\psi}(x,y) \;\ge\; \mathbb{E}_{z \sim q_\phi(z \mid x)}\Big[\ln p_\theta(x \mid y,z) \;-\; \beta\, D_{\mathrm{KL}}\big(q_\phi(y,z \mid x)\, \|\, p_\psi(y,z)\big)\Big]
SymbolMeaning
xxThe original RGB image
yyThe caption, as BPE text tokens
zzThe dVAE’s discrete image tokens, a 32×32 grid over an 8,192-entry codebook
qϕ(z∣x)q_\phi(z \mid x)The dVAE encoder
pθ(x∣y,z)p_\theta(x \mid y,z)The dVAE decoder, reconstructing xx from tokens
pψ(y,z)p_\psi(y,z)The stage-two transformer’s joint model over captions and tokens
β\betaWeight on the KL term; 6.66.6 in practice, though the bound is exact only at β=1\beta=1

GLIDE’s CLIP-guided sampling is the text-conditioned, contrastive-score version of the classifier guidance formula taught in full in Guidance; the only change is what supplies the gradient. Where classifier guidance uses a trained classifier’s log-probability of a class, GLIDE substitutes the dot product between a CLIP image embedding and a CLIP text embedding:

μ^θ(xt∣c)=μθ(xt∣c)+s Σθ(xt∣c) ∇xt(f(xt)⋅g(c))\hat{\mu}_\theta(x_t \mid c) = \mu_\theta(x_t \mid c) + s\,\Sigma_\theta(x_t \mid c)\,\nabla_{x_t}\big(f(x_t) \cdot g(c)\big)
SymbolMeaning
xtx_tThe noisy image at diffusion step tt
ccThe caption, the conditioning signal
μθ,Σθ\mu_\theta, \Sigma_\thetaThe diffusion model’s predicted reverse-step mean and variance
f(⋅)f(\cdot)CLIP’s image encoder
g(⋅)g(\cdot)CLIP’s text encoder
ssThe guidance scale
∇xt\nabla_{x_t}Gradient with respect to the noisy image, computed by backpropagating through ff

What It Enabled

The two papers left the field with a working comparison between backbones at similar training compute, not just similar ambition:

DALL-E, Feb 2021GLIDE, Dec 2021Prior GAN lineage (DF-GAN)
Generative mechanismAutoregressive transformer over dVAE tokensGuided diffusion U-NetAdversarial generator/discriminator
Parameters12 billion3.5 billion base, plus 1.5 billion upsamplerTens of millions, typical for the era
Training data250 million text-image pairsSame 250 million pairs as DALL-E; filtered public release trained on a separate, disjoint set of several hundred million imagesNarrow, curated caption datasets
Conditioning signalCaption tokens, concatenated into the input sequenceCaption, via a transformer encoder feeding the U-NetPooled or per-word text embeddings
Editing / inpainting supportNot a first-class featureYes, via dedicated fine-tuningNot a first-class feature
Human preference vs. DALL-E (photorealism / caption match)—87% / 69% preferred—
Human preference vs. DF-GAN (photorealism / caption match)90% / 93% preferred——

Neither backbone won outright. DALL-E demonstrated that the token-plus-transformer recipe language modeling had already validated at GPT-3 scale transferred directly to images once VQ-VAE-style tokenization existed to carry it. GLIDE demonstrated that a smaller, guided diffusion model, trained on comparable compute, produced samples people preferred over DALL-E’s on both axes tested — and that diffusion, unlike the autoregressive route, came with a natural mechanism for text-driven editing built from the same training objective. Both results reached the same lab within the same year, and both fed directly into what followed: DALL-E 2, covered in The Year Images Went Mainstream, replaced DALL-E’s autoregressive backbone with a diffusion model conditioned on CLIP image embeddings — abandoning the architecture of its own predecessor in favor of GLIDE’s — while keeping CLIP-based reranking’s underlying instinct that a contrastive scorer is useful at generation time, not just for retrieval. Imagen, released the same year, followed GLIDE’s guided-diffusion structure with a much larger frozen text encoder in place of GLIDE’s jointly trained one. And running the same guided-diffusion recipe inside a pretrained autoencoder’s compressed latent space, rather than raw pixel space, is what made Stable Diffusion’s open-weights release affordable to train and run at consumer scale, covered in Latent Diffusion and Stable Diffusion.

The diffusion branch outgrows its own sibling GLIDE's guided-diffusion recipe feeds four later systems; DALL-E's autoregressive tokens go dormant until chapter 20. Grey monospace text names where each descendant is covered. DALL-E, 2021-02 autoregressive tokens this chapter GLIDE, 2021-12 guided diffusion this chapter DALL-E 2 diffusion plus CLIP embeddings covered in chapter 14 Latent diffusion Stable Diffusion's backbone covered in chapter 13 Imagen larger frozen text encoder same guided-diffusion recipe Editing and inpainting text-driven mask fill covered in chapter 17 Autoregressive returns a different token scheme covered in chapter 20 the autoregressive branch the guided-diffusion branch a descendant system
Guided diffusion outgrows its own sibling within the year. The autoregressive branch does not disappear, but it waits until chapter 20 to return. PNG ↓

The autoregressive branch did not disappear after this year — it returned with a different token scheme in later work covered in The Current Frontier — but for the rest of this book’s Part II, the guided-diffusion recipe GLIDE demonstrated is the one every major shipped text-to-image system builds on.

Key Papers

PaperAuthorsYearLinkWhy it matters
Zero-Shot Text-to-Image GenerationRamesh, Pavlov, Goh, Gray, Voss, Radford, Chen, Sutskever2021arXiv:2102.12092Scaled the VQ-VAE-plus-autoregressive-transformer recipe to 12 billion parameters and 250 million text-image pairs; introduced CLIP reranking of sampled candidates
GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion ModelsNichol, Dhariwal, Ramesh, Shyam, Mishkin, McGrew, Sutskever, Chen2021arXiv:2112.10741Applied guided diffusion to open-ended text conditioning; showed classifier-free guidance preferred over CLIP guidance; preferred over DALL-E in human evaluation at under a third of the parameters; added text-driven inpainting

PM Lens

Papers referenced