From telling to showing
Sometimes a task is hard to describe but easy to demonstrate. Instead of explaining the rule, you show a few input-output pairs and let the model infer the pattern. Adding examples to the prompt is few-shot prompting ('few' as in two to a handful), in contrast to the zero-shot approach from the last guide.
Convert each company name to a stock-ticker guess. Apple -> AAPL Microsoft -> MSFT Nvidia -> NVDA Netflix ->
An autoregressive loop that feeds each predicted token back in to produce the next one.
You never updated the model's weights — the learning happened entirely inside the prompt window, for this one request. That is the headline idea of the whole field.
In-context learning: learning without training
This ability to pick up a task from examples placed in the prompt, with no weight change, is in-context learning (ICL). It was one of the surprises of large models: feed a pattern and the model treats it as a temporary instruction. The examples are not stored; when the conversation ends, the 'lesson' is gone. Each new prompt re-teaches from scratch.
Few-shot in-context learning: the model predicts the answer conditioned on the k demonstrations and the query, with the weights θ left unchanged.
Because examples live in the prompt, they compete for space with everything else. Every demonstration spends tokens and counts against the context length. Three sharp examples usually beat ten sloppy ones.
Choosing which examples to show
Which examples you include matters as much as how many — this is demonstration selection. The model leans on the examples as a guide, so pick ones that genuinely represent the task, including the tricky shapes you care about.
Interactive self-attention highlighting which words each token attends to.
- Cover the variety you expect at inference time — not three near-identical easy cases.
- Include at least one edge case (an empty field, an ambiguous input) so the model learns how to handle it.
- Keep label balance: if you only show positive examples, the model may stop predicting negatives.
- Order can matter; a strong, unambiguous example near the end often anchors the format the model copies.
Formatting examples consistently
Examples teach format as well as content, so be ruthlessly consistent. Use the same separator between input and output, the same casing, the same field names. Strong delimiters and formatting let the model see where one example ends and the next begins — and let it copy the exact shape you want for its own answer.
If you reuse the same structure across many requests, lift the fixed parts into a prompt template: a reusable skeleton with slots you fill in. The examples and instructions stay constant while only the new input changes, which removes a whole class of accidental inconsistency.
Task: {task_description}
Examples:
{example_1}
{example_2}
{example_3}
Now do the same for:
Input: {new_input}
Output:When examples help — and when they don't
Reach for few-shot when the task has a specific format or an unusual convention the model won't guess, or when zero-shot keeps drifting from what you want. Stay zero-shot when the task is common and a clear instruction already nails it — examples then just spend tokens for no gain.