Few-shot prompting
Use a small set of examples to demonstrate boundaries the instruction alone leaves unclear.
How to use it
- Few-shot prompts include example inputs and accepted outputs. Examples are useful for a particular voice, an ambiguous category boundary or a formatting convention that is difficult to describe briefly.
- Choose diverse examples, including a missing-value case and a near miss. Align the examples with the written instruction; conflicting examples can teach the wrong rule.
- Evaluate on new inputs, including examples with different names and lengths. Compare against a simpler zero-shot baseline to establish whether the extra context actually helps.
Prompt template
Apply {{rule}} to the final input. Examples:
{{positive_example}}
{{boundary_example}}
{{missing_value_example}}
Now process {{input}}. Follow the same output contract and do not copy example facts into the result.Check the result
- Test the boundary demonstrated by each example using a different record.
- Check that labels and field names are consistent across all examples.
Common mistakes
- Many nearly identical examples can consume context while leaving the difficult boundary undefined.