Language Model Decoding as Direct Metrics Optimization

Haozhe Ji, Pei Ke, Hongning Wang, Minlie Huang

Overview

DAEMON transforms language model decoding from a series of heuristic "hacks" into a formal optimization problem. It forces generated text to match human-level performance across multiple metrics—like coherence and repetition—simultaneously. By framing decoding as an Energy-Based Model (EBM), DAEMON provides a mathematical guarantee that it better approximates the true distribution of human language, leading to more "human-like" text than standard sampling or search methods.

The Decoding Dilemma

Modern Large Language Models (LLMs) are excellent at predicting the next word, but they often "drift" during long-form generation. Current decoding strategies usually fall into two flawed camps:

  1. Sampling-based methods (like Nucleus or Top-k) avoid the "unreliable long tail" of low-probability words but often produce disjunctive, incoherent text.
  2. Search-based methods (like Beam Search) maintain topic flow but frequently fall into "degenerated modes," leading to repetitive, robotic sentences.

Practitioners usually play a game of "whack-a-mole," tuning hyperparameters to fix repetition only to find that coherence has dropped. DAEMON addresses the lack of a holistic alignment strategy—a way to satisfy multiple quality constraints all at once without manual, heuristic-heavy tuning.

The DAEMON Approach

The authors introduce DAEMON (Decoding As DirEct Metrics OptimizatioN). Instead of just picking the most likely words, DAEMON searches for a decoding distribution that is as close as possible to the original model while strictly matching the expected scores of human text across a set of chosen metrics.

Probability distribution shift using DAEMON's energy function
  • The Energy-Based Solution: The optimal solution is an Energy-Based Model (EBM). It takes the base LM's probability and scales it by a sequence-level "energy function." This energy function is a weighted sum of the target metrics (e.g., a penalty for high repetition or a bonus for high coherence).
  • Coefficient Estimation: To find the right weights for these metrics, the method uses Weighted Importance Sampling (WIS) on a small development set, allowing the model to "learn" how much to prioritize each metric.
  • Sampling-Importance-Resampling (SIR): Since the EBM is "globally normalized" and hard to sample from directly, DAEMON generates multiple candidate continuations in parallel using the base LM, then resamples the best one based on the calculated energy scores.

Key Insights

  • Reverse KL Optimization: Most models are trained using "Forward KL" (mean-seeking), which tries to cover every possible human sentence but often includes low-quality "noise." DAEMON minimizes "Reverse KL" (mode-seeking), forcing the generator to stay within the high-quality regions of the model's knowledge.
  • The Perplexity Guarantee: In a rare theoretical win for decoding papers, the authors prove that DAEMON is guaranteed to improve perplexity on human texts compared to the base LM. The energy function isn't just a filter; it makes the model a better representative of human language.
  • Sequence-Level Judgment: Unlike standard decoding which makes local, token-by-token decisions, DAEMON's energy function evaluates the entire generated sequence, catching long-range issues like topic drift or structural repetition.

Experimental Results

The researchers evaluated DAEMON across several domains (Wikipedia, News, Summarization) and model scales (GPT-2 XL, OPT-6.7B).

Comprehensive evaluation of DAEMON against baseline decoding methods
  • Metric Alignment: DAEMON achieved the closest match to human-level scores across repetition (SR-4), coherence (COH), and diversity (DIV) compared to strong baselines like Contrastive Search and Nucleus Sampling.
  • MAUVE Scores: It consistently achieved the highest MAUVE scores—a metric measuring how similar the generated distribution is to the human distribution—reaching 97.4 on the News domain (vs. 95.0 for Typical sampling).
  • Human Evaluation: In side-by-side comparisons, human judges significantly preferred DAEMON over all baselines in terms of Coherence (e.g., winning 66% of the time against Nucleus sampling).
  • Efficiency: Because candidate generation is parallelizable, DAEMON is faster in practice than complex search-based methods like Contrastive Search.

Limitations and Future Work

  • Metric Dependency: DAEMON's performance is tied to the quality of the metrics used in the constraints. If a metric doesn't capture a specific nuance of human language, DAEMON won't optimize for it.
  • Candidate Budget: The method relies on the base LM being "good enough" to produce at least one high-quality candidate in the initial set of samples.
  • Future Directions: The authors suggest extending the framework to handle inequality constraints (e.g., "repetition must be less than X") and incorporating human-preference metrics similar to those used in RLHF.

Summary updated

BibTeX
@inproceedings{ji2024language,
  author = {Haozhe Ji and Pei Ke and Hongning Wang and Minlie Huang},
  title = {{Language Model Decoding as Direct Metrics Optimization}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=488A64eOf6},
}
Figure