Providing only positive examples can leave the model unsure about boundaries. Contrastive few-shot prompting provides pairs of positive (what to do) and negative (what NOT to do) examples alongside explanations of the differences, helping the model learn precise logical limits.
Task: Extract transaction details.
[Negative Example]: Input: paid $20 for coffee Output: { "item": "coffee", "cost": "$20" } Why bad: The 'cost' field must be a number, not a string with currency symbol.
[Positive Example]: Input: paid $20 for coffee Output: { "item": "coffee", "cost": 20.00 } Why good: Correct numeric formatting without currency symbol.
Claude responds exceptionally well to explanations. Labeling sections <bad_example> and <good_example> makes the contrast clear.