Hugging Face

Generating Human-level Text with Contrastive Search in Transformers 🤗

Nov 8, 2022
Generating Human-level Text with Contrastive Search in Transformers 🤗
SummaryAI, from the source post

This post details the integration of Contrastive Search into the Hugging Face Transformers library, providing code examples for PyTorch and TensorFlow. It explains the decoding objective, which balances model confidence with a degeneration penalty based on token representation similarity, and demonstrates its effectiveness in generating long, coherent, and non-repetitive text compared to greedy and nucleus sampling methods. It also highlights a live demo comparing Contrastive Search with other decoding methods.