Few-shot Prompting
A technique where showing 3-5 examples of "for this kind of question, answer this way" makes the LLM answer in the same manner. Zero examples is Zero-shot, one is One-shot.
Example: Sentiment Classification
Classify the following reviews as "pos / neg / neutral":
Review: "The wait was long and tiring"
Class: neg
Review: "The food was good but the price is so-so"
Class: neutral
Review: "The staff was kind and it was comfortable"
Class: pos
Review: "[target]"
Class:
How You Pick Examples Is Key
- Diversity: not only similar examples; include different patterns
- Boundary cases: include one hard-to-judge intermediate example
- Same format: unify output format in examples and production
- Order effect: the last example influences the result more
Cases Where Few-shot Works
- Unique output formats (CSV, special JSON)
- Company-specific tone
- Use of jargon
- Examples including "this way of answering is bad"
