Traditional generative models (GANs, VAEs) try to learn the data distribution in one shot. Diffusion models take a radically different approach: they define a fixed forward process that gradually destroys data, then learn a reverse process that undoes the destruction.
The key insight: If we can learn to denoise data at every noise level, we can start from pure noise and gradually denoise our way to realistic samples.
Score-based generative models: Diffusion models are equivalent to learning the score function ∇xtlogq(xt). The noise prediction relates to score via ϵθ=−1−αˉt∇xtlogq(xt).
Variational autoencoders: Diffusion models can be viewed as a hierarchical VAE with T latent layers and a fixed encoder (forward process).
Markov chains: Both forward and reverse processes are Markov chains (memoryless: xt depends only on xt−1, not the full history).
Langevin dynamics: The reverse process approximates Langevin MCMC sampling from the data distribution.
DDIM sampling: Deterministic variant that reduces sampling steps from1000 to 50 by exploiting implicit generative model structure.
Classifier-free guidance: Technique to trade diversity for sample quality by scaling the noise prediction.
Recall Feynman Explanation (Explain to a 12-year-old)
Imagine you have a beautiful drawing. Now, you slowly pour sand on it—a little bit each day for1000 days—until the drawing is completely buried and you can't see it anymore. That's the forward process: we're destroying the picture step by step.
Now here's the trick: we train a smart robot to learn how to remove the sand, one day at a time, working backwards. The robot looks at the sandy picture and guesses "where was the sand added today?" and removes it. Then it looks at yesterday's sandy picture and does it again. And again. 1000 times going backwards.
Once the robot is trained, we can give it a completely random pile of sand (that never had a picture under it) and ask it to remove sand as if there were a picture underneath. Amazingly, it creates a new beautiful drawing that looks like it came from the same artist as our original pictures!
The magic is that the robot didn't learn to draw directly. It learned to un-messup pictures, which turns out to be easier to learn. And since messing up is reversible (if you're smart about it), un-messing-up is the same as creating!
#flashcards/ai-ml
What is the forward process in diffusion models? :: A fixed Markov chain that gradually adds Gaussian noise to data over T timesteps according to q(x_t|x_{t-1}) = N(x_t; √(1-β_t)x_{t-1}, β_t I), systematically destroying the original data until it becomes pure noise.
What is the reverse process in diffusion models?
A learned Markov chain that removes noise step-by-step, parameterized by a neural network that predicts p_θ(x_{t-1}|x_t) = N(x_{t-1}; μ_θ(x_t,t), Σ_θ(x_t,t)), effectively learning to denoise at every noise level.
What is the reparameterization trick for diffusion forward process?
Instead of sampling x_t through all intermediate steps, we can sample directly: x_t = √(ᾱ_t)x_0 + √(1-ᾱ_t)ε where ᾱ_t = ∏(1-β_s) and ε ~ N(0,I). This allows efficient training by sampling random timesteps.
Why do diffusion models predict noise instead of x_0 directly?
Noise prediction is empirically better because: (1) noise has consistent statistics across all timesteps, (2) it relates to score matching, (3) networks don't need to handle drastically different output ranges (clean images vs noisy images) at different t values.
What is the training objective for diffusion models?
L_simple = E[||ε - ε_θ(x_t, t)||²] where we sample random t, real data x_0, noise ε, compute x_t = √(ᾱ_t)x_0 + √(1-ᾱ_t)ε, then train the network to predict the noise that was added.
Why are β_t values kept small in diffusion models?
Small β_t ensures the reverse conditional distribution q(x_{t-1}|x_t) remains approximately Gaussian, which the neural network can learn to model. Large β_t would make the reverse distribution non-Gaussian and impossible to learn accurately.
How do you generate samples from a trained diffusion model?
Start with x_T ~ N(0,I) (pure noise), then for t=T down to 1: predict noise ε_θ(x_t,t), compute denoised mean μ_θ, and sample x_{t-1} = μ_θ + σ_t·z where z~N(0,I). This iteratively denoises to produce x_0.
What is ᾱ_t (alpha-bar) and why is it important?
ᾱ_t = ∏_{s=1}^t (1-β_s) is the cumulative noise schedule. It controls the signal-to-noise ratio at timestep t: x_t has signal coefficient √(ᾱ_t) and noise coefficient √(1-ᾱ_t). At t=T, ᾱ_T ≈ 0 ensures x_T is pure noise.
What is the relationship between forward and reverse variance?
The reverse variance is β̃_t = (1-ᾱ_{t-1})/(1-ᾱ_t)·β_t, derived from Bayes' rule. It's smaller than the forward variance β_t because conditioning on both x_t and x_0 reduces uncertainty compared to conditioning on x_t alone.
Why use T=1000 steps instead of fewer larger steps?
Many small steps ensure each reverse step is a small perturbation that neural networks can learn to reverse accurately. Fewer large steps would violate the Gaussian approximation and make the reverse process much harder to learn.
Chalo isko simple tareeke se samajhte hain. Socho ek video hai jismein ink paani mein slowly-slowly ghul rahi hai — pehle saaf pattern, phir dheere-dheere sab noise ban jaata hai. Diffusion models basically ye video ulta chalana seekhte hain. Pehle ek forward process hota hai jismein hum apne data (jaise image) mein step-by-step Gaussian noise add karke usse pura destroy kar dete hain, jab tak ki wo bilkul random noise na ban jaye. Phir ek neural network train karte hain jo iss destruction ko reverse kare — yaani noise se wapas ek clean, realistic image banaye. Yahi core intuition hai: generation ko ek "denoising" problem mein convert kar dena.
Ab ye kyu itna kaam ka hai? Kyunki GANs ya VAEs jaise purane models pura complex data distribution ek hi baar mein seekhne ki koshish karte hain, jo bahut mushkil aur unstable hota hai. Diffusion models isko chhote-chhote easy steps mein tod dete hain — har step mein network ko sirf thoda sa noise hatana seekhna hai, jo kaafi aasaan task hai. Isi wajah se ye models bahut high-quality aur stable results dete hain, aur aajkal DALL-E, Stable Diffusion jaise famous image generators inhi pe based hain.
Ek important trick jo iss note mein hai wo hai reparameterization — iski wajah se hum kisi bhi timestep t ka noisy version seedha x0 se nikal sakte hain, poori chain simulate kiye bina. Formula xt=αˉtx0+1−αˉtϵ isi ka result hai. Aur 1−βt se shrink karna isliye zaroori hai taaki variance explode na ho aur har step controlled rahe. Ye chhoti-chhoti design choices hi diffusion models ko itna powerful aur practical banati hain — isliye inhe achhe se samajhna future ke generative AI ke liye foundation ka kaam karega.