Chaliye derive karte hain ki hum pehle expand kyun karte hain phir contract, shuru karte hain uss cheez se jo chahiye:
Goal: Ek non-linear function f:Rdmodel→Rdmodel seekhna jo complex patterns represent kar sake.
Step 1 — Universal Approximation
Universal approximation theorem ke mutabiq, ek two-layer network jisme kaafi hidden units hon, kisi bhi continuous function ko approximate kar sakta hai. Lekin kitne units chahiye?
Step 2 — Information Bottleneck
Agar dff=dmodel ho, toh ek bottleneck hai—limited capacity. Hidden layer ko complex combinations capture karne ke liye input se zyada features represent karne padte hain.
Step 3 — The 4x Rule
Empirically, dff=4×dmodel achha kaam karta hai. Kyun?
Expansion: 4x zyada neurons ka matlab hai ki hum ∼4×dmodel alag feature combinations compute kar sakte hain
Sparsity: ReLU activations sparse hote hain (~50% neurons active), toh effective capacity ∼2×dmodel hoti hai
Compression: Second layer wapas project karta hai, network ko useful high-dimensional features seekhne par majboor karta hai
Shuru karte hain ReLU (Rectified Linear Unit) se:
ReLU(x)=max(0,x)
Problem: Zero par hard cutoff dead neurons create karta hai (gradient = 0 for x<0).
GELU ki taraf evolution:
GELU(x)=x⋅Φ(x)=x⋅P(X≤x),X∼N(0,1)
Intuition: Input ko us probability se multiply karo ki woh ek random Gaussian se bada hai. Chhoti negative values ko chhota lekin non-zero gradient milta hai (smooth!).
Transformers mein feed-forward network sublayer kya hai? :: Ek position-wise fully connected network jo har token par independently apply hota hai, do linear layers se bana hota hai jiske beech ek non-linear activation hota hai, typically dimension 4x expand karta hai phir wapas project karta hai.
FFN model dimension se 4x tak expand kyun karta hai?
Complex non-linear patterns seekhne ke liye ek richer feature space create karne ke liye. Expansion universal approximation ke liye enough capacity provide karta hai, jabki ReLU sparsity (~50% active) effective capacity ko ~2x model dimension banata hai.
Standard Transformer FFN ka formula kya hai?
FFN(x) = max(0, xW₁ + b₁)W₂ + b₂, jahan W₁ dimensions expand karta hai (d_model → d_ff), activation apply hota hai, aur W₂ wapas project karta hai (d_ff → d_model).
FFN position-wise kyun apply hota hai?
Attention already positions ke beech information mix kar chuka hota hai. FFN position-independent feature extraction mein specialize karta hai already-mixed representations par, jo perfectly parallelize hota hai aur redundant cross-position modeling rokta hai.
Transformer parameters ka kitna percentage FFN mein hota hai?
Har layer ke parameters ka approximately 2/3. d_ff = 4×d_model ke saath, FFN ke paas ~8d²_model parameters hote hain vs attention ke ~4d²_model.
Models ReLU se GELU se SiLU ki taraf kyun gaye?
ReLU mein hard cutoff hai (x<0 ke liye dead neurons). GELU activation ko Gaussian probability weighting se smooth karta hai. SiLU (x·σ(x)) self-gated, har jagah smooth hai, aur empirically large models ke liye best perform karta hai.
FFN aur regular MLP mein kya fark hai?
FFN same network ko har sequence position par independently apply karta hai (1x1 convolution ki tarah), jabki MLP poore input ko ek single vector ki tarah process karta hai. FFN mein position-wise weight sharing hota hai.
GLU variant kya hai aur ise kyun use karte hain?
Gated Linear Unit: FFN_GLU(x) = (σ(xW₁) ⊙ xW₃)W₂, jahan ek path doosre ko gate karta hai. Learned selective amplification ke through same performance ke liye 15-20% parameter savings provide karta hai.
Recall Ek 12-saal ke bacche ko samjhao
Socho tum class mein ho aur teacher sabse ek interesting fact share karne ko kehti hai. Yeh attention ki tarah hai—sabne suna kya logon ne kaha aur apne dimaag mein un ideas ko mila liya.
Ab, har student ghar jaata hai aur un saari baaton ke baare mein gehraai se sochta hai jo sunni thi, unhe apni pehle ki jaankari se jodata hai. Shayad tune suna "dogs loyal hote hain" aur "wolves pack mein shikaar karte hain," aur ghar par tune realize kiya "oh, dogs wolves se evolve hue, isliye woh social hote hain!" Woh gehri soch akele ghar par hi feed-forward network hai.
Tu sochte waqt apne classmates ko call nahi karta (doosron ke saath koi mixing nahi). Tu sirf woh process karta hai jo tune seekha. Phir kal, tu class mein wapas aata hai behtar samajh ke saath, aur cycle repeat hoti hai.
"4x expansion" waise hai jaise ghar par sochte waqt 4x zyada brain space milna—tu bahut zyada connections aur ideas consider kar sakta hai apna final thought class mein wapas laane se pehle.