In February 2019, OpenAI published a short article about a mythical Roman poet, written by its new language model, GPT-2. The prose was lucid, almost unnervingly so. What the announcement did not stress, but the paper that followed did, is that the model only wrote that well when it was prevented from doing what it does naturally. Left to pick the single most likely next word, the same model produced bland, repetitive mush.
That gap between a model that understands language and a model that cannot finish a sentence without looping has a name: neural text degeneration. It was first measured carefully in a 2019 paper by Ari Holtzman and colleagues at the University of Washington and the Allen Institute for Artificial Intelligence, and it explains both why every API has a "temperature" dial and why AI agents still get stuck in loops.
The paradox
Language models are trained to maximize the likelihood of the next token. For years, the obvious way to generate text was to use that same objective at inference: pick the most probable next word, append it, repeat (greedy decoding), or keep the top-scoring candidate sentences (beam search). Both methods made output worse, not better.
Holtzman's team quantified it using GPT-2 Large, a 762-million-parameter model, generating from opening paragraphs of held-out web documents. Human text in the same corpus repeats a previously used word only 0.28 percent of the time. Greedy decoding repeats 73.66 percent of the time. Beam search at width 16 repeats 28.94 percent. The models were not broken. Their perplexity, a measure of how well they predict text, was excellent. The better the model by its training objective, the more confidently it could march into a loop, because the most likely continuation of a repeated phrase is usually more of the same phrase.
There was a second finding that mattered just as much. The opposite extreme, pure random sampling from the model's full vocabulary distribution, does avoid repetition (0.22 percent, below the human rate) but drifts into gibberish. The paper's tables show why: real text follows a Zipf-like distribution in which a small set of candidates holds most of the probability, and the long tail of remaining tokens is where models dump probability mass they cannot confidently place. Unconstrained sampling draws from that unreliable tail and inherits its nonsense.
So the model faced two failure modes. Maximize likelihood, and you get a stuck record. Sample freely, and you get incoherence. Neither is the behavior anyone wants.
The fix the field settled on
The paper's answer was nucleus sampling, also known as top-p sampling. At each step, keep the smallest set of candidate tokens whose combined probability reaches a threshold p (typically 0.9 to 0.95), throw away the rest, and renormalize. The set is dynamic: when the model is confident, the nucleus is tiny and output stays coherent; when the model is genuinely uncertain, the nucleus widens and the text can take a chance. On the same GPT-2 experiments, nucleus sampling at p=0.95 cut repetition to 0.36 percent, close to the human 0.28, while keeping perplexity near the human level. The top-k idea it improved on came from Fan, Lewis and Dauphin's 2018 story generation work, which showed a fixed shortlist of candidates was enough to keep sampling sane; nucleus sampling made the shortlist adapt to context instead of a fixed count.
Subsequent work refined the recipe in two directions. Welleck and colleagues at Facebook AI Research and the University of Washington attacked the problem at training time with unlikelihood training, adding a loss term that directly penalizes the model for repeating n-grams it has already produced, rather than only filtering at inference. On the inference side, a 2024 paper by Nguyen and colleagues introduced min-p sampling, which sets the acceptance threshold as a fraction of the top token's own probability. Its selling point is the mirror image of nucleus sampling's: at high temperatures, where top-p starts producing incoherent or repetitive output, min-p keeps quality and creativity from collapsing at the same time. It has since been adopted by Hugging Face Transformers and vLLM.
Degeneration is now a parameter on every commercial and open-source serving stack. The OpenAI API exposes presence_penalty and frequency_penalty, which subtract probability from tokens that have appeared at all, or in proportion to how often they have appeared (API documentation). vLLM's sampling parameters include repetition_penalty and no_repeat_ngram_size, a hard ban on reusing any n-gram of a given length. A 2024 study by Renze and Guven on sampling temperature and problem solving found output similarity falls sharply as temperature rises past 1.0, which is the dial's other job: pushing the model away from its most-likely, most-repetitive habits.

The loop moved, it did not disappear
If degeneration were only a 2019 curiosity, it would belong in a museum. It belongs in your agent logs instead. The token-level version got patched by truncation and penalties. The structural version, where a model's own output re-enters its context and becomes the evidence for the next step, did not go anywhere. It just moved up a level.
Laban, Hayashi, Zhou and Neville's 2025 study, run on every top open- and closed-weight model the authors tested (from Llama 3.1 8B to Gemini 2.5 Pro) across more than 200,000 simulated conversations, is the clearest measurement. When tasks that models solve at roughly 90 percent accuracy in one shot are instead given in underspecified, multi-turn form, the same models lose an average of 39 percent of their performance. The authors call it getting lost in conversation: the model makes an early assumption, commits to it, and then over-relies on its own previous response instead of recovering. Decomposing the effect, best-case ability drops about 16 percent while run-to-run unreliability more than doubles, up 112 percent. The model has not become dumber; it has become a captive of its own transcript.
That is the same ratchet Holtzman measured, at a different time scale. Greedy decoding repeats because the prior output raises the probability of the same tokens. A multi-turn agent repeats its mistakes because its prior answers occupy the context window and read like facts. The paper also reports that tricks which work at token scale, including simply concatenating the conversation into a single prompt, do not reliably fix the multi-turn failure.

What to take from it
Three practical conclusions follow from seven years of evidence.
First, likelihood is not quality. A model that predicts well does not generate well on autopilot, which is why benchmark perplexity and output quality are different claims. Second, every generation setting you have ever tuned, temperature, top-p, min-p, the penalties, exists because of this failure mode. Setting temperature to 0 means asking a degeneration-era problem the worst available question. Third, and most relevant to anyone shipping agents: the repetition loops you see in agent logs, where a coder retries the same failing patch or a chat assistant re-asks the same clarifying question, are the turn-level cousin of the "and the and the and" loops of 2019. Decoding parameters cannot fix them. What works in the research so far is external structure: fresh context, verifiable checkpoints, judges that are not the same model grading its own transcript. The ratchet is a property of autoregression itself, and it is still running.
Sources
- Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, Yejin Choi. The Curious Case of Neural Text Degeneration. ICLR 2020.
- Angela Fan, Mike Lewis, Yann Dauphin. Hierarchical Neural Story Generation. ICLR 2019.
- Sean Welleck, Ilia Kulikov, Stephen Roller, Emily Dinan, Kyunghyun Cho, Jason Weston. Neural Text Generation with Unlikelihood Training. ICLR 2020.
- Minh Nhat Nguyen, Andrew Baker, Clement Neo, Allen Roush, Andreas Kirsch, Ravid Shwartz-Ziv. Turning Up the Heat: Min-p Sampling for Creative and Coherent LLM Outputs. ICLR 2025 (oral).
- Philippe Laban, Hiroaki Hayashi, Yingbo Zhou, Jennifer Neville. LLMs Get Lost In Multi-Turn Conversation. 2025.
- Matthew Renze, Erhan Guven. The Effect of Sampling Temperature on Problem Solving in Large Language Models. 2024.
- OpenAI. Chat completions API reference: presence_penalty, frequency_penalty.
- vLLM. SamplingParams documentation.
- Hugging Face. How to generate text: using different decoding methods for language generation with Transformers.
