Few-shot prompting provides 3-10 input-output examples in the prompt to demonstrate the desired task, format, and tone. The model infers the pattern from examples rather than explicit instructions. Key factors: example quality (gold standard examples beat average ones), example diversity (cover different edge cases), example order (recent examples are weighted more), and format consistency (violating the format in one example confuses the model).
Retrieving relevant examples at query time.
3 carefully curated, human-verified examples outperform 20 auto-generated ones. Each example is a data point teaching the model. One wrong example can skew the entire task.
Fixed few-shot examples are static templates. Dynamic examples retrieved from a vector DB pick the most relevant ones for each query. Especially valuable for classification tasks with many classes.
If 4 examples output JSON and 1 outputs plain text, the model randomly picks one. Audit your example bank regularly for format consistency. A linter for your example bank prevents this.
Sign in to share your feedback and join the discussion.