AI Dictionary › 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.
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.
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.
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.
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.
Il prompt contrastivo e' una tecnica in cui si mostra al modello, all'interno dello stesso prompt, sia un esempio corretto sia uno scorretto (o un esempio buono e uno mediocre) dello stesso tipo di compito, in modo che il confronto diretto tra i due chiarisca al modello quali caratteristiche distinguono una risposta valida da una da evitare.
A differenza del semplice few-shot, dove si mostrano solo esempi positivi da imitare, qui il prompt esplicita anche cosa non va in un esempio negativo, spesso accompagnato da una breve spiegazione del perche' quell'esempio e' inadeguato. Il modello puo' cosi' apprendere non solo il pattern da seguire ma anche il confine che separa un output accettabile da uno da scartare.
Questa tecnica e' utile quando esistono errori tipici e ricorrenti che si vogliono prevenire esplicitamente: mostrare un esempio di risposta troppo prolissa accanto a una concisa e ben calibrata per un servizio clienti, oppure confrontare una spiegazione tecnica corretta con una che contiene un errore concettuale comune, spiegando la differenza.
Il termine richiama il concetto di apprendimento contrastivo, gia' noto in ambito di machine learning come tecnica che insegna a un modello a distinguere esempi simili ma di classi diverse, qui adattato al prompting come modo per rendere piu' nitidi i confini di una risposta corretta attraverso il confronto diretto.
From our network
INDACO TMS — Transport Management for European Logistics
Shipment tracking, multi-carrier EDI and automated invoicing in one cloud platform. Invoices generated in under 10 seconds.
Visit indacotms.com →From the Agora Intelligence blog
📱 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.