Latent diffusion model (LDM)

A latent diffusion model is an image generator that runs the diffusion process on a compressed representation of images rather than on raw pixels, which makes high-resolution generation much cheaper.

A diffusion model makes an image by starting from random noise and removing it step by step until a picture emerges. Doing this directly on pixels is costly: a single 512 by 512 colour image holds 786,432 numbers, and the model has to process all of them at every step, many times over.

A latent diffusion model splits the job in two. First, an autoencoder learns to squeeze images into a much smaller latent representation and to rebuild them from it. In Stable Diffusion the encoder shrinks each side by a factor of 8, so a 512 by 512 image becomes a 4 by 64 by 64 array, 48 times fewer numbers. The diffusion model, a U-Net, learns to remove noise in that compact space. When it finishes, the decoder turns the result back into a full image. A text prompt is turned into numbers by a text encoder and fed in through cross-attention, which is how the words steer the picture.

The approach comes from High-Resolution Image Synthesis with Latent Diffusion Models by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser and Björn Ommer, from the CompVis group at LMU Munich and from Runway, posted on December 20, 2021 and presented at CVPR 2022. The authors reported that it cut the computing cost of both training and generation compared with pixel-based diffusion, and set a new best result for inpainting.

Its best-known use is Stable Diffusion. CompVis released versions 1.1 to 1.4 in August 2022, and RunwayML released version 1.5 in October 2022. Stable Diffusion versions from 1.1 through XL are all built on the latent diffusion design.

The compression is a trade-off the authors set out to balance: squeeze too hard and fine detail is lost in the autoencoder; too little and the savings disappear. When a company says its image or video model works in latent space, this is usually the arrangement it means.

Common questions

What is a latent diffusion model?

It is a diffusion model that works on a compressed version of an image instead of the pixels themselves. An autoencoder handles the compression and decompression, and the diffusion model does its denoising in the small space in between, which saves a great deal of computation.

Is Stable Diffusion a latent diffusion model?

Yes. Stable Diffusion was built on the latent diffusion design from the 2021 paper by Rombach and colleagues, and its versions from 1.1 through XL all follow that architecture.

What is the difference between diffusion and latent diffusion?

A standard diffusion model removes noise directly from pixels. A latent diffusion model removes noise from a compressed latent representation and decodes it into pixels only at the end. The result is similar in kind, but the latent version needs far less computation for large images.

Why do image generators use latent space?

Working on a compressed representation means far fewer numbers to process at every denoising step. That makes training and generation cheaper and faster, and it makes high-resolution images practical.

Finding more

Search for "latent diffusion", "Stable Diffusion architecture" or "VAE U-Net text encoder" to see how the parts fit together. The original paper on arXiv is the authoritative description, and model cards from the groups that release image models say which architecture each version uses. Treat speed and quality comparisons in vendor announcements with care, since they rarely use the same test conditions.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.