Sampling: Guessing Through the Fog
We know the water mage can perfectly extract ink from the water step-by-step to reveal a clear painting. But there is a catch. When the water is completely pitch black, the mage cannot see the dragon hidden at the bottom. In fact, there is no dragon. It’s just random dark water.
So how does he know which drops of ink to pull out?
He has to guess.
He looks into the dark water and imagines what might be hidden there. Based on all the paintings he has seen in his life, he takes a very rough guess: “This tiny shape looks a bit like the outline of a mountain.”
Based on that guess, he pulls a specific drop of ink out of the water. The water gets slightly clearer.
Now he looks again. “Actually, with that drop gone, it doesn’t look like a mountain. It looks more like a tiger.”
He adjusts his guess and pulls out a different drop of ink.
He repeats this process hundreds of times. Guessing what the blurry shape is, removing a drop of ink based on that guess, looking at the slightly clearer shape, and guessing again. By the time the water is completely clear, his hundreds of tiny, adjusted guesses have sculpted the chaotic water into a perfect, brand new painting of a tiger.
The Reality
In Diffusion Models, this process of generating an image from pure noise is called “Sampling” or “Inference.”
When you ask Midjourney for an image, it starts with a completely random grid of TV static. The AI looks at the static and makes a rough guess of what the final image will look like. Based on that guess, it subtracts a tiny bit of noise.
Then it stops, looks at the new, slightly less noisy image, and re-evaluates. It makes a new guess. It subtracts more noise.
Because it constantly stops to look at its own work and adjust its trajectory, the AI can correct its own mistakes in real-time. If it accidentally generates a tiger with three ears at step 50, it might realize the mistake by step 60 and smoothly blur the third ear back into background foliage.
The Why
This constant “guess, adjust, repeat” cycle is why diffusion models take so much longer to generate an image than a GAN, but it’s also why they produce such incredibly detailed and coherent masterpieces. They literally sculpt the image out of the noise, refining their vision at every single step.
The Takeaway
The best way to navigate thick fog isn’t to run blindly toward where you think the end is. It’s to take one step, look around, and adjust your course.
AI specialists call it: Sampling (Inference) Process
During inference, the model iteratively solves a stochastic differential equation (SDE) or probability flow ODE to sample from the learned data distribution. Starting from x_T ~ N(0, I), it applies the learned score function at each discrete timestep t. Techniques like DDPM (Denoising Diffusion Probabilistic Models) or faster samplers like DDIM (Denoising Diffusion Implicit Models) determine the step sizes and trajectories, balancing generation speed with the quality of the final manifold projection.
💬 Think of a project you’ve worked on. Did you plan it all out perfectly in advance (like a GAN), or did you figure it out step-by-step as you went along (like Diffusion)?
Part 12 of 14 | #GenerativeModelsForHumans
#ai_edu Based on Stanford and industry lectures