Prompting & context

Few-shot Prompting

Including a small number of worked examples in the prompt so the model can infer the pattern, format and tone you want.

PROMPT · three examplesEXAMPLES“Fast delivery, very happy.” → Positive“The returns process is a nightmare.” → Negative“Not bad, but pricey.” → MixedNEW INPUT“The parcel came late and the box was crushed.” → ?“Negative”follows the pattern shownExamples convey format, tone and edge cases better than instructions do.

swipe to see the whole diagram →

MEmehmeterkek.com/glossary/few-shot-prompting

In plain terms

Explaining exactly what you want in words is hard. Showing three good examples is easy. Few-shot prompting does the second: you put several input–output pairs in the prompt, then the new input, and the model continues the pattern. It is how you would brief a new colleague: “here are three I did earlier; do the next one the same way”.

Why it matters

Examples are the most reliable way to get consistent format and house style out of a model without fine-tuning. They take minutes to write and can be changed at any time. For classification, extraction and templated writing, a handful of well-chosen examples often brings a larger gain than switching to a more expensive model.

Example

A bank wants transaction descriptions mapped to its own 40 spending categories. With instructions alone the model invents categories. With twelve examples covering the tricky cases, such as a supermarket that also sells fuel, it uses only the bank's list and handles the edge cases as the bank would.

Most often confused with

Few-shot Prompting vs. Fine-tuning

Few-shot PromptingExamples in the prompt; the model is unchanged
Fine-tuningExamples used for training; the weights change

Both teach by example. Few-shot puts the examples into the context on every request: it is instant, flexible, and limited to what fits. Fine-tuning bakes thousands of examples into the weights: slower and costlier to set up, and worthwhile when you have many examples and stable requirements.

Under the hood

Guidelines: three to five examples are usually enough and more help on hard tasks; choose examples that are varied and cover edge cases, since models imitate surface features and will copy an accidental pattern; keep the format identical across examples; mark examples clearly with tags. Order and selection affect results, and for large example pools the most relevant examples can be retrieved per request (dynamic few-shot). Examples cost tokens on every call, which makes them good candidates for prompt caching. The underlying ability is called in-context learning.

Written by Mehmet Erkek · Last updated: