Q1. What is Contrastive prompting?
Contrastive prompting is a technique that presents the model with both positive and negative examples to help it learn distinctions.
Instead of only showing correct input-output pairs, you also show examples of what not to do or common mistakes.
This helps the model understand boundaries and avoid errors.
For example, in a classification task, you might provide examples of correctly classified texts and also examples of borderline cases that should be rejected.
Contrastive prompting can also involve asking the model to explain why one answer is better than another.
It is especially useful for tasks with nuanced differences, such as sentiment analysis with neutral cases, or distinguishing between similar concepts.
Instead of only showing correct input-output pairs, you also show examples of what not to do or common mistakes.
This helps the model understand boundaries and avoid errors.
For example, in a classification task, you might provide examples of correctly classified texts and also examples of borderline cases that should be rejected.
Contrastive prompting can also involve asking the model to explain why one answer is better than another.
It is especially useful for tasks with nuanced differences, such as sentiment analysis with neutral cases, or distinguishing between similar concepts.
Q2. How does Contrastive prompting differ from standard few‑shot prompting?
Standard few‑shot prompting provides only positive examples (correct input-output).
Contrastive prompting adds negative examples (incorrect inputs or outputs) to highlight what is wrong.
Example for sentiment classification: Positive example: "I love this product → Positive". Negative example: "I love this product but it broke → Not Positive (or Neutral)". The negative example teaches the model to consider caveats.
Contrastive prompting can also ask the model to generate contrasting explanations: "Why is A correct but B incorrect?".
This explicit contrast sharpens the model's decision boundaries, leading to higher accuracy on ambiguous inputs.
Contrastive prompting adds negative examples (incorrect inputs or outputs) to highlight what is wrong.
Example for sentiment classification: Positive example: "I love this product → Positive". Negative example: "I love this product but it broke → Not Positive (or Neutral)". The negative example teaches the model to consider caveats.
Contrastive prompting can also ask the model to generate contrasting explanations: "Why is A correct but B incorrect?".
This explicit contrast sharpens the model's decision boundaries, leading to higher accuracy on ambiguous inputs.
Q3. Give a concrete example of Contrastive prompting for a reasoning task.
Task: Determine if a number is prime.
Standard few‑shot: "5 → prime, 7 → prime".
Contrastive prompt adds: "4 → not prime (because divisible by 2), 9 → not prime (3×3), 11 → prime, 15 → not prime (3×5)".
The negative examples show the model what composite numbers look like.
For a more abstract task like analogy: "apple : fruit :: carrot : ?". Positive example: "apple : fruit :: carrot : vegetable". Contrastive example: "apple : fruit :: carrot : root (incorrect, because carrot is a vegetable, not just any root)".
This helps the model learn the precise relationship.
Standard few‑shot: "5 → prime, 7 → prime".
Contrastive prompt adds: "4 → not prime (because divisible by 2), 9 → not prime (3×3), 11 → prime, 15 → not prime (3×5)".
The negative examples show the model what composite numbers look like.
For a more abstract task like analogy: "apple : fruit :: carrot : ?". Positive example: "apple : fruit :: carrot : vegetable". Contrastive example: "apple : fruit :: carrot : root (incorrect, because carrot is a vegetable, not just any root)".
This helps the model learn the precise relationship.
Q4. What are the benefits of using Contrastive prompting?
Benefits include:
• Improved discrimination between similar categories.
• Reduced false positives/negatives.
• Better handling of edge cases.
• The model learns not just patterns but also boundaries.
• Can be combined with explanation generation to improve interpretability.
• Particularly effective when the task has a small number of categories but subtle distinctions (e.g., medical diagnosis from symptoms).
Contrastive prompting is also used in fine-tuning (contrastive learning), but it works in few‑shot as well.
Studies show that adding even a single contrastive example can significantly boost performance on tasks like natural language inference and paraphrase detection.
• Improved discrimination between similar categories.
• Reduced false positives/negatives.
• Better handling of edge cases.
• The model learns not just patterns but also boundaries.
• Can be combined with explanation generation to improve interpretability.
• Particularly effective when the task has a small number of categories but subtle distinctions (e.g., medical diagnosis from symptoms).
Contrastive prompting is also used in fine-tuning (contrastive learning), but it works in few‑shot as well.
Studies show that adding even a single contrastive example can significantly boost performance on tasks like natural language inference and paraphrase detection.
Q5. What are potential downsides of Contrastive prompting?
Downsides include:
• Increased prompt length (more examples).
• The model might overgeneralize from negative examples if they are not representative.
• Choosing effective negative examples requires domain expertise – bad negatives can confuse the model.
• May cause the model to be overly cautious or reject correct answers that resemble negatives.
• Not all tasks have clear negative examples.
• More token usage leads to higher cost.
To mitigate, use a small number of carefully selected contrastive examples and test thoroughly.
For some tasks, generating negatives automatically (e.g., by perturbing positives) can help.
• Increased prompt length (more examples).
• The model might overgeneralize from negative examples if they are not representative.
• Choosing effective negative examples requires domain expertise – bad negatives can confuse the model.
• May cause the model to be overly cautious or reject correct answers that resemble negatives.
• Not all tasks have clear negative examples.
• More token usage leads to higher cost.
To mitigate, use a small number of carefully selected contrastive examples and test thoroughly.
For some tasks, generating negatives automatically (e.g., by perturbing positives) can help.
