Abstract
Large Language Models (LLMs) often face a fundamental trade-off between creativity and coherence during text generation. While stochastic sampling methods like top-p and min-p aim to mitigate this, they frequently struggle at high temperatures, leading to incoherent outputs. This paper introduces Top-H decoding, a novel sampling strategy grounded in information theory. By formulating the selection process as an Entropy-Constrained Minimum Divergence (ECMD) problem, Top-H strictly bounds the entropy of the sampling pool. Experimental results across various benchmarks, including Alpaca-Eval and GSM8K, demonstrate that Top-H outperforms state-of-the-art methods by over 25% in creative tasks while maintaining robustness at high temperatures with minimal computational overhead.
Introduction
When generating text, LLMs sample from a probability distribution over a vocabulary. Selecting only the most probable token (greedy decoding) often results in repetitive and sterile text. Conversely, stochastic sampling introduces the "Goldilocks problem": narrow sampling limits the model's creative potential, while wide sampling includes low-probability tokens that cause the model to spiral into nonsense or hallucinations.
Existing heuristics, such as top-p (nucleus) and min-p sampling, attempt to prune the "long tail" of unlikely tokens. However, these methods often fail to account for the overall shape of the probability distribution. For instance, min-p relies on the probability of the single most likely token, which may not accurately reflect the model's total uncertainty. Top-H decoding addresses this by using entropy as a dynamic measure of confidence, ensuring that the "chaos" of the sampling pool remains within a controlled bound.
Methodology: Entropy-Constrained Minimum Divergence
Top-H decoding is built on the principle of Entropy-Constrained Minimum Divergence (ECMD). The objective is to identify a subset of tokens that minimizes the divergence from the model's original predicted distribution while ensuring the entropy (uncertainty) of that subset does not exceed a predefined limit.
The Mathematical Framework
The authors prove that finding the absolute optimal subset for this constraint is an NP-hard problem, equivalent to a mass maximization problem. To make this practical for real-time inference, they propose a greedy approximation algorithm:
- Sorting: Tokens are sorted by their original probabilities in descending order.
- Dynamic Expansion: Tokens are added to the sampling pool sequentially.
- Entropy Bound: The process stops once the cumulative entropy of the pool reaches a threshold defined as $\alpha \cdot H(p)$, where $H(p)$ is the entropy of the original distribution and $\alpha$ is a tunable hyperparameter (typically set to 0.4).
This approach allows the sampling pool to expand naturally when the model is uncertain and contract when the model is confident, providing a more nuanced control mechanism than static probability thresholds.
Experimental Setup
The researchers evaluated Top-H across several diverse tasks and model architectures to test its versatility:
- Creative Writing: Evaluated using Alpaca-Eval and MT-Bench, with GPT-4o serving as the automated judge for narrative quality.
- Reasoning and Logic: Tested via GSM8K (mathematical reasoning) and GPQA (graduate-level science questions) to ensure that creative gains did not come at the cost of logical accuracy.
- Models: The study utilized LLaMA 3.1-8B, Qwen 2.5-3B, and Phi-3-Mini-4K, with additional validation on the LLaMA 3.3-70B parameter model.
Key Results and Insights
Superior Creative Performance
Top-H demonstrated significant improvements in creative writing tasks. On the Alpaca-Eval benchmark, it achieved a win-rate improvement of up to 25.63% over min-p. LLM-as-judge evaluations indicated that Top-H consistently produced text with superior narrative flow and more vivid imagery.
Resilience at High Temperatures
A critical finding is Top-H's stability at high temperatures (e.g., $T=2.0$). While traditional methods like top-p and min-p often see a performance collapse as they admit too much noise into the sampling pool, Top-H remains robust. Its entropy bound acts as a safety net, preventing the inclusion of incoherent tokens even when the temperature setting encourages high variance.
Maintenance of Logical Integrity
In logic-heavy tasks like GSM8K and GPQA, Top-H maintained or improved upon the accuracy of baseline methods. For the LLaMA 3.3-70B model on GPQA, Top-H outperformed min-p by more than 6%, suggesting that bounded entropy helps the model stay "on track" during complex reasoning chains.
Computational Efficiency
Despite the theoretical complexity of the ECMD problem, the greedy approximation is highly efficient. The authors reported a computational overhead of approximately 0.8%, making Top-H a viable drop-in replacement for existing sampling strategies in production environments.
Limitations and Future Work
While Top-H offers a robust solution to the creativity-coherence trade-off, the authors identify several areas for further exploration. The $\alpha$ hyperparameter, while generally effective at 0.4, may require task-specific tuning for optimal results. Additionally, because Top-H improves fluency, it could potentially make generated misinformation more persuasive; therefore, the authors emphasize the need to pair Top-H with rigorous safety and content moderation frameworks. Future research may also explore more sophisticated approximations of the NP-hard ECMD problem beyond the current greedy approach.
Conclusion
Top-H decoding represents a significant step forward in text generation strategy. By shifting the focus from simple probability thresholds to information-theoretic entropy bounds, it provides LLMs with the ability to be imaginative without sacrificing coherence. Its performance across both creative and logical benchmarks, combined with its minimal latency impact, positions it as a powerful tool for the next generation of language model applications.
Summary updated