By Ryze AI Team
Few-shot prompting anchors model behavior by showing examples instead of only describing the task. It is one of the most reliable prompt techniques and costs nothing but tokens.
Gather 5 to 10 input-output pairs that represent the task and its edge cases. Use real data, not invented examples, because the model learns the distribution of your actual inputs.
Use a fixed template and repeat it for each example, then add the real input:
Input: How do I reset my password?
Output: Go to Settings > Security > Reset password.
Input: Where can I find my invoices?
Output: Invoices are under Billing in your account dashboard.
Input: {{user_question}}
Output:
Models attend more to recent context. Put the most representative example last, and put edge cases first so the model has seen them. If you have many examples, experiment with ordering; it measurably affects results.
Run your eval set with 0, 2, 5, and 10 examples. Pick the smallest count that hits your target accuracy. More examples help up to a point, then add noise and cost.
Each example adds tokens to every request. For high-volume features, the few-shot prompt may dominate cost. When that happens, distill the behavior into a fine-tuned model and drop the examples.
Keep examples consistent in format and tone. Include at least one edge case. And re-test after any model change, because few-shot effectiveness varies by model.