4.5.5 · HinglishGenerative Models

ELBO objective and KL term

2,830 words13 min readRead in English

4.5.5 · AI-ML › Generative Models

Overview

Evidence Lower BOund (ELBO) variational inference mein central optimization objective hai aur Variational Autoencoders (VAEs) ka training loss bhi. Yeh ek tractable tarika deta hai intractable posterior distributions ko approximate karne ka — log-likelihood par ek lower bound maximize karke — aur saath hi ek KL divergence term bhi include karta hai jo approximate posterior ko regularize karta hai.

Figure — ELBO objective and KL term

Derivation from First Principles

Step 1: Intractable log-likelihood se shuru karo

Hum observed data ke liye maximize karna chahte hain, jahan generative model yeh hai:

Yeh mushkil kyun hai: ke zyaadatar choices ke liye (jaise ek neural network decoder), is integral ka koi closed form nahi hota aur yeh ki dimension mein exponentially expensive hota hai.

Step 2: Approximate posterior introduce karo

Kyunki hum directly compute nahi kar sakte, hum ek approximate posterior introduce karte hain (VAEs mein encoder network). Yeh hamara variational distribution hai — hum optimize karenge taaki , ke paas aa sake.

Step 3: Jensen's inequality use karke ELBO derive karo

Log-likelihood se shuru karo:

se multiply aur divide karo:

Key insight: ek concave function hai, isliye Jensen's inequality se (jo concave functions ke liye deta hai):

Isko apply karte hain:

Yeh step kyun? Jensen's inequality humein ko expectation ke andar le jaane deti hai, iske badle mein ek inequality introduce hoti hai. Kyunki concave hai, inequality sahi direction mein point karti hai ( of average ≥ average of s), aur humein ek valid lower bound milta hai. Isse expression Monte Carlo sampling ke zariye computable ho jaata hai.

Step 4: Conditional aur prior use karke rewrite karo

use karke:

Rearrange karo:

Yeh form kyun?

  • Pehla term model ko reward karta hai ki encoder se sample kiye gaye latent codes se ko reconstruct karo.
  • Doosra term encoder distribution ko penalize karta hai agar woh prior se bhatkti hai, taaki woh collapse ya overfit na kare.

Understanding the KL Term

Humein iska zaroorat kyun hai:

  1. Posterior collapse rokta hai: Without the KL term, the encoder could learn to map each to a deterministic, wildly different , making the latent space discontinuous and unusable for generation.
  2. Sampling enable karta hai: rakhne se hum draw karke aur decode karke naye samples generate kar sakte hain, chahe woh humne kabhi dekha na ho.
  3. Regularization: Complexity penalty ki tarah kaam karta hai — simpler, zyaada "prior-like" encodings prefer ki jaati hain.

Mathematical Properties

