AI Dictionary › Prompting

Contrastive Prompting

Prompt Contrastivo

Contrastive prompting is a technique in which the model is shown, within the same prompt, both a correct and an incorrect example (or a good and a mediocre one) of the same type of task, so that the direct comparison between the two clarifies to the model which characteristics distinguish a valid response from one to avoid.

Definition

How it works

Unlike simple few-shot, where only positive examples to imitate are shown, here the prompt also makes explicit what is wrong with a negative example, often accompanied by a short explanation of why that example is inadequate. The model can thus learn not only the pattern to follow but also the boundary separating an acceptable output from one to discard.

Applications

This technique is useful when there are typical, recurring errors one wants to explicitly prevent: showing an example of an overly verbose response next to a concise, well-calibrated one for a customer service context, or comparing a correct technical explanation with one containing a common conceptual error, explaining the difference.

History & etymology

The term echoes the concept of contrastive learning, already known in machine learning as a technique that teaches a model to distinguish similar examples belonging to different classes, here adapted to prompting as a way to sharpen the boundaries of a correct response through direct comparison.

How to use it

Show the model a good example AND a bad one, and say why each earns its label. The contrast carries more signal than either example alone: the model learns the boundary, not just the target.

A concrete example

"Write a cold email opener. GOOD: 'Saw your team just shipped the mobile app: the onboarding flow is sharp.' (specific, earned). BAD: 'I hope this email finds you well.' (generic, skippable). Now write 3 openers for a CFO at a logistics company."

When to use it (and what to watch)

When quality is easy to recognize but hard to describe: tone, style, taste. One good/bad pair usually beats three good examples. Keep the bad example genuinely plausible, not a straw man.

More prompting techniques

Multi-turn prompting · JSON mode · Prompt scaffolding · Context stuffing · Retry with backoff · Self-ask · Chain-of-thought · Role prompting · Prompt injection · Temperature · System prompt

How it's used in Grace

Grace often uses comparisons between a valid answer and one to avoid, so you can see precisely where the line sits in a scenario.

Related terms

More in Prompting

Put it into practice

From our network

AGORÀ Intelligence: Enterprise AI Governance Platform

Govern AI at scale: policies, adoption and measurable results on your data. Built for boards and C-suite.

Visit agora-intelligence.com →

From the Agora Intelligence blog

More on agora-intelligence.com →

📱 Download the Android app (beta) iOS coming soon

Say what you mean. Get what you need.

Grace Certified, the AI coach that trains and certifies your prompt engineering, by Agora Intelligence.