A single decoder layer does two things: mix information across positions (attention) then process each position independently (MLP). Each is wrapped with a residual connection + normalization.
Imagine you're reading a sentence and covering the words after where you are, trying to guess the next word. GPT is a machine that plays this "guess the next word" game billions of times until it's amazing at it. Each version of GPT is the same game machine, just built bigger — more brain cells (parameters) and more books to read (data). The clever trick called "masking" is like a rule: you're not allowed to peek at words you haven't reached yet, so you truly learn to predict instead of copying the answer. When the machine got big enough, something magical happened: you could just show it a couple of examples in your question and it would figure out the pattern by itself — nobody had to retrain it.
Dekho, GPT ki sabse badi baat yeh hai ki har naya version koi bilkul naya jaadu nahi hai — woh same decoder-only Transformer block hai, bas usko deeper aur wider bana diya aur zyada data pe train kiya. Original 2017 Transformer mein encoder aur decoder dono the, lekin GPT ne encoder phenk diya kyunki language modeling mein sirf "agla word predict karo" karna hai — future dekhne ki zaroorat hi nahi. Yeh "future mat dekho" wala rule causal mask se lagta hai, aur yahi GPT ka dil hai.
Training ka objective simple hai: chain rule of probability se poore sentence ka probability tod do next-token predictions mein, aur cross-entropy loss minimize karo. Attention mein jo dk se divide karte hain woh koi random cheez nahi — dot product ki variance dk ke saath badhti hai, toh usko control karke softmax ko saturate hone se bachate hain. Yeh chhoti-chhoti baatein exam aur interview dono mein poochi jaati hain.
Evolution yaad rakhne ka short trick: GPT-1 ne fine-tuning introduce kiya, GPT-2 ne zero-shot dikhaya aur pre-LN ka stability trick laaya, GPT-3 (175B) ne few-shot in-context learning ka magic dikhaya — sirf prompt mein examples daal do, weights freeze rehte hain. GPT-3.5 ne RLHF se alignment kiya (architecture same), aur GPT-4 multimodal + Mixture-of-Experts maana jaata hai. 80/20 funda: 80% badlav sirf scale hai, baaki 20% yeh key tweaks — inhi 20% pe focus karo.
Aur ek important galti se bacho: log mat bhoolo ki GPT-3 ko har task ke liye fine-tune nahi kiya jaata — usko prompt hi mein examples dikha dete hain. Yeh in-context learning scale se emerge hoti hai, planned feature nahi thi.