Prompt & Context Engineering·Question 15 of 68Intermediate

Why does in-context learning work at all? The model's weights don't change.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

The one-line answer: pretraining on internet-scale text teaches the model to be a general pattern-continuer, and few-shot examples are evidence that locates which of the many tasks it already knows is being asked for. No weights change - the "learning" is inference-time conditioning.

Full worked answer

The one-line answer: pretraining on internet-scale text teaches the model to be a general pattern-continuer, and few-shot examples are evidence that locates which of the many tasks it already knows is being asked for. No weights change - the "learning" is inference-time conditioning.

Three complementary levels of explanation worth giving:

Task location / implicit Bayesian inference. Pretraining corpora are full of repeated structures - Q&A lists, translation pairs, tables, code with tests. A model trained to predict the next token over such data learns to infer the latent "format/task" of the current document and continue it. Few-shot examples sharpen the posterior over which task is active. This explains Min et al.'s (2022) surprising result that demonstrations with random labels often barely hurt: much of the benefit is specifying the input distribution, label space, and format - locating the task - rather than teaching the mapping.

Mechanistic: induction heads. Anthropic's interpretability work (Olsson et al., 2022) identified attention-head circuits that implement "find an earlier occurrence of a similar token, copy what followed it" - a primitive match-and-copy operation. Induction heads emerge early in training in a phase change that coincides with the emergence of in-context learning ability, making them a plausible mechanistic substrate for pattern completion over the prompt.

Learned inference algorithms. A research thread (Garg et al., von Oswald et al., 2022-23) shows transformers can be trained to implement simple learning algorithms - approximating gradient-descent-like updates or ridge regression - inside the forward pass on toy tasks. Whether frontier models do this on real tasks is unsettled; present it as suggestive, not established.

For an engineering interview, the takeaway matters more than the theory: ICL is task retrieval and conditioning, not weight updates - which predicts its failure modes: it can't add genuinely new knowledge, it's sensitive to surface format, and it inherits pretraining biases about what patterns are likely.

What a good answer covers

  • The one-line answer: pretraining on internet-scale text teaches the model to be a general…
  • No weights change - the "learning" is inference-time conditioning
  • Task location / implicit Bayesian inference
  • Pretraining corpora are full of repeated structures - Q&A lists, translation pairs, tables, code with tests
  • A model trained to predict the next token over such data learns to infer the latent "format/task" of the…

Key terms: Mechanistic: induction heads · Learned inference algorithms

Interviewer follow-ups to expect

  1. What does the random-label result imply about how you should invest in example quality?

  2. Why does ICL improve with model scale?

  3. What can fine-tuning do that ICL fundamentally can't?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep