DiffSampling: Enhancing Diversity and Accuracy in Neural Text Generation

Giorgio Franceschelli, Mirco Musolesi
2/19/2025
6 citations
cs.CLcs.AIcs.LG

No official code found. Best implementation: giorgiofranceschelli/DiffSampling-tmlr (0 stars, Jupyter Notebook, MIT, last commit 2025-12-29).

Abstract

Despite their growing capabilities, language models still frequently reproduce content from their training data, generate repetitive text, and favor common grammatical patterns and vocabulary. A possible cause is the decoding strategy: the most common strategies either consider only the most probable tokens, which reduces output diversity, or increase the likelihood of unlikely tokens, compromising output accuracy and correctness.

Show full abstract

In this paper, we propose DiffSampling, a new decoding method that leverages a mathematical analysis of the token probability distribution to ensure the generation of contextually appropriate text. In particular, the difference between consecutive, sorted probabilities can be used to truncate incorrect tokens. In addition, we also propose two variations of the proposed method that aim to correct the subtle inconsistencies of common sampling strategies. Experiments involving four different text-generation tasks demonstrate that our approach consistently performs at least on par with the existing methods it builds upon in terms of quality, despite sampling from a larger set of tokens.

View on arXivView PDF

Code Implementations(1)

MIT

Official repo for the paper "DiffSampling: Enhancing Diversity and Accuracy in Neural Text Generation"

00Jupyter Notebook, PythonDec 15, 202511 months agoMIT

Similar Papers

Cite this paper

@article{franceschelli2025diffsampling,
  title  = {DiffSampling: Enhancing Diversity and Accuracy in Neural Text Generation},
  author = {Giorgio Franceschelli and Mirco Musolesi},
  year   = {2025},
  eprint = {2502.14037},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.14037v5}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.14037.svg)](https://codeofpaper.com/paper/2502.14037)

Discussion