A repeated phrase makes a model likelier to repeat it again
The loop shows up under greedy and beam search but not under sampling, and why a trained model favors its own recent words in the first place is still unsettled.
Why this matters
You have probably watched a chatbot lock onto a word or a sentence and say it again and again, filling the screen until it hits a wall. That loop is one of the oldest failures in machine text, and every model you use ships with settings that exist to keep it from surfacing: a top-p value, sometimes a repetition penalty. This lesson starts at the loop on the screen and works down, one part at a time, to the point where the researchers who study it stop agreeing. The loop stops being mysterious once you can name its steps. Chasing the model's likeliest word drives it into a repeat, and a random draw escapes. A phrase that recurs pulls the model back toward itself. And the last question, why a trained model leans on its own recent words at all, still has more than one answer.
- 01
- Two answers to one prompt diverge at a single draw: how a model turns its output into a probability spread and a rule picks one word from it, greedy against sampling, the step this loop starts from.
- 02
- The instant a model writes a token, it becomes fact: why a word, once written, becomes input the model reads back and never revises, which is what lets a loop persist.
A reply that keeps saying the same line
Ask a model to keep writing and sometimes it locks onto a phrase and repeats it, the same words each pass, until something outside the model stops it. Anyone who has used a chatbot has seen a milder version: a sentence that comes back nearly unchanged, or a list that keeps restating its first item.
This is not the model running dry. Holtzman and colleagues showed that the very same trained model, on the very same prompt, will either fall into that loop or read like a person, and the only thing separating the two is the rule that picks each next word from the model's output.1 The loop is one of the most common failures in text generation, and it appears far more under some of those rules than others.2
Chase the likeliest word and the model loops
At each position the model produces a probability for every word in its vocabulary, tens of thousands of them. What differs between one run and another is the rule for collapsing that spread into a single word. The plainest rule takes the highest-probability word every time, called greedy decoding. A more careful version, beam search, keeps a handful of candidate continuations alive at once and extends whichever whole running sequence scores highest. Both are after the same thing, the most likely continuation. The other family treats the probabilities as odds and lets chance draw the next word, so a word the model rates at one in five is picked about that often.
The two families do not behave alike. On GPT-2 Large continuing prompts from web text, Holtzman's team measured how much of each generation was repeated content under each rule. Greedy scored 73.66 on the paper's repetition score and beam search 28.94, while nucleus sampling scored 0.36 and human text scored 0.28.1
| Rule | Repetition score |
|---|---|
| Greedy | 73.66 |
| Beam search (b=16) | 28.94 |
| Top-k sampling (k=640) | 0.28 |
| Nucleus sampling (p=0.95) | 0.36 |
| Pure sampling | 0.22 |
| Human text | 0.28 |
The score is the paper's own, so the rows are meant to be read against each other rather than as a share of anything outside the table, and figures from other papers below sit on other scales. Fan and colleagues, who trained a model to write short stories, found the same pull in beam search on their own task: it tends to produce common phrases and repetitive text.3 So the loop is a property of the rule. Give the same model the same prompt, let a sampler draw instead of taking the top word, and the repetition score falls from 73.66 to under half a point.1 That only pushes the question down a step. Why should always taking the likeliest word loop at all?
The loop feeds itself
The answer is a property of the model's own probabilities. Once a phrase has appeared in the text, the model raises the probability that the same phrase appears again. The second time is likelier than the first, the third likelier than the second. Holtzman's team named this a positive feedback loop and found it held for the vast majority of phrases they tried, whatever the phrase's length and whether it was drawn from human writing or assembled at random.1
The probability of a repeated phrase increases with each repetition, creating a positive feedback loop.1 Holtzman et al., Figure 4
Under greedy decoding this is a trap with no exit. The model takes the top word, that word's reappearance raises its own odds for next time, so it wins again, and the gap widens with every pass until nothing else can catch it. Under sampling the same climb happens, but chance still holds some probability on other words, so a draw can fall outside the phrase and break the loop. That is why the two families came apart on the table above.
The effect is not one paper's anecdote. Xu and colleagues measured it again on modern language models across several corpora and found the probability of repeating a sentence rises almost monotonically with the number of times it has already repeated, climbing toward a ceiling.4 In their measurements a single earlier repetition was enough to raise the next-repeat probability in more than nine cases out of ten, and sentences that started with a higher probability showed the stronger pull.4 Two independent groups, different models, the same shape: that the loop feeds itself is settled.
Why the model favors its own words is unsettled
One step remains. Why does a trained model raise the probability of a word it just produced? Here the settled ground runs out. No one has a single agreed answer, and the two leading ones do not reduce to each other.
Welleck and colleagues put the cause in the training objective. A model is trained to maximize the probability of the human text it is shown, word by word, and Welleck's group argues that this objective itself pushes probability onto sequences with repeats and frequent words, giving the model a bias no decoding rule created.5 Their evidence is that even under sampling, which should dodge the greedy trap, the token-level repeat rate stays above human.5
Fu and colleagues put it somewhere else, in the structure of the language the model learned. In their analysis many different words all predict the same next word with high probability, a pattern they call high inflow, so once generation reaches that word it is easily pulled back to it and circles.6 On their account a simple Markov generator carrying the same transition probabilities would repeat for the same reason, whatever objective had trained it.6
These are different claims about the same effect, and the evidence does not yet decide between them. The measurements from the step above hold either way: the loop is real and it feeds itself. Why the model leans on its own output to begin with is the point below which the accounts diverge and none has closed.
Each fix reaches one step and no further
The remedies sort themselves by which step they touch. The decode-time fixes attack whether the loop is entered. Top-k sampling draws only from the k most likely words and ignores the rest. Fan's story model drew from k of 10.3 Nucleus sampling, or top-p, draws from the smallest set of words whose probabilities add up to p, the rule that scored 0.36 against greedy's 73.66 on the table above.1 A repetition penalty takes a more direct aim: before the model picks, it divides the score of any word already used, so used words are handicapped. Keskar's group, tuning the 1.63-billion-parameter CTRL model, found a divisor near 1.2 kept the output varied without wrecking it.7 A library will also expose a blunt version that simply forbids repeating any run of words the model has already emitted.2
The repetition penalty is the fix a reader is most likely to reach for. It removes the visible loop. It does not touch why the model favored its own words, so it works from outside, shaving scores after the model has computed them. Push the divisor too high and it starts refusing words the sentence actually needs, which is why Keskar reports tuning it to a balance rather than turning it to the maximum.7
The training-time fixes go after the bias itself. Unlikelihood training adds a term that lowers the probability of unwanted continuations, repeated words and sequences, while the model trains, moving its probabilities toward the human distribution.5 It works, and it is plain about its limit. On Wikitext-103 it cut the duplicate four-gram rate from 0.442 under standard training to 0.013, close to human text's 0.006, while the token-level repeat rate fell only from 0.627 to 0.559 and stayed above human's 0.487.5 The loop nearly vanishes; the underlying lean toward repeats narrows but does not close. Xu's DITTO takes a related route, manufacturing repetitive examples and teaching the model to let the repeat probability decay instead of climb.4
Put the two families side by side and the disagreement from the step above turns practical. A decode-time rule decides whether the loop is entered at all; a training method changes how far the model leans toward repeats in the first place. A survey of the field places them exactly this way, as separate attacks on one behavior.8 Neither is a full cure. A decode-time fix can drive the visible repetition below human on the page while the model's token-level bias sits untouched underneath, and the training fix narrows that bias without erasing it.
The takeaway
The loop comes from the rule that picks each word. Take the single likeliest word every time and any phrase that starts to repeat grows likelier to repeat again, so the model tightens into a loop with no way out. Let a sampler draw and chance can still fall outside the phrase and break it. The fixes divide by the step they reach. Top-p, top-k, and a repetition penalty keep the loop from being entered, working from outside the model at the moment each word is picked. Unlikelihood training and DITTO reach further in, pushing the model's own probabilities back toward human writing, and even those narrow the bias without closing it. Below all of it sits the one step still argued over: why a trained model raises the odds on a word it just produced. The measurements above are settled and they agree. The reason underneath them is where an honest account has to say the field holds two answers and has not chosen between them.
- 01
- The Curious Case of Neural Text Degeneration: the paper that named the feedback loop and introduced nucleus sampling, and the source of the decoding comparison here.
- 02
- How to generate text: a hands-on tour of the actual decoding knobs, greedy, beam, top-k, and top-p, with runnable examples.
Sources
- Holtzman, Buys, Du, Forbes & Choi · The Curious Case of Neural Text Degeneration (ICLR 2020)
- Patrick von Platen · How to generate text: decoding methods for language generation with Transformers (Hugging Face)
- Fan, Lewis & Dauphin · Hierarchical Neural Story Generation (ACL 2018)
- Xu, Liu, Yan, Cai, Li & Li · Learning to Break the Loop: Analyzing and Mitigating Repetitions for Neural Text Generation (NeurIPS 2022)
- Welleck, Kulikov, Roller, Dinan, Cho & Weston · Neural Text Generation with Unlikelihood Training (ICLR 2020)
- Fu, Lam, So & Shi · A Theoretical Analysis of the Repetition Problem in Text Generation (AAAI 2021)
- Keskar, McCann, Varshney, Xiong & Socher · CTRL: A Conditional Transformer Language Model for Controllable Generation (2019)
- Lilian Weng · Controllable Neural Text Generation (2021)