Adaptive Contrastive Search: Uncertainty-Guided Decoding for Open-Ended Text Generation

Esteban Garces Arias, Julian Rodemann, Meimingwei Li, Christian Heumann, Matthias Aßenmacher

Abstract

Adaptive Contrastive Search (ACS) is a novel decoding strategy designed to enhance open-ended text generation by dynamically adjusting creativity parameters at each time step. By leveraging Shannon entropy as a real-time measure of model uncertainty, ACS balances coherence and diversity without the need for manual hyperparameter tuning. Our evaluations across multiple datasets and languages demonstrate that ACS consistently outperforms or matches static decoding methods in both automated metrics and human preference.

Introduction

Large Language Models (LLMs) frequently encounter a "Goldilocks" dilemma during text generation. Greedy decoding strategies, which prioritize the most probable tokens, often lead to repetitive and "boring" text—a state known as model degeneration. Conversely, stochastic sampling methods can introduce excessive randomness, resulting in semantically inconsistent or nonsensical outputs.

While Contrastive Search (CS) was developed to mitigate these issues by introducing a "degeneration penalty," it relies on fixed hyperparameters ($k$ and $\alpha$). These static values often fail to account for the fluctuating confidence of a model as a sentence progresses. This paper introduces Adaptive Contrastive Search (ACS), which treats the optimal balance between likelihood and diversity as a dynamic property determined by the model's internal uncertainty.

Methods: The ACS Framework

The core innovation of ACS lies in its ability to "self-tune" based on the Shannon entropy of the model's output distribution at each time step. High entropy indicates the model is uncertain among several candidates, while low entropy suggests high confidence in a specific prediction.

The Adaptive Contrastive Search (ACS) workflow, illustrating the three-step process of computing k, alpha, and final scoring based on model uncertainty.

The ACS process follows three primary steps:

  1. Uncertainty Measurement: The model calculates the Shannon entropy of the output distribution $y_t$. This value is centered and scaled relative to the maximum possible entropy for the vocabulary.
  2. Dynamic Parameter Scaling: The scaled entropy is passed through a sigmoid-like function to automatically derive $k_t$ (the number of top candidates) and $\alpha_t$ (the weight of the degeneration penalty).
  3. Adaptive Scoring: When the model is uncertain, it prioritizes coherence (lower $\alpha$); when confident, it increases the penalty to encourage diversity and creativity.

Experimental Setup

The researchers evaluated ACS across three distinct domains to ensure broad applicability:

  • Wikinews: 2,000 examples for news-style generation.
  • WikiText-103: 1,314 examples for encyclopedic text.
  • BookCorpus: 1,947 examples for narrative story generation.

Additionally, the method was tested in a multilingual context across eight languages, including German, French, Chinese, and Bengali, to assess its universal robustness.

Key Results and Discussion

ACS achieved comparable or superior performance to standard Contrastive Search across all primary datasets. As shown in the results table below, ACS maintains a high level of diversity while achieving competitive MAUVE and coherence scores.

Quantitative comparison of ACS against standard decoding methods across Wikinews, Wikitext, and Story datasets.

Diversity vs. Coherence

A critical finding was ACS's ability to maintain lexical diversity (measured by n-gram repetition) without sacrificing the semantic flow characteristic of human-generated text. In human evaluations, ACS was frequently preferred for its fluency and coherence compared to static baselines.

The "DoubleExp" Metric Discrepancy

The study also highlighted a significant pitfall in automated evaluation. A variant method, "DoubleExp," achieved exceptionally high MAUVE scores (often used as a gold standard for distribution similarity) but was consistently rated poorly by humans for lack of coherence. This underscores the importance of human-centric evaluation in the development of decoding strategies.

Multilingual Robustness

In the 8-language evaluation, ACS showed particular strength in languages like Bengali and French. Because ACS adapts to the linguistic characteristics of the model's output automatically, it eliminates the need for language-specific hyperparameter tuning, making it a highly practical solution for global deployments.

Conclusion and Future Work

Adaptive Contrastive Search represents a significant step toward more autonomous and high-quality text generation. By grounding decoding parameters in model uncertainty, ACS provides a robust framework that generalizes across tasks and languages. While the current implementation introduces a minor latency trade-off (approx. 35% slower than static CS), the gains in text quality and ease of use are substantial. Future research will focus on testing ACS with modern isotropic models like Llama 3 and exploring additional uncertainty metrics such as KL divergence.

Summary updated

BibTeX
@inproceedings{arias2024adaptive,
  author = {Esteban Garces Arias and Julian Rodemann and Meimingwei Li and Christian Heumann and Matthias Aßenmacher},
  title = {{Adaptive Contrastive Search: Uncertainty-Guided Decoding for Open-Ended Text Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=qB0uT1hqnU},
}
Figure