WHY does this even exist? During pretraining the model sees enormous text where a pattern established earlier in a document predicts later tokens (lists, tables, translations, Q&A threads). To minimise next-token loss it is forced to become good at "spot the pattern in the context, then continue it." ICL is that skill reused at inference time.
Imagine a super-smart parrot that has read the whole internet. You don't retrain it. You just show it a few examples first: "cat→animal, rose→plant, dog→?" Because it has seen millions of little lists like this before, it figures out the game you're playing and finishes the pattern: "animal". It didn't study for a test — it just noticed the rule you were hinting at right there in front of it. That noticing-and-continuing is in-context learning.
A frozen LLM performing a new task by conditioning on demonstrations in the prompt, with no weight updates; the "learning" happens in the forward pass.
In ICL, what changes about the model's parameters?
Nothing — θ stays fixed; only the transient activations depend on the context.
State the k-shot ICL objective.
y^=argmaxyPθ(y∣x1,y1,…,xk,yk,xk+1).
Bayesian view: what do demonstrations do?
They shift the posterior p(c∣Dk) over latent tasks, concentrating it on the true task.
Why does accuracy saturate with more shots?
Log-posterior-ratio grows ≈k⋅KL, so p(c∗∣Dk)→1 exponentially; extra demos give diminishing returns.
Why does a single GD step equal linear attention?
GD from W0=0 gives y^=η∑iyi(xi⊤xk+1), the same form as attention with keys xi, values yi, query xk+1.
Why can flipped labels still give good ICL accuracy?
Demos mainly convey input distribution, label space, and format (task location); pretraining priors supply the mapping — until the task is novel/hard.
Zero-shot vs one-shot vs few-shot?
k=0,1,many demonstrations respectively.
Two biases that reveal ICL is conditioning not clean learning?
Recency bias (later demos weighted more) and majority-label bias.
ICL vs fine-tuning in one line?
Fine-tuning permanently edits weights; ICL is per-prompt, reversible conditioning.
Dekho, in-context learning ka matlab hai: aap model ko train nahi kar rahe. Model ke weights bilkul frozen hain. Aap sirf prompt ke andar do-chaar examples (demonstrations) daal dete ho, aur model unko dekh kar "game samajh leta hai" aur pattern aage badha deta hai. Jaise "cat→animal, rose→plant, dog→?" — model bina kisi training ke bol dega "animal". Yeh sab ek hi forward pass ke andar ho raha hai.
Ab kyun hota hai? Pretraining ke time model ne internet par lakhon aisi lists, tables aur Q&A threads dekhe jahan pehle wala pattern baad ke tokens predict karta hai. Next-token loss kam karne ke liye model majboor tha ki "context mein pattern pehchano aur continue karo" — yehi skill inference time pe reuse hoti hai. Bayesian tareeke se sochein: model ke andar bahut saare latent tasks ka mixture hai, aur demos us posterior ko shift kar dete hain sahi task ki taraf. Jitne zyada saaf demos, utna posterior true task pe collapse — isliye accuracy pehle tez badhti hai, phir plateau ho jaati hai (exponential concentration, p(c∗∣Dk)→1).
Ek gehri baat: attention actually ek chhota gradient descent step jaisa kaam karta hai. Keys ko inputs xi, values ko labels yi, aur query ko test input maano — attention ka output ∑iyi(xi⊤xk+1) ban jaata hai, jo bilkul ek GD step ke barabar hai. Matlab model apne activations mein ek "virtual model" train kar leta hai, par asli weights kabhi nahi badalte.
Practical tip: labels galat ho jayein tab bhi ICL kaafi accha chalta hai, kyunki demos mostly format aur label-space batate hain — actual mapping pretraining prior se aa jaati hai. Lekin agar task naya/mushkil hai, tab correct labels zaroori ho jaate hain. Aur haan — demo ka order aur recency matter karta hai, majority label ki taraf bias hota hai. Isliye prompt design ek skill hai!