Language mein structure hota hai: "love" word "I" ke baad zyada likely hai, "quantum" ke baad nahi. Causal LM sequences par yeh conditional probability distribution seekhta hai:
Is tarah factorize kyun karte hain?Chain rule of probability ke according, koi bhi joint distribution conditionals ke product ke roop mein likhi ja sakti hai. Causal constraint ka matlab hai ki har P(wt∣w<t) ek forward-looking prediction hai, jo bilkul waise match karta hai jaise hum naturally language produce karte hain.
Yeh factorization kyun? Probability ka chain rule: P(A,B)=P(A)P(B∣A), T variables tak extend kiya. Causal ordering (x1 pehle, phir x2 given x1, etc.) arbitrary hai lekin text ke left-to-right flow se match karta hai.
Sequence: "I love ML"
Tokens:x1=I,x2=love,x3=ML
Step-by-step loss:
Position 1:L1=−logPθ(x1=I∣∅)Context nahi kyun?x1 pehla token hai; model ek start-of-sequence token se predict karta hai ya unconditional distribution seekhta hai.
Position 2:L2=−logPθ(x2=love∣x1=I)Sirf x1 kyun? Causal constraint: model "I" dekhta hai, "love" predict karta hai.
Position 3:L3=−logPθ(x3=ML∣x1=I,x2=love)x1,x2 dono kyun? Saara previous context available hota hai.
Total loss:LCLM=L1+L2+L3
Concrete numbers: Maano model yeh output karta hai:
Pθ(I∣∅)=0.1 → L1=−log(0.1)≈2.30
Pθ(love∣I)=0.4 → L2=−log(0.4)≈0.92
Pθ(ML∣I love)=0.05 → L3=−log(0.05)≈3.00
Total:2.30+0.92+3.00=6.22
Yeh number kyun? Kam loss = model true sequence ko zyada probability assign karta hai. Perfect prediction (P=1) se loss 0 milta hai.
Dono ke liye same objective kyun kaam karta hai? Training har position par Pθ(xt∣x<t) seekhta hai. Generation repeatedly is seekhe hue conditional ko sequence extend karne ke liye apply karta hai.
Generation ke liye causal kyun? Inference par, tumhare paas sirf past tokens hote hain. Training objective ko test-time reality se match karna chahiye (future available nahi hai).
Masked LM generate kyun nahi kar sakta? BERT bidirectional context dekhta hai, lekin generation left-to-right hoti hai. Training aur inference ke beech mismatch hai.
Recall Ek 12-Saal-Ke Bacche Ko Samjhao
Socho tum ek story likh rahe ho, ek word at a time. Tum jo likh chuke ho woh dekh sakte ho, lekin aage kya aayega yeh nahi dekh sakte (kyunki tumne abhi likha hi nahi!).
Causal language modeling ek robot ko yahi game sikhana hai. Robot "Once upon a" padhta hai, phir guess karta hai agla word "time" ho sakta hai. Agar real agla word sach mein "time" hai, to robot ko achcha score milta hai. Agar usne "banana" guess kiya, to bura score milta hai aur woh better karna seekhta hai.
Robot laakhon stories par practice karta hai, aaise patterns seekhta hai jaise:
"Once upon a ___" → usually "time"
"I feel ___" → often "happy", "sad", "excited"
"The dog ___" → probably ek verb jaise "ran", "barked"
Trick yeh hai ki robot kabhi cheat nahi karta aage dekh ke. Woh sirf wahi dekhta hai jo already likh chuka hai, bilkul tumhari tarah. Isliye ise "causal" kehte hain — jaise cause aur effect, past future ko cause karta hai, na ki ulta!
Kaafi practice ke baad, robot next words guess karne mein itna achcha ho jaata hai ki woh khud poori stories likh sakta hai, ek word at a time.
GPT Family — Causal LM objective se train kiye gaye models
#flashcards/ai-ml
Causal language modeling objective kya hai? :: Negative log-likelihood −∑t=1TlogPθ(xt∣x<t) minimize karo, har token ko sirf previous tokens se predict karo (future access nahi).
Ise "causal" kyun kehte hain? :: Kyunki position t par prediction sirf t se pehle ki positions par depend kar sakti hai (cause → effect), time ki forward direction preserve hoti hai.
CLM sequence probability ko kaise factorize karta hai?
Chain rule se: P(x)=∏t=1TP(xt∣x<t), joint probability ko conditional next-token predictions mein decompose karta hai.
CLM, true next-token distribution (correct token par one-hot) aur model ki predicted softmax distribution ke beech cross-entropy hai.
Generation ke liye causal LM kaise use hota hai?
Autoregressively xt∼Pθ(⋅∣x<t) sample karo, phir sampled xt par condition karke xt+1 predict karo, end-of-sequence tak repeat karo.
CLM ke context mein perplexity kya hai?
PPL=exp(LCLM), exponentiated average negative log-likelihood; kam perplexity = better predictions.
CLM shifted targets par kyun train karta hai?
Position t−1 par input, position t par target predict karta hai (input: "The cat sat", targets: "cat sat on"), P(xt∣x<t) implement karta hai.
Causal LM mein exposure bias kya hai?
Training mein context ke liye true tokens use hote hain (teacher forcing), lekin generation mein model ke apne predictions use hote hain; errors compound ho jaate hain kyunki model ne kabhi apni galtiyon se recover karna practice nahi kiya.
BERT GPT ki tarah text generate kyun nahi kar sakta?
BERT bidirectional context ke saath masked LM use karta hai, lekin generation left-to-right hai (sirf past available); training-inference mismatch autoregressive sampling prevent karta hai.