AI GLOSSARY · PROMPTS AND INSTRUCTIONS
Few-shot prompting
Definition
Few-shot prompting means putting a handful of worked examples of a task into the prompt so a language model can copy the pattern. The model's weights are not changed.
Also called: multishot prompting, few-shot examples.
In plain language
Few-shot prompting is showing the AI a few examples before asking it to do the real task. If you want product reviews labelled as positive or negative, you paste in three reviews with the right labels, then give a new review and ask for its label. The AI picks up the format and judgement from your examples. Giving none is called zero-shot, and giving one is one-shot. It is like showing a new colleague three finished forms before handing over a blank one. The limit is that the model may copy your examples too closely, including accidental patterns, and retained examples occupy context and can add token usage, with billing dependent on the service, plan and caching.
Technical definition
In few-shot prompting, demonstrations of input and output pairs are placed in the prompt and the model continues the pattern at inference time, with no gradient updates or fine-tuning. The GPT-3 paper (Brown et al., submitted May 2020) states that tasks and few-shot demonstrations are specified purely through text interaction with the model. Anthropic's guidance says examples steer format, tone and structure, should be relevant, diverse and wrapped in tags such as example, and suggests including 3 to 5. Example choice and order can change results, so they are worth testing.
Worked examples in this catalogue
Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.
Skill by Skill Almanac · Illustrative, not executed
prompt-writing 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- Prompts written and linted with a fixed structure, injection rules and a numeric test plan.
- Why it exercises the concept
- A set of examples is one part of a well-formed prompt. The test plan gives you a way to check whether a particular example set helps.
Skill by Skill Almanac · Illustrative, not executed
regex-from-labeled-examples 37/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- A Python regular expression proposed from labeled match and non-match strings, then checked against every example you supplied.
- Why it exercises the concept
- Labeled positives and negatives are the same kind of data used in a few-shot prompt, and here they are checked by running them against the result.
Skill by Skill Almanac · Illustrative, not executed
regex-case-tester 58/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- A regular expression checked against a supplied table of must-match and must-not-match strings.
- Why it exercises the concept
- The table supplies positive and negative examples of intended behaviour. Passing these finite cases does not prove behaviour on unseen strings; add independent cases to probe it.
How it shows up when you use agents
When you ask a coding agent to write commit messages, tests or log parsers in your house style, pasting two or three finished samples into the request is few-shot prompting. Instruction files such as a project's rules file often include sample outputs for the same reason. Examples occupy part of the context window when included in a request. Selection or compaction can remove them; retained tokens and caching affect usage, while charges depend on the service and plan.
What breaks when this is misunderstood: examples that are all alike teach the wrong rule, and the model copies a quirk (always the same length, always the same opening) that you never intended. Anthropic's guidance says to make examples relevant to the real use, diverse enough to cover edge cases, and clearly marked off from instructions. It also suggests 3 to 5 examples, though the right number for your task is something to test.
Next action: write the instruction first, add three varied examples that include one awkward case, run twenty real inputs, and read the failures. If the same mistake repeats, change an example, not the wording. When examples are not enough, fine-tuning changes the model itself. See prompt engineering for the wider practice.
Common confusions
- Few-shot prompting versus fine-tuning. Few-shot adds examples to the prompt for one request, and the model's weights do not change. Fine-tuning trains the model on examples and does change them.
- Few-shot versus zero-shot. Zero-shot gives instructions only. Few-shot adds examples. One-shot is the case of a single example.
- Few-shot prompting versus few-shot learning. In machine learning, few-shot learning is the wider idea of learning a task from few examples. Few-shot prompting is the version where the examples go into a prompt.
- Myth. More examples always give better results. Examples take space, and similar ones can mislead, so test the set.
Related terms
Show all 15 related terms
Terms that mention Few-shot prompting
More in Prompts and instructions
Sources
- Language Models are Few-Shot Learners, arXiv (Brown et al.) (accessed 2026-11-23)
- Prompting best practices, Anthropic (accessed 2026-11-23)
Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-25. Wikipedia is never the only source.
Review record
Last verified
Drafted by Claude (original draft) and OpenAI Codex (targeted revisions); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-25. Last verified .
Change log (5)
- : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled.
- : Targeted batch-04 source repairs; qualified scope and illustration claims. Independent affected review pending; no publication approval.
- : First version.
- : Verifier pass: Removed zero-shot and one-shot aliases.
- : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.