Building with AI

Few-shot prompting

3 min readbeginnerUpdated 28 Sept 2026
1 · In one line

Few-shot prompting places a small set of example inputs and outputs in the prompt so the model can imitate the task on a new input.

1 · What it is

Few-shot prompting teaches by showing. You put a few solved cases in the prompt, each one an input next to the right output, and then add the new input. The model spots the pattern and answers the same way. When the examples are clear enough, some written instructions can be dropped altogether.

Nothing gets retrained. The GPT-3 paper tested this setup with the model frozen and everything given as plain text. It also named the smaller cases. One-shot means a single example plus a task description. Zero-shot means the description alone.

Which examples you pick matters a lot. One study found that changing the format, the chosen examples, or just their order could move accuracy from near guessing to near the best known score. Part of the reason is bias: models favour answers that sit near the end of the prompt or were common in their training data. So pick varied examples that cover the tricky cases, and test how many you really need.

2 · Why it exists

Instructions alone can leave the intended labels, format, or edge cases ambiguous.

Words leave gapsGoogle's prompt guide says prompts with no examples tend to work less well.
Shape is left openExamples can pin down the format, wording, and scope of a reply.
Examples can misleadNarrow or repetitive demonstrations can teach an accidental pattern instead of the intended task.
3 · How it works

Follow three demonstrations into one new classification.

Few-shot examples define a classification pattern Three labelled examples and a new ticket enter a highlighted pattern application stage, which outputs the label urgent. DEMONSTRATIONS IN THE PROMPT “Password typo”→ normal“Site is down”→ urgent“Invoice question”→ billing NEW INPUT“Checkout fails for everyone” KEY MECHANISMContinue the patterncompare task structurereuse label meaningsmatch output syntaxweights stay unchanged COMPLETIONurgentsame label format Evaluate with held-out cases: examples can teach both the intended rule and accidental correlations.
The examples define the task in context; the model applies their pattern to the new case.
  1. 1 · chooseThe developer selects relevant examples that cover the normal case and important variations.
  2. 2 · pairEach demonstration places a sample input beside the output the application considers correct.
  3. 3 · appendThe new input follows the demonstrations in the same prompt, without changing the model's weights.
  4. 4 · completeThe model continues the demonstrated pattern to produce a new output.

Examples are temporary context for this request, not training updates stored in the model.

4 · Where it's used
WhoWhat they askWhat it works with
Support operations“Which queue should receive this ticket?”Examples of tickets paired with queue labels
Content team“Rewrite this title in our style”Before-and-after title pairs
Finance team“Which expense category fits this note?”Descriptions paired with approved categories
Developer tools“Convert this command into the expected JSON”Natural-language commands paired with JSON objects
5 · What it solves, and what it doesn't
solves
  • It can demonstrate a task through text interaction without gradient updates or fine-tuning.
  • Examples can steer formatting, phrasing, scope, and recurring patterns.
  • Varied demonstrations can expose edge cases that a short instruction leaves implicit.
doesn't solve
  • Results can swing with the prompt format, the examples you pick, and even their order.
  • Models can lean toward answers placed near the end of the prompt or common in their training data.
  • Examples last only for this request; they do not permanently teach the model.
6 · Go deeper

Sources used

This explainer is written in original language. The links below support its factual claims.

  1. paperLanguage Models are Few-Shot Learners, Brown et al. · read 27 Sept 2026
  2. docsPrompting best practices, Anthropic · read 27 Sept 2026
  3. docsPrompt design strategies, Google AI for Developers · read 27 Sept 2026
  4. docsPrompt engineering, OpenAI · read 27 Sept 2026
  5. paperCalibrate Before Use: Improving Few-Shot Performance of Language Models, Zhao et al. · read 27 Sept 2026