LLM & Transformer Fundamentals·Question 17 of 109Basic

What is in-context learning, and how do you decide between it and fine-tuning?

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

In-context learning is a model performing a task specified entirely in the prompt, via instructions or examples, with no weight update. It emerged from pretraining rather than being designed in, and it is the reason the API-call era exists at all.

Full worked answer with diagram

In-context learning is a model performing a task specified entirely in the prompt, via instructions or examples, with no weight update. It emerged from pretraining rather than being designed in, and it is the reason the API-call era exists at all.

Why it works: pretraining on enormously diverse data makes "infer what task this prefix implies and continue consistently" the loss-minimising behaviour, because the corpus is full of implicit task demonstrations. Mechanistically the best-understood ingredient is induction heads: a two-head circuit that finds an earlier occurrence of the current token and copies what followed it. Their formation coincides with a sharp jump in in-context ability during training, which is one of the cleaner mechanistic stories we have.

The decision framework:

Use in-context learning when the task is describable, changes often, has low volume, or you are still iterating. It costs nothing to set up and you can change it in a text editor. The ceiling is your context budget and per-call token cost.

Use fine-tuning when the task is stable and high volume so amortised token cost dominates, when you need lower latency or a smaller model, when you have thousands of good examples, or when the behaviour resists description in a prompt (tone, a house style, a specialised output format).

One thing worth flagging because interviewers like it: for most real tasks, examples mostly are not teaching a new task. Min et al. (2022) showed that on classification, replacing demonstration labels with random wrong ones barely hurts. What the demonstrations convey is the label space, the input distribution and the output format, not the mapping. The nuance: later work found the largest models can follow consistently flipped labels, so the mapping is not ignored entirely, but the practical lesson holds. So the practical implication is that example selection and diversity matter far more than example count, and 30 near-identical examples are mostly wasted context.

Worth sketching. A decision tree keeps this from turning into a generic list of pros and cons.

flowchart TD
    S["new task"] --> D1{"can you describe it in a prompt?"}
    D1 -->|"no: tone, house style, odd format"| FT["fine-tune"]
    D1 -->|"yes"| D2{"stable and high volume?"}
    D2 -->|"no, still iterating"| ICL["in-context: instruction plus<br/>a few diverse, format-correct examples"]
    D2 -->|"yes, or latency and size limits bite"| D3{"thousands of good examples?"}
    D3 -->|"yes"| FT
    D3 -->|"no"| ICL

What a good answer covers

  • In-context learning is a model performing a task specified entirely in the prompt, via instructions or…
  • It emerged from pretraining rather than being designed in, and it is the reason the API-call era exists…
  • Why it works: pretraining on enormously diverse data makes "infer what task this prefix implies and…
  • Mechanistically the best-understood ingredient is induction heads
  • Their formation coincides with a sharp jump in in-context ability during training, which is one of the…

Interviewer follow-ups to expect

  1. If wrong labels barely hurt, what does that imply about how you should choose few-shot examples?

  2. When have you seen in-context learning genuinely fail where fine-tuning succeeded?

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