Reference · How-to · ~6 min
How to write a few-shot prompt
Show the model **2–5 examples** of input → desired output so it copies the pattern.
Show the model **2–5 examples** of input → desired output so it copies the pattern.
Steps
1. Pick a **repeatable task** (classify, format, extract fields)
2. Write 2–3 diverse **input/output pairs**
3. Add one line of **instruction** above the examples
4. End with a new input and leave output blank for the model
5. Test on edge cases; add one more example if it drifts
Template
Task: [one sentence]
Example 1
Input: [text]
Output: [ideal]
Example 2
Input: [text]
Output: [ideal]
Now complete:
Input: [new text]
Output:Example (sentiment)
Classify sentiment as positive, neutral, or negative.
Input: "Best support ever!"
Output: positive
Input: "It arrived late."
Output: negative
Input: "It's okay I guess."
Output: