Zero-Shot and Few-Shot Prompts
Level 2 · Writing a better prompt
The difference between zero-shot, one-shot and few-shot prompts. When a worked example helps, how to pick good ones, and what they cost.
Course contentsLesson 5 of 16
Level 1 · What a prompt is
Level 2 · Writing a better prompt
Level 3 · Harder and bigger tasks
Level 4 · Prompts inside an app
After this lesson you can
- Tell zero-shot, one-shot and few-shot prompts apart
- Pick varied examples that show a pattern
- Say why examples do not train the model
12 mincovers 3 glossary entries
Worth reading first: Prompt Delimiters and Tags
How many worked examples a prompt needs
A zero-shot prompt asks for a task with no worked examples. A one-shot prompt adds one, and a few-shot prompt adds a few, often two to five. Each example shows an input and the answer you want. A 2020 paper on GPT-3 showed a model could pick up a task from examples alone.
Start with zero-shot. Large models have seen so many tasks that a clear request is often enough. Is this review happy or unhappy needs no example. Zero-shot is the cheapest prompt, and it shows you what the model does on its own.
Add one example when the format comes out wrong. One worked answer shows the length, the layout and the tone better than a page of rules. The risk is that the model copies that one example too closely. It takes its words and quirks as well as its shape.
Add a few when one cannot show the whole pattern. Pick examples that differ from each other: a short input and a long one, an easy case and a hard one. Varied examples teach the pattern. Three that look alike teach the model to copy them.
Examples do not train the model. They only steer the request they sit in, and they cost tokens every time it is sent. Five long examples on a prompt sent 10,000 times a day add up to a real bill.
Wrap the examples in tags, so the model can tell them from the real task, and put the real task last. Check the answers in your examples with care. A model will copy a wrong answer in an example just as faithfully as a right one.
Newer models often need fewer examples than older ones. Many can follow a clear note on the format with none at all. So try the note first. Add examples only for what words cannot pin down, such as a tone, a style or a tricky case.
Which one to pick
Worked example
Emma tags products in her shop
Emma asks for three tags for each product in her shop. Zero-shot, the tags come back in mixed styles, some long and some with capitals.
She adds two products with the tags she wants, inside example tags. All 40 of her test products then come back in her style.
The words for this lesson3
Check yourself
What happens to a model after you give it a few-shot prompt?
Finished this lesson?
Marking it complete also marks its 3 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.