Applied AI / Forward Deployed Engineer · Prompt Engineering · Lesson 2 of 4
Zero-shot, few-shot & in-context learning
In-context learning is the model's ability to learn a task from examples in the prompt — no training required.
- Zero-shot: just instructions, no examples. Fine for simple, well-known tasks.
- Few-shot: include 2–8 input→output examples. Dramatically improves format adherence and edge-case handling. The single highest-leverage technique after clear instructions.
- Pick examples that are diverse and cover the tricky cases (including a 'none/other' example). Keep formatting identical to what you want back.
Few-shot = teaching by demonstrationIf you can't precisely describe the rule, show it. Two good examples of the exact output you want often beat three paragraphs of instructions.
Watch the costEvery few-shot example is tokens on every call — cost and latency. If examples get large or numerous, that's a signal to consider fine-tuning or retrieval of examples (dynamic few-shot).
◆ Lock it in
- Few-shot examples are the highest-leverage lever after clear instructions.
- Choose diverse examples covering edge cases and the 'none' case; match the exact output format.
- Examples cost tokens on every call — a lot of them hints at fine-tuning/dynamic selection.
Feynman drill — say it out loudWhen would you switch from few-shot prompting to fine-tuning? Give the tradeoff.
Step 1 rate your confidence · Step 2 pick your answer
Your extraction prompt gets the format wrong ~20% of the time with zero-shot. Cheapest first fix?
Step 1 — how sure are you?