Most language models are trained to predict the next token by maximizing likelihood. However, when it comes to generating text, simply picking the most probable word at every step—a strategy known as greedy search—often results in text that is repetitive, generic, and "boring." To create language that feels natural, researchers have moved toward stochastic decoding: introducing controlled randomness into the selection process to mirror the variation found in human speech.
The Failure of Maximization
In theory, the "best" sentence should be the one with the highest cumulative probability. In practice, deterministic methods like greedy search or beam search often lead to linguistic traps. As Thiago Castro Ferreira, Emiel Krahmer, and Sander Wubben point out in Towards more variation in text generation, human language is inherently non-deterministic. We don't always use the most statistically common word; we vary our referential forms (e.g., switching between "John," "he," or "the man") to maintain flow.
When models strictly maximize probability, they tend to default to safe, high-frequency phrases. Nicholas Roberts and Graham Neubig demonstrate in Decoding and Diversity in Machine Translation that this doesn't just make text dull—it amplifies bias. Beam search systematically strips away the diversity of human language, often "overwriting" less common female pronouns with more common male ones to favor the most likely statistical output.
Truncating the Unreliable Tail
The simplest way to add variety is to sample from the model’s predicted probability distribution. However, pure sampling is risky because the "long tail" of the distribution contains thousands of low-probability tokens that are contextually nonsensical.
To solve this, researchers use truncation strategies:
- Top-k Sampling: This restricts the model to sampling only from the $k$ most likely next tokens. Abigail See and Christopher D Manning found that while this prevents nonsensical generation, it requires careful tuning to balance diversity and logical coherence.
- Nucleus (Top-p) Sampling: Introduced by Rowan Zellers, Ari Holtzman, and colleagues in Defending Against Neural Fake News, this method dynamically adjusts the size of the sampling pool. It selects the smallest set of tokens whose cumulative probability exceeds a threshold $p$. This effectively "cuts off" the unreliable tail of the distribution while allowing the pool of candidates to expand or contract based on the model's confidence.
Why Randomness Feels Human
The intuition behind why stochastic sampling works better than maximization lies in the "information signal" of language. Human writing isn't a flat line of high-probability words; it involves a rhythmic distribution of "surprisal."
Zuhao Yang, Yang Xu, and their team developed a framework called FACE (Fourier Analysis of Cross-Entropy) to treat this surprisal as a digital signal. They discovered that the rhythmic authenticity of text depends heavily on the decoding algorithm. Stochastic sampling produces information signals that closely resemble human patterns, whereas deterministic search creates signals that feel "artificial" to both statistical tests and human readers.
The Diversity-Coherence Trade-off
While sampling increases variety, it introduces a trade-off: as you increase the "randomness" (often controlled by a temperature parameter), the risk of hallucinations and logical errors rises.
To mitigate this, some researchers use a sample-and-rank strategy. Daniel Adiwardana, Quoc V Le, and the team behind Google’s Meena chatbot found that generating multiple independent candidates via sampling and then selecting the one with the highest log-probability allows for a balance between the creative spark of randomness and the grounding of likelihood.
Ultimately, the shift from "finding the best sequence" to "sampling from a human-like distribution" has been fundamental in moving AI from rigid, template-like narration—such as the time-series descriptions studied by Mandar Sharma and Naren Ramakrishnan in TCube—toward the fluid, engaging prose expected of modern Large Language Models.