NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Contrastive Search Is What You Need For Neural Text Generation

Yixuan Su, Nigel Collier

Introduction

Generating text that is both coherent and creative remains a significant challenge in natural language processing. Traditional decoding strategies often fall into two traps: maximization-based methods, such as beam search, frequently result in repetitive loops, while stochastic methods, like nucleus sampling, often suffer from semantic drift or hallucinations.

Qualitative comparison of text generation methods showing beam search repetition, nucleus sampling incoherence, and the balanced output of contrastive search.

Contrastive search was recently introduced to bridge this gap. However, it was initially believed that standard language models (LMs) required an expensive additional training step (SimCTG) to become "isotropic"—meaning their internal word representations are sufficiently distinct. This paper challenges that assumption, demonstrating that most modern LMs are naturally ready for high-quality generation.

The Anisotropy Myth

The core contribution of this research is debunking the belief that most LMs are "anisotropic" (internally cramped). By evaluating a wide range of models, the authors found that the perceived lack of isotropy was largely an artifact of testing smaller, older models like GPT-2 Small and Medium.

Model isotropy scores across different architectures and parameter scales, showing that larger models naturally maintain higher isotropy.

As shown in the figure above, models like OPT, GPT-Neo, and larger versions of GPT-2 naturally exhibit high isotropy. This finding implies that the computationally intensive SimCTG training stage is unnecessary for the vast majority of off-the-shelf models available today.

Methodology: How Contrastive Search Works

Contrastive search selects the next token by balancing two competing objectives:

  1. Model Confidence: The probability of the token according to the language model.
  2. Degeneration Penalty: A measure of how similar the token's internal representation is to previously generated tokens.

By subtracting the penalty from the confidence, the algorithm forces the model to choose tokens that are likely but distinct from the existing context. The authors prove that in isotropic models, this penalty provides a high-variance "signal" that effectively prevents repetition without sacrificing coherence.

Experimental Setup and Results

The researchers evaluated contrastive search across diverse datasets, including WebText (English generation), WIT (multilingual), HumanEval (code generation), and XSum (summarization).

Key Findings:

  • Human-Level Quality: In 12 of 16 languages tested, human evaluators found text generated via contrastive search to be comparable to human-written text.
  • Superior Metrics: Contrastive search consistently outperformed nucleus and top-k sampling in diversity and coherence metrics. In specialized tasks like Python code generation, it achieved higher accuracy (Pass@1) than traditional beam search.
  • Robustness: Unlike sampling methods, which are highly sensitive to "temperature" hyperparameters, contrastive search remains stable across different settings.

Conclusion and Future Work

This paper proves that contrastive search is a "plug-and-play" solution for modern language models. By leveraging the natural isotropy of larger models, it enables the generation of diverse, non-repetitive, and coherent text without further training. While beam search remains slightly superior for strict tasks like machine translation, contrastive search is now the leading candidate for open-ended generation and knowledge probing.

Summary updated

BibTeX
@article{su2023contrastive,
  author = {Yixuan Su and Nigel Collier},
  title = {{Contrastive Search Is What You Need For Neural Text Generation}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2023},
}
Figure