Study FAQ
How should I select and test few-shot examples for an ambiguous Claude task?
Also asked as 2
- Which examples help Claude learn a decision boundary without copying unrelated facts?
- How do I check whether a Claude few-shot example set generalizes to new inputs?
Answer
Select verified input/output pairs that demonstrate the task's decision rules, including a plausible alternative that should receive a different answer and an appropriate missing-information outcome. Keep every example consistent with the current policy and output contract, then evaluate new inputs that were not demonstrations.
For a reviewer allowed to flag null dereferences, contrast a function that receives permitted null and fails with one whose actual caller excludes null. The same string-method syntax can be valid in the second case. Show the relevant caller premise and expected finding or no-finding result rather than teaching a syntax-based alarm. For extraction, vary layout and wording while preserving units, approximation and missing values.
Separate instructions, demonstrations and the target input. Examples can teach tone or structure; their names, prices, dates or contact details must not become facts about the new target. Use complete outputs with the fields the consumer actually expects.
When a static set becomes unwieldy, retrieve examples from a verified collection. Check task, policy and schema compatibility, remove near-duplicates, and handle an empty or conflicting selection explicitly. Similar wording alone does not make a demonstration suitable.
Compare the baseline and revised prompt on the same held-out cases. Check decisions, required fields, unsupported values and uncertainty handling, including unfamiliar layouts. Evaluate example retrieval as well as generation. Expand the set to address observed gaps; an example count alone cannot establish adequate coverage.
Full explanation
Apply few-shot prompting to improve output consistency and quality
Learning material · CCAR-F
Read the full explanation