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

Abstract: Despite the remarkable capabilities of large language models, generating high-quality text remains a challenging task. Numerous decoding strategies—such as beam search, sampling with temperature, top‐ k sampling, nucleus (top‐ p ) sampling, typical decoding, contrastive decoding, and contrastive search—have been proposed to address these challenges by improving coherence, diversity, and resemblance to human-generated text. In this study, we introduce Adaptive Contrastive Search (ACS), a novel decoding strategy that extends contrastive search (CS) by incorporating an adaptive degeneration penalty informed by the model’s estimated uncertainty at each generation step. ACS aims to enhance creativity and diversity while maintaining coherence to produce high-quality outputs. Extensive experiments across various model architectures, languages, and datasets demonstrate that our approach improves both creativity and coherence, underscoring its effectiveness in text-generation tasks. We release our code, datasets, and models to facilitate further research.

## introduction the transformer @xcite plays a key role in various generative natural language processing (nlp) tasks, such as generating stories, completing contextual text, and dialogue systems. however, the conventional method of training these models using maximum likelihood estimation (mle) and decoding to the most probable sequence often results in substantial shortcomings. this can lead to repetitive and uncreative outputs, also known as degenerate text. to address this issue, previous approaches have aimed to adjust the decoding strategy by incorporating sampling from less probable vocabularies. while this helps reduce repetitiveness, it introduces the problem of semantic inconsistency @xcite . the sampled text may stray from or even contradict the original context provided by a human-written prompt. in response, contrastive search (cs, @xcite has been introduced. it employs a fixed balance between model confidence and degeneration penalty throughout the generation process, maintaining a blend of likelihood and diversity. however, it is important to note that this fixed weighting requires hyperparameter tuning and overlooks the unique demands of each generation step, where a different balance between model confidence and degeneration penalty might be desirable and even more effective. we address this limitation by proposing adaptive contrastive search (acs), an adaptive approach that automatically adjusts the hyperparameters of conventional cs. this method evaluates the model's uncertainty at each generation step and adjusts the weighting of both components without the need for manual intervention. the experimental outcomes demonstrate the effectiveness of our method, as it performs well in the task of open-ended text generation across different architectures, languages, and datasets. contributions our contributions can be summarized as follows: ## related work decoding methods are generally categorized into two types: deterministic and stochastic. deterministic methods. these approaches focus on choosing the text continuation with the highest probability according to the model's probability distribution. prominent examples are beam search and greedy search. recently, studies by @xcite ; @xcite ; @xcite ; @xcite have demonstrated that solely maximizing the output probability frequently leads to degenerated or repetitive text sequences, a problem that has been addressed by stochastic, sampling-based methods. ## experimental setup in this section, we describe the metrics, datasets, baseline models, and human evaluation settings. ## conclusion we introduce an uncertainty-guided adaptive method aimed at enhancing the quality of openended text generation outputs. our approach calculates the estimated uncertainty at each time step using shannon entropy and leverages this measure to dynamically adjust the weighting between model confidence and the degeneration penalty, as proposed by @xcite and @xcite . our experiments demonstrate that this method performs well in terms of coherence and diversity, achieving mauve scores comparable to existing methods. it receives high ratings from human evaluators, particularly for the fluency of its outputs. this method requires no hyperparameter tuning and utilizes computational resources similar to the nonadaptive cs. notably, unlike cd, it does not rely on two separate models, making it more versatile and suitable for various tasks. while it introduces some latency, our comprehensive studies comparing this approach to cs highlight its robustness across multiple languages and model sizes. we encourage further research into adaptive methods for open-ended text generation and advocate for the development of new metrics that better align with human judgments to improve the evaluation of decoding strategies.