Skip to main content
QUICK REVIEW

[Paper Review] Contrastive Decoding: Open-ended Text Generation as Optimization

Xiang Lisa Li, Ari Holtzman|arXiv (Cornell University)|Oct 27, 2022
Natural Language Processing TechniquesComputer Science7 citations
TL;DR

Contrastive Decoding (CD) improves open-ended text generation by optimizing the difference between log-probabilities from a large 'expert' language model and a smaller 'amateur' model, while enforcing plausibility via the expert's output. It achieves higher quality, more coherent, and lexically diverse text than decoding from the expert alone or using standard baselines like nucleus or top-k sampling, with zero additional training and minimal inference overhead.

ABSTRACT

Given a language model (LM), maximum probability is a poor decoding objective for open-ended generation, because it produces short and repetitive text. On the other hand, sampling can often produce incoherent text that drifts from the original topics. We propose contrastive decoding (CD), a reliable decoding approach that optimizes a contrastive objective subject to a plausibility constraint. The contrastive objective returns the difference between the likelihood under a large LM (called the expert, e.g. OPT-13B) and a small LM (called the amateur, e.g. OPT-125M), and the constraint ensures that the outputs are plausible. CD is inspired by the fact that the failures of larger LMs (e.g., repetition, incoherence) are even more prevalent in smaller LMs, and that this difference signals which texts should be preferred. CD requires zero additional training, and produces higher quality text than decoding from the larger LM alone. It also works across model scales (OPT-13B and GPT2-1.5B) and significantly outperforms four strong decoding algorithms (e.g., nucleus, top-k) in automatic and human evaluations across wikipedia, news and story domains.

Motivation & Objective

  • To address the limitations of maximum probability decoding, which produces short, repetitive outputs, and sampling, which often leads to incoherent or topic-drifting generations.
  • To improve open-ended text generation quality by leveraging the contrast between a large, high-performing language model (expert) and a smaller, less capable one (amateur).
  • To develop a decoding strategy that amplifies the strengths of the expert model while suppressing failure modes common in smaller models, such as repetition and incoherence.
  • To achieve better generation quality than existing decoding methods without requiring any fine-tuning or additional training.
  • To demonstrate that the method generalizes across model scales and domains, including Wikipedia, news, and story generation.

Proposed method

  • CD formulates decoding as an optimization problem that maximizes the difference between the log-probability of the next token under the expert LM and the amateur LM.
  • The objective function is defined as: $ \text{CD} = \log p_{\text{exp}}(x_i \mid x_{<i}) - \log p_{\text{ama}}(x_i \mid x_{<i}) $, where $ x_i $ is the candidate next token.
  • A plausibility constraint restricts the search to only those tokens with sufficiently high probability under the expert LM, ensuring generated text remains fluent and coherent.
  • The method operates in an autoregressive manner, selecting one token at a time based on the contrastive score, conditioned on the current context.
  • The approach uses two pre-trained, frozen language models: a large expert (e.g., OPT-13B) and a smaller amateur (e.g., OPT-125M), both of which are not fine-tuned.
  • The contrastive objective implicitly favors sequences that are highly probable in the expert but less so in the amateur, highlighting factually grounded, diverse, and coherent continuations.

Experimental results

Research questions

  • RQ1Can a contrastive objective between large and small language models improve text generation quality without additional training?
  • RQ2Does the contrast between expert and amateur models effectively suppress common failure modes like repetition and incoherence?
  • RQ3How does contrastive decoding compare to established decoding strategies such as nucleus sampling, top-k, and typical decoding across different domains?
  • RQ4Does the performance of contrastive decoding depend on the scale difference between the expert and amateur models?
  • RQ5Can contrastive decoding maintain fluency while significantly improving coherence and lexical diversity in open-ended generation?

Key findings

  • Contrastive decoding significantly improves coherence in generated text across Wikipedia, news, and story generation domains, outperforming nucleus sampling, top-k, typical decoding, and SimCTG in both automatic and human evaluations.
  • The method produces higher-quality outputs than decoding directly from the expert model alone, even though no additional training is required.
  • Human evaluations show that CD-generated text is more coherent and lexically diverse, while maintaining or improving fluency compared to baselines.
  • The performance of CD improves with larger scale differences between the expert and amateur models, indicating that the contrastive signal is stronger when the amateur model is significantly smaller.
  • CD incurs minimal inference overhead, as the amateur model is small and fast, making it practical for real-time applications.
  • In the example generation, CD correctly produced a coherent and factual continuation about the episode "Exit Through the Kwik-E-Mart" with relevant details, while nucleus sampling produced incoherent or off-topic outputs.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.