Diffusion · Multimodal

DALL-E 2 (unCLIP): Hierarchical Text-Conditional Image Generation with CLIP Latents

Turn the caption into a CLIP image embedding first, then decode that embedding into pixels.

unCLIP splits text-to-image generation into two stages: a prior predicts the 1,024-number CLIP image embedding of a matching picture, and a diffusion decoder paints pixels from that vector.

Explaining the paperHierarchical Text-Conditional Image Generation with CLIP LatentsRamesh, Dhariwal, Nichol, Chu, Chen · OpenAI, April 2022 · arXiv:2204.06125 ↗
Listen22 min narrated explainer0:00 / 22:10

Fixing what the scene shows in an embedding before any pixel is drawn lets classifier-free guidance sharpen image quality without collapsing every sample onto the same pose, and turns any existing photograph into a pair of latents you can vary, blend, or edit with text.

Two stages instead of one

OpenAI's earlier text-to-image diffusion model, GLIDE (December 2021), goes straight from words to pixels: a 3.5-billion-parameter network reads a caption and denoises a 64×64 image directly. That one-stage design faces a sharp trade-off. Sample without guidance and the images are varied but blurry or loose on the prompt. Turn up guidance so every picture looks crisp and faithful to "a green vase filled with red roses sitting on top of table", and the camera angle, lighting, and vase shape converge until every generation looks nearly identical.

unCLIP breaks that coupling by inserting a compact semantic representation between the caption and the pixels. Let be an image, its text caption, and the 1,024-number vector produced when you pass through CLIP's image encoder. Because that encoder is a fixed deterministic function, knowing the image already determines with certainty. Adding a deterministic function of to the event does not change its probability, so equals the joint probability , which the chain rule splits into two factors:

(1)

Each factor on the right of (1) becomes its own trained generative model. The prior maps a caption to a plausible CLIP image embedding, choosing what objects, composition, and style the scene will have before a single pixel is drawn. The decoder takes that embedding (and, optionally, the caption) and renders an image that would produce it. Generation runs the two models in order: draw from the prior, then draw from the decoder. If both distributions were learned exactly, the resulting images would be exact samples from . Because the decoder runs CLIP's image encoder in reverse, the authors call the full system unCLIP.

What a CLIP embedding holds

CLIP (Contrastive Language-Image Pre-training) is a pair of neural encoders trained together on hundreds of millions of web images and their captions. One encoder maps an image to a vector ; the other maps a caption to a vector of the same length. Both outputs are normalized to unit length, so every image and every caption becomes a point on the surface of a high-dimensional sphere. Given a training batch of paired images and captions, contrastive training raises the dot product (the cosine of the angle between unit vectors) for every matched pair and pushes down the dot product for every mismatched pair in the batch. After training, a photo of a corgi in a party hat and the sentence "a photo of a corgi in a party hat" point in nearby directions.

unCLIP trains its own CLIP model rather than reusing the original public weights. Its image encoder is a ViT-H/16, a Huge Vision Transformer that cuts a 256×256 RGB image (196,608 pixel values) into 16×16-pixel patches and passes them through 32 Transformer blocks of width 1,280. Its text encoder is a 24-block causal Transformer of width 1,024. Both output 1,024-dimensional embeddings. The pair trains on roughly 650 million images drawn equally from the CLIP and DALL-E datasets, with learning rate and SAM (Sharpness-Aware Minimization, an optimizer that evaluates gradients at a perturbed point a radius away on each batch-64 replica so training settles in flatter loss valleys). Once CLIP is trained, its weights stay frozen throughout the rest of the pipeline.

Compressing 196,608 pixel values into 1,024 numbers under a caption-matching objective forces CLIP to be selective. To match an image to its caption out of thousands of distractors, the encoder has to preserve semantics and visual style: which objects appear, what they are doing, and whether the picture is a photograph, an oil painting, or a line drawing. It does not need to store whether a dog faces left or right, where shadows fall, or the exact background clutter, because those details rarely distinguish one caption from another. Consequently, many visually distinct images map to nearly the same , leaving exact layout, lighting, and fine texture for the decoder to fill in.

How unCLIP generates an image

