Geometry-Aware Decoding with Wasserstein-Regularized Truncation and Mass Penalties for Large Language Models

Arash Gholami Davoodi, Navid Rezazadeh, Seyed Pouyan Mousavi Davoudi, Pouya Pezeshkpour

Abstract / TL;DR Large language models (LLMs) face a constant tug-of-war between creative diversity and logical coherence. Existing truncation-based samplers (like Top-$p$ or Top-$k$) manage this by filtering out low-probability tokens, but they rely on heuristics that ignore the underlying semantic geometry of the token space. We introduce Top-$W$, a novel decoding strategy that leverages Wasserstein distance to truncate token distributions based on semantic proximity. By considering how close tokens are in the embedding space, Top-$W$ significantly improves both reasoning accuracy and creative generation, particularly at high temperatures.

The Problem: Ignoring Semantic Geometry

When an LLM generates text, it predicts a probability distribution over its entire vocabulary. To prevent the model from selecting nonsensical, low-probability tokens, practitioners use truncation rules.

However, traditional methods treat tokens as unstructured, independent categories. They fail to recognize that "cat" and "kitten" are semantically closer than "cat" and "refrigerator." If a model must truncate its options to maintain quality, it should ideally preserve a representative "neighborhood" of meanings. Because existing heuristics ignore this semantic geometry, they often cause a collapse in coherence or a loss of creative nuance—especially when the generation temperature is increased to encourage diversity.

The Top-$W$ Solution

To address this, the authors developed Top-$W$, a geometry-aware truncation rule. The core idea is to select a subset of tokens ($S$) that minimizes a specific objective function balancing three components:

  1. Wasserstein Distance ($W_1$): This measures the "cost" of moving probability mass from the original distribution to the truncated one. By utilizing the distance between token embeddings (specifically, diagonal-whitened Mahalanobis distances), it ensures the truncated set remains semantically faithful to the model's original intent.
  2. Entropy ($H$): A penalty term that prevents the distribution from becoming too diffuse, thereby maintaining logical coherence.
  3. Mass Penalty ($\beta$): A reward for retaining more probability mass, which prevents the model from over-truncating its options.

A Computational Breakthrough

Calculating Optimal Transport (like the Wasserstein distance) is notoriously slow, typically scaling at $O(N^2)$ or $O(N^3)$. Applying this naively to a vocabulary of over 100,000 tokens would be computationally prohibitive.

The authors solve this by proving a "Prefix Optimality" theorem. They demonstrate that for a fixed geometric potential, the optimal subset is always a simple prefix of tokens when sorted by a combined score. This mathematical insight transforms a complex combinatorial problem into a fast linear scan. Implemented as a logits processor, Top-$W$ adds only about 5.4% runtime overhead compared to standard Top-$p$ sampling.

Empirical Performance

The researchers evaluated Top-$W$ across three instruction-tuned models (LLaMA-3.1-8B, Qwen2.5-3B, and Phi-3-Mini) using a diverse suite of benchmarks:

  • Reasoning and Knowledge: GSM8K (grade school math) and GPQA (expert-level science).
  • Instruction Following: AlpacaEval and MT-Bench.
  • Open-Ended Creativity: A custom rubric evaluated by GPT-4o assessing axes like imagery, narrative flow, and originality.

Key Results

  • Superior Reasoning: On GSM8K, Top-$W$ outperformed the previous state-of-the-art (Top-$H$) by up to 33.7% at high temperatures. Across 15 different model/temperature settings, Top-$W$ won or tied in 13 cases for GSM8K and 12 for AlpacaEval.
  • Temperature Robustness: Standard samplers often "break" at high temperatures (e.g., $T=2.0$), producing gibberish. Top-$W$ remains remarkably stable because its geometric penalty prevents the model from drifting into semantically unrelated territory, even when the probability distribution flattens out.
  • Enhanced Creativity: In LLM-as-a-judge evaluations, Top-$W$ successfully balanced being imaginative without becoming unstable, scoring higher for narrative flow and imagery.

Limitations and Future Directions

While highly effective, Top-$W$ does have limitations. Most notably, it requires access to the model's input embedding matrix. While this is trivial for open-weight models, it is currently impossible for closed APIs (like OpenAI's) that only expose log probabilities. Additionally, while the authors found a reliable hyperparameter "sweet spot" ($\lambda=2.2, \beta=2.8$), these values may require tuning for vastly different model architectures.

Looking forward, the authors suggest applying this geometric approach to Speculative Decoding—where a smaller draft model generates tokens for a larger verification model. Semantic alignment through Wasserstein distances could potentially speed up the verification process, opening new avenues for efficient LLM inference.

Summary updated

BibTeX
@inproceedings{davoodi2026geometry,
  author = {Arash Gholami Davoodi and Navid Rezazadeh and Seyed Pouyan Mousavi Davoudi and Pouya Pezeshkpour},
  title = {{Geometry-Aware Decoding with Wasserstein-Regularized Truncation and Mass Penalties for Large Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=HSuU4xBmAv},
}

Loading related content...

Figure