Few-shot
Few-shot prompting includes examples that demonstrate a desired input-output pattern without updating model weights.
Before you start: Review System prompt first. Python-like examples use variables, lists and functions.
Follow the mechanism
Task definition
Define labels and boundaries.
Start with an everyday explanation
Show a new teammate several correctly labeled support messages before asking them to label another. The examples guide the task but do not cover every exception.
See a concrete example
Examples map refund to billing and denied claim to claims. “I was billed after my claim was denied” may require multi-label handling or clarification.
A claim to question
Examples do not replace a clear label definition or unbiased evaluation.
Try before revealing the answer
Add an ambiguous example and define when the router should return needs_review.
Show the worked answer
Use needs_review when evidence supports multiple categories under a single-label contract. Evaluate false routing costs rather than forcing every message into a confident category.
Now explain the idea to someone else using your own example. If you cannot explain a stage, revisit it before moving on.
Engineering details and trade-offs
Choose examples representing boundaries, ambiguous cases and the actual output format. Separate examples from the live input.
Compare against a zero-shot baseline on a held-out set. Avoid leaking test answers into prompts or assuming more examples always improve accuracy.
Reason through the example
Examples map refund to billing and denied claim to claims. “I was billed after my claim was denied” may require multi-label handling or clarification.
Implement and test
Add an ambiguous example and define when the router should return needs_review.
Inspect the reasoning and expected result
Use needs_review when evidence supports multiple categories under a single-label contract. Evaluate false routing costs rather than forcing every message into a confident category.
What to measure
State the expected result before changing a control. Record your inputs, compare the observed result and explain one limit of this model. In a real implementation, test the failure case as well as the normal path.
Answer before reading the reference
How do you choose few-shot examples?
A defensible answer
Use representative, verified examples that cover confusing boundaries and realistic formats. Keep evaluation queries separate and measure the effect of example choice, order and token cost.
Prepare the follow-up
What experiment detects order sensitivity or majority-label bias?
Show follow-up reasoning
Rotate example order and class balance while holding held-out queries fixed. Compare per-class confusion matrices and unstable predictions. If an order effect is material, improve definitions and representative examples or use a more suitable classifier; do not choose an order by testing on the final test set.
Use the engineering explanation and worked task above to support your response. Identify which assumptions you would need to verify in production.
Choose a practice depth
- New to GenAI
- Define few-shot with the everyday example and name its key limitation.
- Applied experience
- Explain the example, implementation choice and a measured failure case. Use the exercise as a small design review.
- Senior or systems depth
- Answer the follow-up, compare alternatives and justify an evaluation or rollout plan with operational constraints.
Self-review your answer
0/4 checks selected. This is self-assessment, not an interview score.
Your explanation and revision notes
Loading local notes…