4.3.1 · HinglishPretraining & Fine-Tuning LLMs

GPT family architecture evolution

1,984 words9 min readRead in English

4.3.1 · AI-ML › Pretraining & Fine-Tuning LLMs


GPT exist kyun karta hai?

OBJECTIVE kya hai? Har next token ki probability maximize karo, given sab pehle wale tokens:


Ek GPT block scratch se kaise banta hai

Ek decoder layer do kaam karti hai: positions ke across information mix karo (attention), phir har position ko independently process karo (MLP). Dono ko residual connection aur normalization ke saath wrap kiya jaata hai.

Figure — GPT family architecture evolution

Evolution timeline (ACTUALLY kya badla)


Scale kyun kaam karta hai: scaling laws (Forecast-then-Verify)


Common mistakes (Steel-man + fix)


Worked examples


Recall Feynman: ek 12 saal ke bachche ko explain karo

Socho tum ek sentence padh rahe ho aur jo words aage hain unhe chhupa ke rakh rahe ho, aur agla word guess karne ki koshish kar rahe ho. GPT ek aisi machine hai jo yeh "agla word guess karo" wala game billions baar khel khel kar isme kamaal ban jaati hai. GPT ka har version wahi game machine hai, bas badi banayi gayi — zyada brain cells (parameters) aur padhne ke liye zyada books (data). "Masking" naam ka clever trick ek rule ki tarah hai: tumhe un words ko dekhne ki ijazat nahi jo tumne abhi tak nahi padhe, toh tum sach mein predict karna seekhte ho, sirf answer copy nahi karte. Jab machine kaafi badi ho gayi, toh kuch magical hua: tum apne question mein sirf do examples dikhaa sakte the aur woh khud pattern samajh jaati — kisi ne use dobara train nahi kiya tha.


Connections


Flashcards

Original Transformer ka kaunsa sub-part GPT rakhta hai?
Sirf decoder (masked/causal self-attention stack); koi encoder nahi, koi cross-attention nahi.
Autoregressive factorization ko kaunsa probability rule justify karta hai?
Chain rule of probability, baar baar apply karke (telescoping se) — yeh exact hai, koi approximation nahi.
Attention scores ko se divide kyun karte hain?
Dot product ki variance ke saath badhti hai; divide karne par scores rehte hain taki softmax saturate na ho aur gradients vanish na hon.
Causal mask ka kya role hai?
Future positions ke scores ko set karta hai taki softmax ke baad woh 0 ho jaayein — token ko future dekhne se rokta hai, autoregression enforce karta hai.
GPT-1 se GPT-2 mein key architectural change kya tha?
LayerNorm ko pre-activation (pre-LN) par residual branch ke andar move karna + ek final LayerNorm add karna → stable deep training.
GPT-3 ki emergent capability kya thi?
In-context / few-shot learning — frozen weights ke saath prompt examples se tasks solve karna, koi fine-tuning nahi.
GPT-3 ka parameter count aur depth?
~175B parameters, 96 layers, d=12288, 96 heads, 2048 context.
GPT-3.5 (InstructGPT) ko kya distinguish karta hai — architecture ya training?
Training: instruction tuning + RLHF (alignment). Backbone architecture essentially unchanged hai.
GPT-4 ke widely-believed additions kya hain?
Multimodality (text + image) aur Mixture-of-Experts; details undisclosed hain.
Test loss parameters ke saath kaise scale karta hai?
Power law ki tarah jahaan hai; log-log plot par ek seedhi line.
Raw likelihood ki jagah log-likelihood kyun use karte hain?
Bahut saari chhoti probabilities ka product underflow karta hai; log products ko stable gradients wale sums mein badal deta hai.
Per-layer attention parameter count ke terms mein kya hai?
( se), toh params width ke saath quadratically badhte hain.

Concept Map

drop encoder

objective

chain rule

train via

built from

mixes positions

masked by

scale scores

per position

stabilized by

enables

drives

optimizes

2017 Transformer encoder-decoder

Decoder-only GPT

Autoregressive LM

Joint factorization

Cross-entropy NLL loss

Decoder block

Causal self-attention

Causal mask -inf on future

Divide by sqrt of d_k

Position-wise MLP 4d

Residual + pre-LN

Stack deeper and wider

GPT family evolution