Typing a prompt runs five neural networks in sequence: the frozen CLIP text encoder, the prior, the 64×64 decoder, and two super-resolution upsamplers. (CLIP's image encoder is used only during training and when encoding a real photo for editing.) Figure 1 traces the tensor flowing out of each stage. Notice two structural details in the diagram: the dashed grey box marks the frozen CLIP encoder, and the dashed amber line shows the caption taking a second path directly into the 64×64 decoder. Select any stage to inspect its exact architecture, training objective, and inference step count.

Figure 1 · the unCLIP stack
Diffusion prior (trained, 1B parameters). A decoder-only Transformer, width 2048, 24 blocks. Its input sequence is the encoded caption, z_t, a timestep embedding, the noised image embedding z_i^(t), and one extra slot whose output is the prediction of the clean z_i. Loss: mean squared error to the true z_i, eq. (4). Sampling: 64 Analytic-DPM steps, run twice; the sample with the larger dot product z_i · z_t is kept. The text conditioning is dropped 10% of the time in training so guidance is possible.
The sampling chain with the paper's model sizes and step counts (Table 3). The dashed box is frozen. The dashed amber line shows the caption's second route into the decoder alongside . Click any stage or button to inspect what it computes and how it was trained.

The word "hierarchical" in the paper's title refers to this three-level cascade: the 1B-parameter prior commits to semantic content as one 1,024-number vector, the 3.5B-parameter decoder turns that vector into a coarse 64×64×3 canvas, and the 700M and 300M upsamplers add high-frequency detail up to 256×256 and 1024×1024 without reading the caption. Together the four trained models contain about 5.5 billion parameters, trained only on the 250-million-image DALL-E dataset; mixing in the noisier CLIP dataset hurt sample quality in early tests. All metrics and Table 3 settings on this page belong to these paper models, not the separately trained production DALL-E 2 model shown in the paper's Figure 1.

How the decoder turns an embedding into pixels

The decoder is a diffusion model. During training, you take a 64×64×3 training image (12,288 pixel numbers), pick a random step between 1 and 1,000, add Gaussian noise scaled by a cosine schedule, and train a neural network to predict the noise that was mixed in. At generation time, you start from 12,288 random Gaussian numbers and repeatedly subtract the predicted noise over hundreds of steps until an image takes shape (the DDPM explainer works through this forward and reverse process in detail).

Rather than inventing a new image backbone, the authors start from GLIDE's 3.5-billion-parameter base model: a 64×64 U-Net (a convolutional encoder-decoder with skip connections and self-attention at 32×32, 16×16, and 8×8 resolutions, 512 base channels, roughly 2.3 billion parameters) paired with a 24-block, width-2,048 text Transformer (256-token context, 32 heads, roughly 1.2 billion parameters). To condition this network on , they modify it in two places:

  1. A learned linear layer projects and adds it to the timestep embedding that enters every residual block of the U-Net, broadcasting the global semantic summary across every spatial resolution.
  2. A second linear projection maps into four extra context tokens appended to the 256 token outputs from the GLIDE text encoder, so every attention layer in the U-Net attends over 260 conditioning entries alongside its own image positions.

In one training step, a 64×64×3 image and its caption enter the pipeline. The frozen CLIP image encoder computes (shape 1,024); the image is noised to a random step ; and the U-Net predicts both the added noise and the reverse-step variance, using the learned-variance objective from Improved DDPM. Gradients update the U-Net and its text encoder with batch size 2,048, learning rate , dropout 0.1, and Adam with decoupled weight decay over 800,000 iterations; CLIP never receives a gradient. At sampling time, the decoder runs 250 evenly spaced ("strided") steps out of the 1,000 training levels.

During training, the authors randomly replace with zeros (or a learned null vector) 10% of the time and drop the text caption 50% of the time. If those two drops are independent, 45% of steps see both and the caption, 45% see only , 5% see only the caption, and 5% see neither. Keeping GLIDE's text pathway was meant to help the decoder capture linguistic relations that CLIP drops, though the authors report in Section 7 that it provided little help. Dropping conditioning during training lets one network produce both a conditional noise prediction and an unconditional prediction at test time. Subtracting the unconditional prediction from the conditional one isolates how much the conditioning shifts the denoising direction, and classifier-free guidance extrapolates along that shift by a scale :

(2)

In (2), bundles the active conditioning ( and the caption), is the dropped conditioning, and follows GLIDE's convention where recovers ordinary conditional sampling and pushes past it away from generic unconditional images. Each guided step costs two forward passes through the 3.5B decoder. Raising sharpens edges, lighting, and fidelity to while narrowing the range of outputs the sampler visits, a trade-off covered in the guidance-and-diversity section below.

To reach 1024×1024 pixels, two smaller diffusion upsamplers follow the decoder. Both use ADMNet (the Ablated Diffusion Model U-Net from Diffusion Models Beat GANs) with spatial convolutions only and no attention layers, which lets them train on random crops one-fourth the target width (64×64 crops for the 256×256 model, 256×256 crops for the 1024×1024 model) and generalize straight to full images at inference without quadratic attention cost. Because real generated 64×64 images contain small imperfections that uncorrupted downsampled photos lack, each upsampler trains on deliberately corrupted low-resolution inputs: a 3×3 Gaussian blur () for the 700M 64→256 stage (320 channels, depth 3, cosine schedule) and BSR degradation (Blind Super-Resolution: random blur, resizing, noise, and JPEG compression) for the 300M 256→1024 stage (192 channels, depth 2, linear schedule). Caption conditioning did not improve either upsampler, so both run unguided using DDIM (Denoising Diffusion Implicit Models, a fast deterministic sampler) for 27 and 15 steps respectively.

How the prior maps captions to image embeddings

With only the decoder trained, unCLIP is an image autoencoder whose encoder is CLIP. Turning a text prompt into an image requires producing a plausible from the caption . Why not skip training a 1-billion-parameter prior and hand the decoder the caption's CLIP text embedding directly, since CLIP was already trained to align and ?

Two geometric obstacles block that shortcut. First, the mapping from text to images is one-to-many: a single caption such as "a corgi in a party hat" matches close-ups, wide shots, photographs, and oil paintings, each with a different image embedding , whereas the caption produces only one deterministic . Second, CLIP's text and image embeddings do not share the same patch of the sphere. Liang et al. (2022) measured a persistent "modality gap" in contrastive models: image vectors cluster in one region of the unit sphere and text vectors cluster in another, so even a matched pair sits far apart in Euclidean distance and handing to a decoder trained exclusively on gives it an out-of-distribution input.

The prior solves both problems by learning the full conditional distribution over the image-embedding region of the sphere. Figure 2 compresses CLIP's 1,024-dimensional unit sphere down to three dimensions so you can see the separation between text embeddings (amber) and image embeddings (teal). Click sample the prior to draw candidates for the chosen caption, then toggle best of two to compare single draws against the paper's two-sample selection rule.

Figure 2 · what the prior samples
A toy 3-D slice of CLIP space. Faint teal dots are image embeddings and faint amber dots are text embeddings in a separate cap. For the chosen caption, the bright amber dot is and bright teal dots are prior draws. With best of two on, each draw samples two vectors (hollow circle dropped) and keeps the one with the larger dot product . Dot products are the toy's, not CLIP's.

The paper tests the shortcut quantitatively on small models using FID (Fréchet Inception Distance, which compares the mean and covariance of generated and real images inside an Inception classifier's feature space, capturing both realism and diversity; lower is better). Feeding zero-shot to the unCLIP decoder scored an FID of 16.55. Training a small decoder from scratch directly on CLIP text embeddings improved that to 9.16. Adding a diffusion prior to form a small unCLIP stack lowered FID further to 7.99, and in human side-by-side ratings between the text-embedding decoder and the full unCLIP stack, raters preferred unCLIP 57.0% ± 3.1% of the time for photorealism and 53.1% ± 3.1% for caption similarity.

The diffusion prior

The paper's stronger prior applies Gaussian diffusion directly to the 1,024-number continuous vector instead of to a grid of pixels. Over steps of a cosine noise schedule, a signal retention factor falls smoothly from 1 down to near 0, blending the unnoised embedding with standard Gaussian noise:

(3)

At step , (3) multiplies the embedding by and adds unit-variance Gaussian noise multiplied by . That schedule was calibrated for ImageNet RGB pixel values scaled to , where a typical pixel coordinate has variance around 0.3. A unit-length 1,024-dimensional CLIP embedding has coordinates whose squares sum to 1, so assuming unit norm before scaling, a typical coordinate has root-mean-square magnitude only (variance 0.00098). Plugging that tiny vector straight into (3) destroys the signal almost immediately: the signal-to-noise ratio (SNR) drops below 0 dB (equal signal and noise power) at step out of 1,000, leaving over 98% of the noise schedule spent on pure static. Appendix C fixes this by multiplying the CLIP embedding inputs by 17.2 before adding noise, which lifts typical coordinate magnitude (under the unit-norm assumption) to (variance 0.289, matching ImageNet pixels) and multiplies the SNR at every step by (+24.7 dB).

Figure 3 lets you verify that shift directly. At the default step , compare the unscaled (1×) and paper (17.2×) presets: the SNR curve on the left jumps from −18.1 dB (1.5% signal variance) to +6.6 dB (82% signal variance), and the 24-coordinate slice on the right switches from amber signal bars drowned in teal noise to a clearly recoverable pattern.

Figure 3 · why the prior scales embeddings by 17.2
17.2×
t = 150
Exact cosine-schedule SNR (left) and a 24-coordinate slice of a 1,024-D unit-norm embedding (right) under eq. (3). Amber bars show the scaled signal component , where is the embedding scale factor (1 for unscaled, 17.2 in the paper); teal bars show the noised vector . Toggle 1× vs 17.2× or play the sweep to watch when the embedding disappears into noise.

At scale 17.2×, the 0 dB crossover moves from to , and even at halfway through the schedule () 22% of the variance is still signal, giving the denoiser a full coarse-to-fine ramp to learn across all 1,000 steps.

The denoiser is a 1-billion-parameter decoder-only causal Transformer (24 blocks, width 2,048, 32 heads) that reads a 260-position sequence in order: 256 encoded caption tokens, one projected , one timestep embedding for , one projected noised embedding , and one final query slot whose output predicts the unnoised vector . Where DDPM trains the network to predict the added noise , the authors report empirically that predicting the unnoised directly with plain mean-squared error performed better (they offer no theoretical explanation for why):

(4)

In (4), is the forward noising distribution from (3), takes the noisy vector, timestep, and caption conditioning, and the loss measures squared Euclidean distance to the target . Training uses batch size 4,096 for 600,000 iterations, learning rate , weight decay , and drops text conditioning 10% of the time so classifier-free guidance is available. A single training step, with tensor shapes:

# One training step of the diffusion prior (all CLIP weights frozen)
x, y   = batch()                          # x: [B, 3, 256, 256], y: text
z_i    = 17.2 * clip_image(x)             # [B, 1024] scaled target embedding
z_t    = 17.2 * clip_text(y)              # [B, 1024] scaled caption embedding
t      = randint(1, 1000, size=(B,))      # [B] cosine schedule step
eps    = randn(B, 1024)                   # [B, 1024] Gaussian noise
z_noisy = sqrt(abar[t]) * z_i + sqrt(1 - abar[t]) * eps        # eq. (3)
if rand() < 0.10:                         # drop text conditioning for guidance
    y, z_t = EMPTY, NULL_EMB
seq = [*text_encoder(y),                  # [B, 256, 2048] caption tokens
       proj(z_t), time_emb(t),            # [B, 1, 2048] + [B, 1, 2048]
       proj(z_noisy), query]              # [B, 1, 2048] + [B, 1, 2048] -> 260
h = prior_transformer(seq, causal=True)   # [B, 260, 2048], 24 causal blocks
z_pred = out(h[:, -1])                    # [B, 1024] read final slot
loss = mean((z_pred - z_i) ** 2)          # eq. (4): predict clean z_i, not eps
loss.backward()                           # gradients update the prior only

At sampling time, the diffusion prior runs 64 strided steps with Analytic-DPM (Bao et al., 2022), a sampler that computes the optimal reverse noise variance at each step in closed form. Rather than accepting the first draw, unCLIP samples two candidate embeddings and keeps whichever has the larger dot product with the caption. If a single draw's dot product were Gaussian with standard deviation , taking the maximum of two independent draws shifts the mean upward by (visible in Figure 2's 4,000-draw readout). Although the prior supports classifier-free guidance, the authors found in their aesthetic study (Section 5.5) that guiding the prior hurt quality, so there they guide only the decoder.

The autoregressive prior

The paper also tests an autoregressive (AR) prior that predicts one discrete token at a time like a language model. Predicting 1,024 continuous numbers sequentially is slow, so the authors first compress with PCA (Principal Component Analysis, which rotates the coordinate axes so they are ordered from highest variance across the dataset to lowest). A surprising side effect of training CLIP with SAM was that the representation space collapsed to a much lower effective rank while slightly improving metrics: keeping just 319 of the 1,024 principal components reconstructs with under 1% average mean-squared error, a (threefold) reduction in sequence length. Each of the 319 coordinates is quantized into 1,024 discrete buckets, and a 1B causal Transformer (24-block width-2,048 text encoder plus 24-block width-1,664 latent decoder, 26 heads, context 384) predicts them in decreasing-eigenvalue order conditioned on the caption and as a prefix.

To steer the AR prior toward tighter prompt alignment, the authors prepend one extra prefix token: the quantized dot product of the training pair. At sampling time, they sample that token from the top half of the distribution (sweeping the 50th, 70th, 85th, and 95th percentiles showed 50% was optimal in every experiment), playing the same role that best-of-two selection plays for the diffusion prior. Across every benchmark in Sections 5.2, 5.4, and 5.5, the diffusion prior outperformed the AR prior at the same 1B parameter count and with less training compute (600,000 iterations against 1,000,000 at batch size 4,096).

Why guidance keeps unCLIP's diversity

To see why splitting generation into a prior and a decoder avoids GLIDE's diversity collapse, look at what classifier-free guidance does to a probability distribution. Scaling the conditioning shift in (2) by causes the sampler to approximate a "tilted" distribution:

(5)

At , the factor drops out and (5) is the unmodified conditional distribution. For , rewriting the right-hand side as shows what happens: regions that are far more likely under conditioning than under generic images get amplified by a power . Because amplification is exponential in , the most probable semantic cluster does not merely get sharper; it takes probability mass from every smaller cluster.

Suppose images matching a caption fall into four semantic views (front, side, top, and close-up) with probabilities , and the broad unconditional density is roughly flat across the four views. Raising each view's density to the power gives it a new share:

(6)

Plug in concrete shares of 45%, 28%, 17%, and 10%. At , the cubes are 0.0911, 0.0220, 0.0049, and 0.0010, which renormalize to 77%, 18–19%, 4%, and 1%. At , the front view takes 99% of the mass. When GLIDE guides directly on the caption, all four semantic views compete inside the same guided distribution, which is why the vase's angle, color, and size converge in the paper's Figure 9.

unCLIP guides only the decoder, whose conditioning is a single already sampled by the unguided prior. Because the high-level scene choice is already locked inside , guidance only sharpens the pixel rendering around that embedding and cannot pull a close-up sample over into the front-view cluster. Figure 4 compares both mechanisms on the same four-mode 2-D toy. Drag the guidance slider from 1 to 10 and watch the mode bars and effective modes (, the exponential of Shannon entropy, which equals 4 for four equal modes and 1 when a single mode takes over).

Figure 4 · guiding a caption vs guiding an embedding
s = 3.00
A toy 2-D image space with four semantic modes (45%, 28%, 17%, 10%). Left: GLIDE samples from the exact grid tilted density . Right: the unguided prior picks each sample's mode and only the decoder is guided. Bars show probability mass per mode; effective modes is . Real guided samplers only approximate the tilted density.

At , both panels start at 3.49 effective modes. At the default , GLIDE drops to 1.99 effective modes (bars 77%, 18%, 4%, 1%, matching rule (6) to within a percentage point), and at it collapses to 1.05. unCLIP holds steady at 3.48–3.49 effective modes at every guidance scale while each individual cluster tightens.

The paper's real-image measurements follow the same curve. Sweeping decoder guidance scale on MS-COCO (Microsoft Common Objects in Context, a standard benchmark of everyday captioned photos) raises unCLIP's FID far less than GLIDE's (paper Figure 11), because FID rises steeply when sample diversity collapses. In Section 5.5's aesthetic study, the authors generated 512 artistic captions with GPT-3, drew four images per caption (2,048 images total), and scored them with a linear probe on CLIP ViT-L/14 trained on human photo ratings from the AVA (Aesthetic Visual Analysis) dataset. Plotting aesthetic score against Recall (the fraction of the training distribution covered by generated samples, where higher means broader diversity) showed that raising decoder guidance improved aesthetic score for both models, yet for unCLIP Recall did not drop at all.

Variations, blends and text diffs

Because unCLIP pairs an image encoder (CLIP) with a generative inverse (the decoder), any real photograph can be split into a bipartite latent . The vector (1,024 numbers from CLIP's image encoder) stores the semantic content and style CLIP recognizes. The tensor (a 64×64×3 noise image, 12,288 numbers) stores every residual detail of layout and pixels the decoder needs to rebuild that specific photograph.

To obtain , the paper uses DDIM inversion (Dhariwal & Nichol, 2021, Appendix F). With its random noise switched off, a DDIM sampler is a deterministic map from noise to image . Running those same discrete equations backward from up to while conditioning the decoder on yields an that decodes back near . Because each reversed step assumes the network's noise prediction barely changes between adjacent timesteps, finite-step inversion is an approximation that reconstructs the input closely rather than exactly (the Provenance panel flags an overclaim in the paper's Figure 5 caption).

Variations

To produce variations of a real image that keep its core subject and style while changing pose, geometry, and fine details, you keep fixed, start from the inverted , and re-introduce controlled randomness during decoding. DDIM exposes a stochasticity knob in every reverse step from timestep down to :

(7)
(8)

In (7) and (8), is the decoder's noise prediction, is the unnoised image estimate implied by , is fresh standard Gaussian noise, and is the cumulative signal schedule (Song et al. write for the same quantity). Two endpoints bracket the behavior: when , and the random term vanishes, so decoding deterministically retraces the inversion path back to the input (up to inversion error). When , equals DDPM's full posterior standard deviation, injecting enough fresh noise to wash out the starting point so the reverse pass lands on an independent sample from . Intermediate values of preserve everything encoded in while letting the residual details stored in drift farther from the original.

Figure 5 simulates (7)–(8) in one dimension where is a mixture of four narrow modes representing four distinct images CLIP maps to the same embedding, using the exact posterior mean so only sampler dynamics remain. Sweep from 0 to 1 to watch the 14 teal decode paths peel away from the dashed amber inversion path, then slide into the empty gap between two modes to see how inversion breaks on an atypical input.

Figure 5 · variations from an inverted latent
η = 0.30
x₀ = 0.56
DDIM inversion (amber, dashed) and 14 decodes (teal) over 250 strided cosine steps as in unCLIP's decoder. At all paths retrace the inversion (header shows reconstruction error). Raise to spread across the four modes; drag between modes to test an atypical input.

At the default , the reconstruction lands within 0.0058 of the input, and by roughly one-quarter of the decodes remain in 's mode, matching fresh draws from four equal modes. Drag into a low-density gap between modes and the error jumps sharply, illustrating that DDIM inversion degrades when an image sits far from the decoder's high-density regions. On real images (paper Figure 3), variations of a surrealist painting preserve its clock and painting style, and variations of a logo preserve its overlapping strokes and color gradients, while redrawing exact layout and proportions.

Interpolations and text diffs

To blend two photographs and , unCLIP interpolates between their unit-length CLIP embeddings and . A straight-line blend cuts through the interior of the sphere: halfway between two perpendicular unit vectors, its norm shrinks to , shorter than the unit-length vectors the decoder trained on. Instead, unCLIP uses spherical linear interpolation (slerp), which moves along the great-circle arc on the unit sphere at constant angular speed:

(9)

Here and are unit vectors separated by angle . At the formula returns , at it returns , and at every intermediate the vector stays at length 1.000, rotated by angle from . For the residual noise , the paper notes two options: slerping between the two inverted latents and reproduces both original photos at and 1, whereas fixing one randomly drawn across the sequence (the choice shown in paper Figure 4) yields many possible blend trajectories whose endpoints are new variations of the two inputs.

Text diffs apply the same rotation to language-guided image editing. Compute the CLIP text embedding of a caption describing the current image ("a photo of a cat") and of the target description ("an anime drawing of a super saiyan cat, artstation"). Their normalized difference defines an edit direction , and slerp rotates the image's embedding toward it:

(10)

Each is decoded using the original image's inverted with so layout stays anchored while content shifts toward the prompt. The authors increase linearly from 0 up to a maximum typically between 0.25 and 0.50 (Footnote 3 notes that a dummy baseline such as "a photo", or dropping altogether, also worked well). Because slerp never leaves the 2-D plane spanned by its two endpoint vectors, Figure 6 renders that cross-section of the 1,024-dimensional unit sphere without approximation.

Figure 6 · spherical interpolation in CLIP space
θ = 0.40
90°
Exact 2-D plane through the two endpoint vectors and the unit circle in it. Teal: slerp point , always norm 1. Violet: straight-line blend on the chord. In text-diff mode, the amber band marks the paper's 0.25–0.50 range. Adjust and the angle between endpoints to compare rotation and chord shrinkage.

At 90° and , slerp rotates 36° toward (cosine 0.809 with , 0.588 with ) at norm 1.000, while the linear blend sags to norm 0.721. At (45°), both cosines equal 0.707. The paper stops by 0.50 because is a normalized difference of text embeddings rather than an image embedding; pushing toward 1 feeds the decoder a direction far from any real image embedding. Since the paper does not report typical 1,024-D angles between and , the angle slider lets you test how much rotation the same produces across different separations.

Using the decoder to probe CLIP

Decoding a CLIP image embedding several times turns the decoder into a diagnostic lens: features that stay fixed across every draw are stored inside , while features that change are not. The authors apply this lens to two experiments in Section 4.

First, they test typographic attacks discovered by Goh et al. (2021), where pasting a paper note reading "iPod" onto a Granny Smith apple tricks CLIP into classifying the photo as an iPod. On the paper's example (Figure 6), CLIP assigns 99.98% probability to "iPod", 0.02% to "Granny Smith", and 0% to "Pizza". Yet decoding that exact image embedding produces apples with high probability and never generates an iPod. (On the companion "pizza" attack, unCLIP's SAM-trained CLIP was less fooled than Goh et al.'s models, assigning 94.33% to "Granny Smith" and 5.66% to "Pizza".) The reconstructions show that the printed word did not erase the apple from ; it only skewed which caption won CLIP's dot-product comparison.

Second, they probe PCA truncations of real image embeddings (paper Figure 7). Projecting onto its first 20, 30, 40, 80, 120, 160, 200, and 320 principal components and decoding each truncation with DDIM on a fixed noise seed reveals a coarse-to-fine ordering: the first 20–40 components already establish broad scene semantics (food and a container), while higher components add specific object identities and shapes (tomatoes and a bottle). Because the autoregressive prior generates principal components in this exact decreasing-variance order, the sequence also visualizes what the AR prior decides first.

Results against GLIDE and on MS-COCO

Because automated metrics like FID do not always match human taste, the authors ran pairwise human evaluations against GLIDE on 1,000 captions from the MS-COCO validation set. Raters judged single image pairs for photorealism and caption similarity, and compared two 4×4 grids of 16 samples for the same caption to measure diversity (each task included a "Not sure" option). Before running the human study, sampling hyperparameters for every model were tuned using a CLIP ViT-L/14 logistic-regression proxy trained on 15,000 earlier pairwise ratings. Table 1 lists the probability that raters picked unCLIP over GLIDE (50% is a tie; 95% normal-approximation confidence intervals):

unCLIP priorPhotorealismCaption similarityDiversity
AR47.1% ± 3.1%41.1% ± 3.0%62.6% ± 3.0%
Diffusion48.9% ± 3.1%45.3% ± 3.0%70.5% ± 2.8%

With the diffusion prior, photorealism is a statistical tie with GLIDE (the interval 45.8% to 52.0% includes 50%), GLIDE keeps an edge on caption similarity (the interval stops at 48.3%), and raters judged unCLIP's 4×4 grids more diverse 70.5% of the time. Could GLIDE match that diversity simply by using a weaker guidance scale? The authors swept GLIDE's guidance scale in human comparisons (paper Figure 10) and found that at , GLIDE comes close to unCLIP on photorealism and caption similarity while still producing less diverse grids.

On zero-shot MS-COCO 256×256 FID (Table 2, where "zero-shot" means the model never trained on MS-COCO's training split, and "filtered" removes validation images near-duplicate to the training set, shrinking the reference batch and nudging FID slightly higher), unCLIP with decoder guidance scale 1.25 set a new zero-shot record:

ModelZero-shot FIDZero-shot FID (filtered)
DALL-E~28
LAFITE26.94
GLIDE12.2412.89
Make-A-Scene11.84
unCLIP, AR prior10.6311.08
unCLIP, diffusion prior10.3910.87

Models trained directly on MS-COCO score lower (LAFITE reaches 8.12 and Make-A-Scene 7.55), so 10.39 is a best mark among zero-shot models only. Compared with GLIDE, whose 3.5B backbone the unCLIP decoder reuses, adding the CLIP embedding stage cuts zero-shot FID from 12.24 to 10.39.

Where unCLIP fails

Compressing every prompt through a single 1,024-number CLIP vector and decoding first at 64×64 leaves three failure modes documented in Section 7 of the paper:

On safety, higher photorealism leaves fewer visual artifacts that distinguish generated images from real photographs, increasing the risk of deceptive content relative to GLIDE. The authors refer readers to Mishkin et al. (2022), the system card for the DALL-E 2 Preview (the first deployment of an unCLIP model), for a full risk analysis in deployment context.

Sampling, variations and text diffs in pseudocode

The listing below puts text-to-image sampling, image variations, and text diffs side by side with the paper's Table 3 step counts and tensor shapes, using descriptive function names because OpenAI released no official unCLIP implementation.

# Sampling one 1024x1024 image for caption y (paper models, App. C)
z_t = clip_text(y)                               # [1024] frozen CLIP text
cands = [diffusion_prior.sample(y, z_t, steps=64)  # [1024] Analytic-DPM
         for _ in range(2)]
z_i = max(cands, key=lambda z: dot(z, z_t))      # [1024] best-of-two pick
x64 = decoder.sample(z_i, y, steps=250,          # [3, 64, 64] 3.5B U-Net
                     guidance=s)                 # eq. (2), guided
x256 = up1.sample(x64, steps=27)                 # [3, 256, 256] DDIM, unguided
x1024 = up2.sample(x256, steps=15)               # [3, 1024, 1024] DDIM, unguided

# Image variation from a real 64x64 image x (Sec. 3.1)
z_i = clip_image(x)                              # [1024] frozen CLIP image
x_T = ddim_invert(decoder, x, cond=z_i)          # [3, 64, 64] approximate inverse
x_var = decoder.sample(z_i, x_T=x_T, eta=0.5)    # eqs. (7)-(8); eta=0 rebuilds x

# Text diff (Sec. 3.3): "a photo of a cat" -> "an anime drawing of a cat"
z_d = normalize(clip_text(y_new) - clip_text(y_now))  # [1024] eq. (10)
for th in linspace(0, 0.5, 6):
    z_th = slerp(z_i, z_d, th)                   # [1024] eq. (9), unit norm
    out = decoder.sample(z_th, x_T=x_T, eta=0)   # [3, 64, 64] fixed layout

Latent Diffusion (the basis of Stable Diffusion), posted four months before unCLIP in December 2021, also runs diffusion in a learned latent space rather than full-resolution pixels, but its latent is a spatial 2-D grid from an autoencoder trained to reconstruct pixels. That spatial grid keeps local geometry and object layout intact, whereas unCLIP's single 1,024-D CLIP vector trades spatial precision for semantic steering, zero-shot text diffs, and diversity under guidance.

Provenance Verified against primary literatureHow we verify
Ramesh, Dhariwal, Nichol, Chu & Chen (2022)Sec. 2 (method, P(x|y) factorization, prior loss), Sec. 3 (variations, interpolations, text diffs), Sec. 4 (CLIP probes), Sec. 5 (all results quoted here), Sec. 7 (limitations and risks), App. C and Table 3 (every parameter count, step count, learning rate and dropout rate on this page). Paper models, not the production DALL-E 2 model shown in its Figure 1.
No official unCLIP codeOpenAI released no unCLIP code. How z_i enters the decoder is read from the paper plus the official GLIDE code (openai/glide-text2im): text2im_model.py adds transformer_proj(xf_out[:, -1]) to the timestep embedding (emb = emb + xf_proj), and unet.py QKVAttention concatenates the projected text tokens to every attention layer's keys and values. The paper's four extra z_i tokens join that list.
Nichol et al. (2021), GLIDESec. 4 gives the 3.5B parameter split: a 64x64 ADM U-Net at 512 base channels (roughly 2.3B parameters) plus a 24-block, width-2048 text Transformer (roughly 1.2B). Table 2 defines the "filtered" MS-COCO validation split as purging validation images similar to training images. Guidance is written as eps(x|0) + s (eps(x|c) - eps(x|0)), so s = 1 means no guidance.
Song, Meng & Ermon (2020), DDIMEqs. 12 and 16: the eta-parameterized update and its noise scale, where Song et al. write alpha_t for the cumulative product written alpha-bar_t here. eta = 0 is deterministic; eta = 1 matches DDPM's posterior variance.
Dhariwal & Nichol (2021), App. FDDIM inversion: running the deterministic sampler backward is described as an approximation that "gives latents with reasonable reconstructions"; they reversed 249 of 250 steps because the last step added noise artifacts.
Liang et al. (2022)"Mind the Gap": CLIP's image and text embeddings occupy separate regions of the unit sphere (the modality gap). Used here to explain why z_t sits outside the decoder's training distribution; the unCLIP paper does not make this argument itself.
This page's arithmetic196,608 input pixels (256x256x3) and 12,288 decoder values (64x64x3); 1024/319 = 3.2 (the paper's "threefold" token reduction); conditional on unit-norm embeddings, coordinate RMS 1/sqrt(1024) = 0.031, 17.2 x 0.031 = 0.54, SNR gain 17.2^2 = 296 (+24.7 dB), and cosine-schedule SNR crossings (t = 14 vs t = 309; t = 150 shares 1.5% vs 82%); 260 prior and decoder attention positions; mode masses proportional to pi_k^s; E[max of two Gaussians] = mean + sigma/sqrt(pi); and the 10% x 50% = 5% independence reading of the dropout rates.
correctionTwo statements in the paper need correcting. (1) Figure 5's caption says DDIM inversion is used "to perfectly reconstruct the input image". Inversion runs a discretized deterministic sampler backward, assuming each step's noise prediction barely changes between neighboring noise levels; Dhariwal & Nichol, whose Appendix F the paper cites for the method, call the result an approximation with "reasonable reconstructions". The reconstruction is close, not exact. (2) Section 5.1 says the CLIP image embedding "is dropped 5% of the time during training", while Section 2.1 gives 10% for the embedding and 50% for the caption. The two agree if the drops are independent: 10% x 50% = 5% of steps keep the caption while losing the embedding, which matches the Figure 8 caption ("trained to do the text-to-image generation task (without the CLIP image representation) 5% of the time"). This page uses Section 2.1's rates.

Questions you might still have

?

Is unCLIP the same model as DALL-E 2?
DALL-E 2 is a production version of unCLIP. Every FID score, human-evaluation table, and hyperparameter in the paper (Appendix C, Table 3) comes from the paper models. The authors report that the production model uses similarly sized networks with modified architectures, longer training, a larger dataset filtered for aesthetic quality and safety, and product changes such as inpainting and memorization defenses. The 1024x1024 pictures in the paper's Figure 1 come from that production model.

?

Why not skip the prior and feed the CLIP text embedding straight to the decoder?
The authors tested both variants on small models. Feeding a CLIP text embedding zero-shot into an unCLIP decoder trained on image embeddings gave an FID of 16.55, against 7.99 with a diffusion prior. Training a decoder from scratch directly on CLIP text embeddings scored 9.16, and human raters still preferred the prior-plus-decoder stack 57.0% of the time for photorealism. One caption corresponds to many valid image embeddings, and text embeddings sit in a different region of CLIP's sphere from image embeddings.

?

Why does the diffusion prior predict the clean embedding instead of the noise?
The paper reports only the empirical finding that predicting z_i directly worked better than DDPM's noise-prediction objective. Given a noisy vector and its noise level, predicting clean z_i and predicting noise eps are algebraically equivalent, but minimizing plain squared error on each weights noise levels differently. Because the paper offers no theoretical explanation, any deeper claim would be speculation.

?

Does the decoder still read the caption, and did that help with binding?
Yes. The decoder keeps GLIDE's 1.2B-parameter text Transformer and drops the caption 50% of the time during training. The authors hoped keeping direct access to caption tokens would rescue details that CLIP embeddings lose, such as which color belongs to which object, but report in Section 2.1 and Section 7 that it offered little help.

?

Why does unCLIP struggle with "a red cube on top of a blue cube"?
A single 1,024-number CLIP embedding does not reliably record which attribute belongs to which object. The paper proves this by encoding real photographs of two colored or differently sized objects and decoding their CLIP embeddings: the reconstructions frequently swap colors or relative sizes. Because every generated image passes through that bottleneck, binding can break before the decoder even starts. GLIDE, which attends straight to caption tokens, handles this prompt better.

?

How does unCLIP differ from Latent Diffusion (Stable Diffusion)?
Latent Diffusion, published four months earlier in December 2021, runs diffusion on a spatial 2D grid produced by an autoencoder trained to reconstruct pixels, so its latent preserves exact layout and local geometry. unCLIP runs its prior over a single non-spatial 1,024-D CLIP vector and its decoder directly over 64x64 pixels, which enables semantic variations and text-diff edits at the cost of losing pixel-aligned structure in the bottleneck.

?

How many network evaluations does one 1024x1024 image require?
Under the paper's Table 3 settings, the 1B diffusion prior runs 64 steps twice to draw two candidates (128 passes unguided), the 3.5B 64x64 decoder runs 250 guided steps (two passes per step for conditional and unconditional predictions, 500 passes total), the 700M upsampler runs 27 unguided DDIM steps, and the 300M upsampler runs 15 unguided DDIM steps. The 3.5B decoder accounts for almost all of the inference cost.

Footnotes & further reading

  1. The paper: Ramesh, Dhariwal, Nichol, Chu & Chen, Hierarchical Text-Conditional Image Generation with CLIP Latents (OpenAI, April 2022). Deployment risk analysis: Mishkin et al., DALL·E 2 Preview: Risks and Limitations (2022).
  2. The decoder's base model: Nichol et al., GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models (2021), GLIDE explainer, with official code at openai/glide-text2im.
  3. CLIP and modality gap: Radford et al., Learning Transferable Visual Models From Natural Language Supervision (2021), CLIP explainer; Liang et al., Mind the Gap: Understanding the Modality Gap in Multi-modal Contrastive Representation Learning (NeurIPS 2022).
  4. Diffusion background: Ho, Jain & Abbeel, Denoising Diffusion Probabilistic Models (2020, DDPM explainer); Nichol & Dhariwal, Improved Denoising Diffusion Probabilistic Models (2021, Improved DDPM explainer); Song, Meng & Ermon, Denoising Diffusion Implicit Models (2020, DDIM explainer); Bao et al., Analytic-DPM (2022).
  5. Guidance, inversion, and latent diffusion: Dhariwal & Nichol, Diffusion Models Beat GANs on Image Synthesis (2021, explainer), Appendix F for DDIM inversion; Ho & Salimans, Classifier-Free Diffusion Guidance (2021/2022, explainer); Rombach et al., High-Resolution Image Synthesis with Latent Diffusion Models (2021, Latent Diffusion explainer).
  6. Optimization and probing: Foret et al., Sharpness-Aware Minimization for Efficiently Improving Generalization (2020, SAM explainer); Goh et al., Multimodal Neurons in Artificial Neural Networks (Distill, 2021).