Local and Global Decoding in Text Generation

Daniel Gareev, Thomas Hofmann, Ezhilmathi Krishnasamy, Tiago Pimentel

Abstract

Standard text decoding methods like top-$k$ and nucleus sampling (top-$p$) locally renormalize probability distributions at each step of generation. While this process technically distorts the language model's original distribution, this study investigates whether a "mathematically pure" global normalization would yield superior results. Our findings indicate the opposite: the distortion introduced by local decoding is a critical feature that prevents models from falling into repetitive loops and generating overly brief or incoherent text. Experiments using the Pythia model family show that local decoding consistently outperforms global decoding across standard quality metrics like MAUVE.

Introduction

When an autoregressive language model generates text, it produces a probability distribution over the vocabulary for the next token. Decoding algorithms then select a token from this distribution. Popular methods like top-$k$ or top-$p$ pruning involve throwing away low-probability candidates and locally renormalizing the remaining probabilities so they sum to 1.0 at that specific step.

This local renormalization is mathematically "messy" because the final probability of a generated sequence is no longer strictly proportional to the model's original joint distribution. This paper explores whether this distortion is a bug or a feature by comparing standard local decoding with a global decoding approach that preserves the model's original relative rankings across the entire string distribution.

Methods: Local vs. Global Normalization

The authors define two distinct paradigms for text generation:

  1. Local Decoding: Pruning and renormalization occur independently at each token step.
  2. Global Decoding: The model's distribution is pruned, but normalization is calculated across the set of all possible completed strings.
Figure 1: Comparison of probability distributions under the original language model, local decoding, and global decoding. Note how local decoding's renormalization at each step alters the final sequence probabilities compared to the global approach.

Because global normalization is computationally intractable for infinite string sets, the researchers employed Independent Metropolis-Hastings (IMH). This MCMC sampling method allows for approximate sampling from the globally normalized distribution by using the local decoding distribution as a proposal. The study utilized the Pythia model family (70M to 2.8B parameters) and evaluated performance on the WebText test set.

Results and Analysis

The core finding of the research is that "mathematically faithful" global decoding consistently produces lower-quality text than standard local decoding.

The Performance Gap

As measured by the MAUVE metric—which quantifies the similarity between model-generated and human-written text—local decoding significantly outperformed global decoding across nearly all configurations of top-$p$ sampling.

Figure 4: MAUVE scores for local (blue) versus global (green) decoding across different top-p (nucleus sampling) thresholds. Local decoding maintains higher quality as the sampling pool expands.

Why Global Decoding Fails

The study identified several key reasons for the failure of global normalization:

  • Length Bias: In global distributions, probabilities compound multiplicatively, which naturally favors shorter sequences. Local normalization constants (which are always $\ge 1$) act as a "length bonus," encouraging the model to produce more substantial, human-like outputs.
  • The Repetition Trap: Language models often assign high probability to repetitive loops. Local decoding effectively "discounts" these sequences during step-wise renormalization. Global decoding lacks this safety valve, leading to significantly higher Self-BLEU scores (indicating more repetition).
  • Coherence: Qualitative analysis showed that global decoding often devolves into disjointed phrases or irrelevant symbols, whereas local decoding maintains a more logical flow.

Conclusion

This research provides strong evidence for the "Probability-Quality Paradox": the highest probability sequences in a language model are often not the highest quality. The "broken" math of local decoding serves as a crucial heuristic that compensates for internal model biases toward repetition and brevity. Future work should focus on refining pruning strategies that intentionally leverage these beneficial distortions rather than attempting to eliminate them through global normalization.

Summary updated

BibTeX
@inproceedings{gareev2024local,
  author = {Daniel Gareev and Thomas Hofmann and Ezhilmathi Krishnasamy and Tiago Pimentel},
  title = {{Local and Global Decoding in Text Generation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.854},
}
Figure