home/productivity/few-shot-prompting

Few Shot Prompting

GPTClaudeDeepSeek··136 copies·updated 2026-07-14
few-shot-prompting.prompt
# Few-Shot Prompting

## Why this matters

A few-shot prompt is the trick where you teach a task by example. Instead of describing every edge case in prose, you show the model two or five worked input/output pairs and let it generalize. For narrow, well-defined tasks — classification, extraction, transformation, formatting — a small set of examples often beats a paragraph of instructions, and it is much easier to update.

The technique is older than instruction-tuned chat models (it was Brown et al., 2020, that named it "in-context learning"), and it still works on modern models because the pattern in the prompt is exactly what the model is trained to continue.

## Zero-shot vs. few-shot vs. fine-tuning

A quick mental map:

- **Zero-shot** — instruction only, no examples. Cheapest, lowest signal.
- **Few-shot** — instruction plus 1–8 worked examples in the prompt. More tokens per call, but no training and no infra.
- **Fine-tuning** — bake the pattern into the weights. Lower per-call tokens, requires data prep and training infra, and you re-do it whenever the model changes.

For most application work, you start zero-shot, escalate to few-shot when the failure mode demands it, and only consider fine-tuning when you have a large, stable, valuable dataset and the per-call savings justify the overhead.

## What examples are good at

Few-shot earns its tokens when:

- The output **shape** is fiddly and hard to describe in prose (a specific JSON schema, a domain-specific tagging convention, a particular tone).
- There are **edge cases** whose handling is hard to specify but easy to demonstrate (how to label borderline categories, how to phrase a refusal).
- The model **keeps drifting** from a specific format despite clear instructions ("write in the second person", "always use Australian spelling", "limit to 12 words").

Examples are weaker when:

- The task is **open-ended** ("brainstorm 20 ideas"). Examples bias toward their own pattern.
- The input space is **wide and unstructured** and your few examples are not representative.
- The model already **handles it perfectly zero-shot**. Then examples are just spent tokens.

## Where to put the examples

Two common placements:

**1. Inside the system block, as a labeled exhibit:**

when to use it

Community prompt sourced from the open-source GitHub repo ai-engineering-curriculum/agentic-ai-developer-learning (MIT). A "Few Shot Prompting" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

productivitycommunitydeveloper

source

ai-engineering-curriculum/agentic-ai-developer-learning · MIT