NEW
Also known as: Contrastive decoding
A decoding method that balances model likelihood with a penalty to reduce degeneration while preserving fluent, informative text.
DESCRIPTION
Contrastive search (also called contrastive decoding) ranks candidate tokens using both likelihood and a degeneration penalty, improving coherence over naive sampling. It often uses a weaker model or an unconditioned distribution to discourage generic continuations. The method mitigates repetition and blandness without sacrificing readability. It is supported in modern NLP libraries as an alternative to beam and nucleus sampling.
ALTERNATIVE DEFINITIONS
Li et al.
We propose contrastive decoding, a simple and effective decoding method that uses both a strong and a weak model to produce more informative and coherent text.
Uses a strong-weak model setup to counter degeneration.
Hugging Face
Contrastive search aims to find a balance between maximizing model confidence and avoiding degeneration to generate coherent and diverse text.
Highlights the balance between confidence and degeneration.
RELATED TERMS
Top-k Sampling Temperature Greedy Decoding Mutual Information Diverse Beam Search Deterministic Decoding Text Degeneration
COMPETING TERMS
RELATIONS
- Broader: Search
KNOWLEDGE AREAS
TARGET AUDIENCE
AI Engineer Data Scientist MLOps Engineer
EXTERNAL SOURCES
- Wikipedia - Beam search
- Li et al. - Original method paper
- Hugging Face - Library usage guide
TOP QUESTIONS
When should I use Contrastive Search instead of beam search?
Use it to reduce degeneration and repetition while retaining coherence. It’s often better for open-ended generation than pure beam search.
Category: BestPractices
What parameters matter in Contrastive Search?
Key parameters include the penalty weight and candidate pool size. Tuning them balances diversity against fluency.
Category: HowTo
How does Contrastive Search combat generic responses?
It penalizes high-probability but bland continuations using a contrasting signal, encouraging more informative choices.
Category: Concept
Does Contrastive Search increase latency?
It can, due to additional scoring steps. Efficient implementations and small candidate sets mitigate overhead.
Category: Performance
What’s a common mistake with Contrastive Search?
Over-penalizing can produce erratic text. Start with conservative penalties and validate on your domain.
Category: Mistakes
How does Contrastive Search relate to mutual information decoding?
Both reward informativeness; contrastive methods operationalize it by penalizing degenerate patterns during ranking.
Category: Comparison
Is Contrastive Search deterministic?
Implementations can be largely deterministic given seeds and fixed candidate generation, but may include stochastic components.
Category: Definition
Can Contrastive Search be combined with top-k or top-p?
Yes. Contrastive ranking can operate on a top-k/p candidate set to constrain search space and speed up decoding.
Category: HowTo
What tasks benefit most from Contrastive Search?
Open-ended dialogue, storytelling, and summarization often see improved coherence with reduced repetition.
Category: Application