Key properties:

  • hamesha (Gibbs' inequality)
  • iff almost everywhere
  • Symmetric nahi: generally

Yeh direction kyun? Hum use karte hain nahi, kyunki:

  • woh distribution hai jise hum control karte hain (encoder)
  • Expectations ke w.r.t. li jaati hain, jisse hum sample kar sakte hain
  • Ise reverse KL ya exclusive KL kehte hain — yeh ko ke support ko underestimate karvata hai (zero-forcing behavior)

The Gap: ELBO vs True Log-Likelihood

Step 5: Gap quantify karna

Bayes' rule se shuru karo:

Log lena:

par expectation lo:

add aur subtract karo:

Yeh kyun matter karta hai:

  • ELBO aur true log-likelihood ke beech ka gap exactly humari approximation aur true posterior ke beech ka KL divergence hai
  • Jab hum ELBO maximize karte hain, hum simultaneously generative model () improve karte hain aur approximation quality () bhi
  • Jab , ELBO log-likelihood ke barabar ho jaata hai

Worked Examples

ELBO:

Yeh step kyun? Reconstruction term negative squared error ban jaata hai kyunki .

Diagonal Gaussians ke liye closed-form KL:

Is formula ki derivation: Definition se shuru karte hain:

aur use karke:

Yeh kyun matter karta hai: Yeh closed form VAE training ko efficient banata hai — KL term ke liye koi Monte Carlo estimation ki zaroorat nahi.

Step 1: Reconstruction term

Yeh step kyun? Hum evaluate karte hain ki decoder ne sampled latent code se original kitni acchi tarah reconstruct kiya.

Step 2: KL term ( use karke, toh aur )

ELBO:

Yeh step kyun? Hum encoder ko penalize karte hain kyunki usne ek aisi distribution produce ki jo standard normal prior se bhatkti hai. Ek important detail yaad raho: KL formula use karta hai, na ki — 2 ka factor bhool jaana ek common galti hai.

Kya hota hai:

  • : Reconstruction ko priority deta hai, KL bada ho sakta hai → behtar reconstructions, entangled latents
  • : Standard ELBO, balanced trade-off
  • : Prior se match karne ko priority deta hai → zyaada disentangled latents, worse reconstructions

Yeh kyun kaam karta hai: KL term ki strength information bottleneck control karti hai. Zyaada encoder ko majboor karta hai ki ke kam, zyaada independent dimensions use kare, jisse disentanglement hoti hai.


Common Mistakes and Misconceptions

Sach yeh hai: KL term ad-hoc regularization nahi hai; yeh variational inference framework se naturally aati hai. Yeh tumhare approximate posterior aur true posterior ke beech ka gap hai. Ise remove karna tumhe "kam regularized" VAE nahi deta — yeh mathematical justification tod deta hai ki tum yeh objective optimize kyun kar rahe ho.

Kaise theek karo: Derivation yaad raho: ELBO + KL gap = log-likelihood. KL term bound ka hissa hai, add-on nahi.

Nuance yeh hai: ke w.r.t. ELBO maximize karna zaroor improve karta hai. Lekin jab hum bhi optimize karte hain, hum KL gap reduce karke bound tighten kar rahe hote hain. Log-likelihood tabhi badhti hai jab ELBO ki badhot gap reduction se zyaada ho. Practice mein hum jointly optimize karte hain, isliye dono saath hota hai.

Kaise theek karo: ELBO fixed ke liye lower bound hai. Jab change hota hai, bound khud move karta hai. Guarantee yeh hai: hamesha, lekin improve karna model improve karta hai.

Sach yeh hai: KL asymmetric hai. (reverse KL, ELBO mein use hota hai) zero-forcing hai: yeh banata hai jahan ho, jisse true posterior ke support ka underestimation hota hai. (forward KL) zero-avoiding hai: yeh banata hai jahan ho, jisse support ka overestimation hota hai.

VAEs ke liye kyun matter karta hai: Reverse KL posterior collapse cause kar sakta hai jahan encoder true posterior ke kuch modes ignore kar deta hai. Forward KL approximate posterior ko overly broad aur diffuse bana deta.

Kaise theek karo: Direction yaad raho: humein ke w.r.t. expectations chahiye (jo hum sample kar sakte hain), isliye hum use karte hain.

Sach yeh hai: ELBO log-probability par lower bound hai, jo negative ho sakti hai (probabilities 1 se kam ho sakti hain). Jo matter karta hai woh yeh hai ki training ke dauran ELBO badhta rahe, uski absolute value nahi. Ek typical ELBO value data dimensionality ke hisaab se -1000 ya -10000 bhi ho sakti hai.

Kaise theek karo: ELBO improvement track karo, absolute value nahi. Meaningful comparisons ke liye same data par different architectures ka ELBO compare karo.


Active Recall Practice

Recall ELBO ko ek 12-saal ke bachche ko explain karo

Socho tumhare paas ek magic box hai jo pictures bana sakta hai. Lekin tum samajhna chahte ho ki box har picture banane ke liye kaunse secret codes use karta hai. Problem yeh hai ki tum box ke andar directly nahi jhank sakte.

Toh tum ek guesser machine banate ho jo picture dekh kar guess karta hai ki use kaunse secret code ne banaya. Ab ek game khelo:

  1. Guesser ko picture dikhao → woh ek code guess karta hai
  2. Woh code magic box mein daalo → dekho ki wahi picture wapas milti hai ya nahi
  3. Agar picture sahi nikli toh points milte hain

Lekin ek pakad hai! Tumhara guesser koi bhi random codes nahi bana sakta — use waise codes use karne hote hain jo magic box naturally use karta hai (jaise 0 aur 1 ke beech ke numbers, 999 jaisi pagal numbers nahi).

ELBO tumhara is game mein score hai: Pictures sahi se recreate karne par points milte hain (reconstruction term), lekin agar tumhara guesser weird, unnatural codes use kare toh points katte hain (KL term). ELBO maximize karna matlab dono mein behtar hona — codes guess karna aur pictures recreate karna — aur saath mein apne guesses ko reasonable rakhna.


KL direction ke liye: "Queen Prefers Priors", hum measure karte hain ki hamari Queen (encoder) Prior se kitni door hai.


Connections

  • Variational Inference: ELBO, VI mein fundamental objective hai; VAEs iska deep learning application hain
  • KL Divergence: Properties, forward vs reverse, f-divergences mein deep dive
  • VAE Architecture: ELBO ko reparameterization trick ke saath neural networks mein kaise implement karte hain
  • Expectation Maximization: Latent variable models ke liye EM algorithm mein bhi ELBO aata hai
  • Information Bottleneck: β-VAE, weighted KL term ke zariye IB principle se connect hota hai
  • Posterior Collapse: Kya hota hai jab KL → 0 aur model latent variables ignore kar deta hai
  • Importance Weighted Autoencoders: Multiple samples use karke ELBO se tighter bounds
  • Normalizing Flows: Zyaada expressive ke liye diagonal Gaussian encoder ka alternative

Summary

ELBO objective intractable log-likelihood par ek tractable lower bound hai. Yeh do parts mein decompose hota hai:

  1. Reconstruction term: Accurate decoding ko reward karo
  2. KL regularization: Encoder ko prior ke paas rakho

ELBO aur log-likelihood ke beech ka gap exactly hai — variational posterior ka approximation error. ELBO maximize karna jointly generative model improve karta hai aur approximation gap reduce karta hai. KL term ad-hoc regularization nahi hai balki variational framework ka fundamental consequence hai jo sampling enable karta hai, collapse rokta hai, aur VAEs ke liye ek principled training objective provide karta hai.


#flashcards/ai-ml

Variational inference mein ELBO objective kya hai?
The Evidence Lower BOund, , par ek tractable lower bound hai jo reconstruction term aur KL regularization term mein decompose hota hai.
ELBO ko "lower bound" kyun kehte hain?
Kyunki Jensen's inequality se (log concave hai), hamesha hold karta hai. ELBO maximize karna log-likelihood ko neeche se upar dhakelta hai.
ELBO ke do components kya hain?
1) Reconstruction term: (accurate decoding ko reward karo), 2) KL divergence: (prior se deviation ko penalize karo).
ELBO aur true log-likelihood ke beech ka gap kya hai?
Gap hai, approximate posterior aur true posterior ke beech ka KL divergence. Jab yeh zero hota hai, ELBO log-likelihood ke barabar ho jaata hai.
ELBO mein kyun use karte hain ki jagah?
Kyunki humein ke w.r.t. expectations chahiye, jisse hum sample kar sakte hain

Concept Map

intractable integral

cannot compute

variational distribution

apply Jensens inequality

used in

lower bounds

splits into

splits into

regularizes

uses

pulls q toward

maximized to train

Log-likelihood log p x

Marginal over latent z

Introduce approx posterior q phi

VAE Encoder

ELBO lower bound

Reconstruction term

KL divergence term

VAE Decoder p theta x given z

Prior p z

Variational Autoencoder