Prompt Recipes
Sam Q.4 min read17 views

Few-Shot Prompting Examples That Ship (2026)

Five copy-paste few-shot prompting examples that ship: classification, JSON extraction, tone matching, refusal, and format locking, plus the shot-count and label-bias traps.

Three example input-output cards flowing into one output card, illustrating few-shot prompting
Three example input-output cards flowing into one output card, illustrating few-shot prompting
On this page

Quick Answer

Few-shot prompting means you show the model two to five labeled example pairs before the real task, so it copies the pattern instead of guessing it. As of 2026 it is still the cheapest fix for classification, extraction, and format-matching jobs where a plain instruction drifts. Below are five copy-paste recipes, each with the exact examples block, why it works, and the failure mode that quietly wrecks it.

Few-shot is not "add more words." It is "add the right two or three demonstrations." The examples carry the spec that your prose cannot.

Reference points if you want the theory: the Prompt Engineering Guide on few-shot, Anthropic's Anthropic logo multishot prompting docs, and OpenAI's OpenAI logo prompt engineering guide. This post is the recipes those pages skip.

Recipe 1: Classification that stops arguing

Claim: a two-line instruction gives you essays. Three labeled examples give you one word.

text
Classify each support message as: billing, bug, or feature_request.
Reply with only the label.

Message: "You charged me twice this month."
Label: billing

Message: "The export button does nothing on Safari."
Label: bug

Message: "Can you add dark mode?"
Label: feature_request

Message: "My invoice shows the wrong VAT rate."
Label:

Comes back: billing. No preamble, no "Sure, here is the classification."

Why it works: the three pairs pin the output shape (one token) and the label set at the same time. You never wrote "do not explain." The examples said it.

Failure mode: unbalanced labels. Three billing examples and the model will lean billing on anything ambiguous. Balance the classes, or it inherits your accident.

Recipe 2: Extraction straight to JSON

Claim: "return JSON" is a wish. One filled-in example is a contract.

text
Extract the fields as JSON. Use null when a field is absent.

Text: "Order 4471 for Lena Ford, ships to Berlin, 2 units."
JSON: {"order_id": "4471", "name": "Lena Ford", "city": "Berlin", "qty": 2}

Text: "Refund requested by mike@acme.io, no order number given."
JSON: {"order_id": null, "name": null, "city": null, "qty": null, "email": "mike@acme.io"}

Text: "Order 9902, 5 units, customer Priya Anand."
JSON:

Comes back: {"order_id": "9902", "name": "Priya Anand", "city": null, "qty": 5, "email": null}.

Why it works: the second example teaches the hard case, missing fields become null and a new key (email) is allowed. One demonstration of the exception beats a paragraph describing it.

Failure mode: if every example has the same keys, the model drops any key it has not seen. Show at least one row with a variant shape or it will silently normalize your data away.

Recipe 3: Match a house tone

Claim: "write in our voice" is unlabeled. Two before-and-after pairs are a style transfer.

text
Rewrite the input in our style: short, direct, no hype, no exclamation marks.

Input: "We're SUPER excited to announce our amazing new dashboard!!!"
Output: "The new dashboard is live."

Input: "Unlock next-level productivity with our game-changing tool."
Output: "The tool tracks your tasks and shows what is overdue."

Input: "Introducing the revolutionary way to manage your team!"
Output:

Comes back: The tool assigns work and shows who owns what.

Why it works: the model cannot infer "our style" from an adjective. It can copy the delta between two input-output pairs. Tone is a pattern, so demonstrate the pattern.

Failure mode: examples that are too similar teach a narrow rule. Vary the inputs, or the rewrite only works on marketing fluff and breaks on a normal sentence.

Recipe 4: Teach it to say "I don't know"

Claim: models hallucinate confident answers. An example of refusal teaches restraint.

text
Answer only from the passage. If the passage does not say, reply "not stated".

Passage: "The plan renews annually."
Q: How much does it cost?
A: not stated

