Skip to content
tezvyn:
Menu

Diffusion Models: Generating by Reversing Noise

Source: Wikipedia: Diffusion modelHardHow cards are made

Diffusion models generate data by learning to reverse a process of adding noise. They power state-of-the-art image generation (DALL-E 2, Stable Diffusion). The main footgun is that their iterative sampling process is slow and computationally expensive.

Why it exists

Generative models like GANs were often unstable to train and could suffer from 'mode collapse,' where they only produce a limited variety of outputs. Diffusion models were developed to provide a more stable training objective that leads to higher-quality and more diverse results, at the cost of slower generation speed.

The mental model

Think of sculpting, but in reverse. You start with a masterpiece (a clean image). The 'forward process' is like repeatedly hitting it with a tiny hammer, adding a little dust each time, until it's just a cloud of dust (pure noise). The model's job, the 'reverse process,' is to learn how to perfectly undo each of those steps, reconstructing the masterpiece from the dust cloud. To generate a new image, you just start with a random cloud of dust and run this learned reverse process.

How it works

The process has two parts. First, the forward diffusion process is a fixed procedure where you take an image and add a small amount of Gaussian noise over many steps (e.g., 1000). At the end, the image is indistinguishable from random noise. Second, the reverse process trains a neural network to do the opposite. At each step, the model is given a noisy image and a timestep, and it learns to predict the noise that was added. By subtracting this predicted noise, it takes one step back towards a cleaner image. To generate a new image from scratch, you start with pure random noise and apply this trained de-noising model iteratively for all the steps until a clean image emerges. It is a latent variable model because the noisy image at each step is a latent representation of the final clean image.

When to use it

Use diffusion models when the absolute highest quality and diversity of generation is the top priority, and you can tolerate slow, computationally expensive inference. This is ideal for offline asset generation, such as creating artwork, synthetic data for training other models, or generating frames for an animated sequence.

When not to use it

Avoid diffusion models for applications requiring real-time or low-latency generation, like interactive video filters. The multi-step sampling process makes them inherently slower than single-shot models like GANs. Their high computational and memory requirements also make them difficult to deploy on resource-constrained devices like mobile phones.

One canonical example

Text-to-image generation is the most famous application. A model like Stable Diffusion takes a text prompt (e.g., 'an astronaut riding a horse') and uses it to guide the reverse diffusion process. Instead of just de-noising randomly, the model de-noises in a way that steers the emerging image towards the concepts described in the text prompt. This guidance allows for powerful, controllable image synthesis from natural language.

Interview question

Which characteristic of diffusion models directly contributes to their high computational cost and slow generation speed?

  • a.The necessity of iteratively reversing noise over many steps.Correct
  • b.The use of Gaussian noise during the training phase.
  • c.Their ability to produce highly diverse and high-quality outputs.
  • d.Their reliance on a fixed forward diffusion process.
Why?

The card explicitly states that 'The multi-step sampling process makes them inherently slower' and mentions 'iterative sampling process is slow and computationally expensive.' This refers to the reverse process where noise is iteratively removed. While other options describe aspects of diffusion models, they are not the direct cause of slow generation speed.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on generative ai — each one lists the topics its interview covers.

See open roles