Passage: "Support replies within 24 hours on weekdays."
Q: What is the weekend response time?
A: not stated

Passage: "The trial lasts 14 days and then converts to the Pro plan."
Q: How long is the trial?
A:

Comes back: 14 days. And the not-stated cases actually get not stated instead of an invention.

Why it works: one worked refusal is worth ten instructions telling the model not to guess. You gave it permission and a template for the null answer.

Failure mode: if none of your examples show a real answer, the model over-refuses and returns "not stated" even when the passage does say. Balance refusals with answers.

Recipe 5: Fix format drift with a delimiter

Claim: multi-field outputs wander. A fixed delimiter in every example locks the layout.

text
Summarize each ticket as: PRIORITY | OWNER | ONE-LINE ACTION

Ticket: "Login broken for all EU users since 9am."
p1 | on-call | roll back the auth deploy

Ticket: "Typo on the pricing page footer."
p3 | marketing | fix the footer copy

Ticket: "Customer wants a CSV export they can schedule."
p2 | product | scope scheduled CSV export

Why it works: every example repeats the exact A | B | C skeleton, so the model treats the pipe layout as non-negotiable. Structure you show three times is structure you get every time.

Failure mode: change the delimiter or column order between examples and the model picks whichever it saw last. Keep the skeleton identical across all shots.

How many shots

Two to five for most tasks. One shot fixes format but not edge cases. Past five or six you hit diminishing returns and start paying for tokens that teach nothing new. If five good examples do not fix it, the problem is not shot count, it is that your examples disagree with each other.

Zero-shot first, few-shot when it drifts. If you have not tried the plain instruction, start with the zero-shot recipes, then add examples only where the output wobbles. For tasks that need reasoning between the examples, layer in chain-of-thought prompting. Building this into an agent loop? The same example blocks belong in your system prompt; see the agent tutorials on AgentNotebook.

The three failure modes, named

  1. Majority-label bias. The model copies the most frequent label in your examples. Balance the classes.
  2. Recency bias. It over-weights the last example it read. Shuffle example order, or put the trickiest case last on purpose.
  3. Format drift. Inconsistent example layouts teach an inconsistent output. Make every example structurally identical except the content.

Get those three right and few-shot does what a longer instruction never could.

Cost to test: $0.00 (every recipe above runs inside a free-tier chat message).

S

Written by

Sam Q.

Sam Q. writes terse, tested prompt recipes for PromptAttic. Senior engineer energy, commit-message prose.

FAQ

What is few-shot prompting?

Few-shot prompting is giving a model two to five worked example pairs before the real input so it copies the demonstrated pattern instead of inferring the task from an instruction alone. It is the standard fix for classification, extraction, and format-matching jobs in 2026.

How many examples should a few-shot prompt include?

Two to five for most tasks. One shot locks the output format but not edge cases; past five or six you usually see diminishing returns. If five balanced examples do not fix the output, the examples probably contradict each other.

When should you use few-shot instead of zero-shot prompting?

Start zero-shot. Add examples only when the output drifts in format, label set, or tone. Few-shot is the targeted fix for a specific wobble, not a default you reach for on every prompt.

What is the biggest mistake in few-shot prompting?

Unbalanced examples. If most of your demonstrations share one label, the model inherits that bias and leans toward it on anything ambiguous. Balance the classes and vary the example order to avoid majority-label and recency bias.

Does few-shot prompting still matter in 2026?

Yes. Larger models follow instructions better, but examples still carry specification that prose cannot, especially exact output shape, edge-case handling, and house tone. Few-shot remains the cheapest way to pin those down.

Prompt Recipes

ReAct Prompting: 6 Copy-Paste Recipes That Ship (2026)

ReAct prompting interleaves reasoning and tool calls: Thought, Action, Observation, repeat, until the model has enough to answer. It is how a plain prompt becomes an agent. Six copy-paste ReAct recipes below, each with the failure mode that bites first. Tested July 2026.

4 min read25