WorksComputer Science
When Do Repetition Loops Lock? Truncation Sampling, Bounded Penalties, and a Blind Spot in DRY
Abstract
Language models sometimes repeat verbatim until the generation limit. We study the exit rather than the entrance: given that a span has already been repeated times, when is escape still possible? Along the loop the context is deterministic, so loop survival under any sampler can be computed exactly from one forward pass. Pure sampling leaves a positive escape probability at every step; top- with threshold locks a position exactly when the continuation probability reaches . A bounded penalty can leave a position locked; a penalty that outgrows the model's preference for the loop over unseen tokens guarantees escape under top-. The same analysis predicts a blind spot in the widely deployed DRY sampler: its sequence breakers cap the penalty at for loops whose longest breaker-free run has tokens. On eleven open models, 66% of locked units with stay locked under DRY and 1% with . In free generation with llama.cpp, all 109 loops that survive DRY have . We propose DRY-C, which adds a term that grows exponentially with the number of verbatim recurrences, up to its look-back window. With it, none of 720 structured-output generations looped to the length limit, and task completion stayed close to DRY's.
Introduction
Open-weight models can repeat a line until the token budget is exhausted, including inside reasoning, JSON and tool calls. The phenomenon is old [14], and its onset has been studied from several angles: the self-reinforcing rise of repetition probability (Xu et al., 2022), properties of the transition matrix [7], training data [20], and, most recently, learning errors in reasoning models [30].
This paper asks the complementary question. Suppose a loop has started. Why can the model not get out, and which decoding-time interventions can in principle get it out?
Our starting observation is that, conditioned on staying in a loop, the context is a deterministic sequence. Every sampler, including history-dependent penalties, therefore assigns a deterministic probability to “continue the loop” at each step, and the probability that a loop survives more repetitions is a product of such numbers (Proposition 1). Teacher forcing supplies the logits without sampling loop trajectories.
Truncation can remove the exit. Under pure sampling every step has a positive escape probability. Under top- with the usual threshold , a position is locked (the loop token is the only candidate) exactly when its raw probability satisfies (Theorem 1). Measured reinforcement curves cross this threshold within a few repetitions. In our finite-horizon tests, 80%–100% of sampled units are locked through the last ten repetitions under top- 0.9, compared with none under pure sampling; the units include corpus sentences and hand-written structured spans.
Penalty growth determines the available guarantee. For an additive logit penalty on the loop token, locking persists whenever (Theorem 2). A bounded penalty only raises the threshold at which locking sets in. Escape is guaranteed under top- once the penalty outgrows , where is the raw mass of tokens not yet in the context and therefore unpenalized (Corollary 2). A full-context frequency penalty grows fast enough as long as stays bounded below; presence penalties and windowed frequency penalties come with no such guarantee.
DRY has a blind spot, and it can be closed. DRY [35, 37] penalizes a token exponentially in the length of the verbatim match it would extend, and is widely used in local inference. To protect formatting, matches may not cross sequence breakers (newline, colon, quote, asterisk). We show that for a loop whose longest breaker-free run has tokens, the penalty on the loop token is at most (Proposition 4): on such loops DRY is a bounded penalty. The prediction is borne out in a dose–response experiment, in the unmodified llama.cpp sampler, and in free generation, where every one of the 109 loops that appear with DRY enabled has . We then add a count term that penalizes how many times the same continuation has already occurred, prove that the resulting sampler, DRY-C, penalizes every loop exponentially, breakers or not, up to its look-back window (Proposition 5), and show that it eliminates run-to-the-limit loops in two model families.
This matters most for structured output: under default settings our prose prompts loop in 0%–7% of generations and structured prompts in 16%–21%, and breakers are densest there.
Related Work
Why loops start. Holtzman et al. [14] documented degenerate repetition under likelihood-maximizing decoding and introduced nucleus sampling. Fu et al. [7] analyzed repetition through a Markov model of the transition matrix. Xu et al. (2022) measured a self-reinforcement effect: the probability of repeating a sentence rises with the number of previous repetitions; our reinforcement curves extend this measurement to current instruction-tuned and reasoning models and to 200 repetitions. Li et al. [20] traced repetition to training data, Yao et al. (2025) and Mahaut and Franzon [22] to internal features and mechanisms. Pipis et al. [30] explain why reasoning models enter loops through learning errors and study the role of temperature, keeping each model’s default truncation and explicitly setting penalties aside. Lee et al. [19] separate loop entry from loop persistence in pruned models, relate persistence to the escape mass that the sampling set leaves to alternatives, and address both with fine-tuning objectives. We take the loop as given, work at decoding time, and characterize when that escape mass is exactly zero; these views are complementary.
Truncation samplers. Top- ([14]), min- ([26]), typical sampling ([23]), and related truncation rules ([12, 6, 1]) are motivated by the unreliability of the distribution’s tail. We point out a side effect: truncation turns a near-certain continuation into a certain one.
Repetition penalties. The multiplicative penalty of Keskar et al. [15], presence and frequency penalties, training-time remedies ([38] (Xu et al. 2022)), contrastive search ([33]), and penalty decoding with a forgetting window ((Zhu et al., 2023)) all discourage reuse of tokens; hard -gram blocking ([29, 16]) forbids it outright. Ginart et al. [10] derive a penalty from LZ77 code lengths. Wang et al. [34] compare remedies in a production setting. Grammar-constrained decoding ([39, 4]) guarantees well-formed structured output but does not stop a valid record from being repeated. DRY (Weidmann, [35]}) acts on repeated continuations rather than repeated tokens; Weidmann et al. [37] evaluate it at scale, report roughly halved loop rates, and show that removing sequence breakers damages formatting while lowering their loop metric slightly further, treating breakers as a structure-preserving benefit. We characterize the cap, the loops it can leave locked, and a count-based modification that retains breakers. Further decoding and monitoring approaches are discussed in Appendix E.
Setup
Let be the vocabulary. Fix a prefix and a loop unit . In state , with and , the context is the prefix, followed by complete copies of , followed by ; the model is about to produce the -th token of copy . Write for the model’s next-token distribution in this state, and
for the raw probability of continuing the loop and of the strongest rival. We drop subscripts when no confusion arises.
A sampler maps the history, meaning the tokens so far together with the model’s logits at every step (which the tokens determine), to a distribution over the next token, possibly using internal randomness independent of the history. Along the loop the history is determined by , so the probability that emits is a deterministic number ; this includes samplers with internal state such as Mirostat. Let be the probability of completing one more copy. State is locked if ; repetition is locked if . Starting with copies in context, let be the number of further complete copies produced before the first deviation.
Proposition 1 (Survival). For any sampler, and .
The proof is the chain rule (Appendix § 10). Its practical content is that loop survival under any sampler is computable exactly from the logits along the repetition path. We distinguish three notions: a position is not locked (); there is no permanent lock (no beyond which every repetition is locked); and the loop ends almost surely ().
Truncation Can Lock Loop Positions
Proposition 2 (Pure sampling). If only rescales temperature, no state is locked. Moreover if and only if , and if for all then .
Truncation changes the picture qualitatively. We use the standard definitions. Top- with threshold keeps token iff the total probability of tokens strictly more probable than is below . Min- with ratio keeps iff . Greedy decoding keeps the most probable token. We assume no exact ties among the largest probabilities, which holds almost surely for real-valued logits; implementations break ties by token order.
Theorem 1 (Lock criteria). For top- let ; for min- let . State is locked (a) under top- iff ; (b) under min- iff ; (c) under greedy decoding iff . If the condition holds at every position for all , then .
Whether a position locks can therefore be read off the reinforcement curve . Top- applied before top- (the default order in llama.cpp) renormalizes over the retained tokens: the state is then locked iff is retained among the top tokens and , where is their total raw probability. For a retained loop token, this renormalization can only make locking easier.
Temperature and sampler order. Temperature maps to . Its effect depends on where it sits in the chain.
Proposition 3 (Temperature). (A) If truncation precedes temperature (the default order in llama.cpp), the criteria of Theorem 1 are unchanged. (B) If temperature precedes truncation (the default in transformers) and , then for top-
and for min-, for every , the state is locked iff .
With and in order (B), the sufficient threshold drops from to : lowering the temperature does not merely sharpen the distribution, it lowers the bar for becoming trapped. The case is treated in Appendix § 10.
Penalties: Bounded versus Growing
An additive penalty subtracts from the logit of before truncation, where may depend on the history. Let and let be the raw probability mass of tokens absent from the context; we assume this untouched set is nonempty, so .
Theorem 2 (Penalized continuation). Assume , so the loop token has appeared in the context, and . After the penalty, the loop token has probability
with
Hence, with top- after the penalty,
With min- after the penalty, the state is locked iff
Corollary 1 (Bounded penalties). With top- () after the penalty, if for all states, then every state with is locked, where is the logistic function.
A bounded penalty thus moves the threshold from to ; for and this is 0.961, 0.985, 0.9945. It cannot remove locking from a model whose reinforcement curve saturates above that level.
Corollary 2 (Growing penalties). With top-p () after the penalty, if at some position , then and the loop ends almost surely. This holds in particular if and .
Table 1 classifies common penalties. Two entries deserve comment. First, the look-back window decides the class: over the full context the frequency penalty grows linearly with , but restricted to the last tokens (64 by default in llama.cpp) a token appears at most times; once the window lies entirely within the looping region, the sharper bound is , where is its count per unit. Every deployed penalty has such a window and is thus strictly bounded; what matters is whether the cap exceeds the lock margin for the loop lengths that occur. The frequency cap grows linearly in (with and a 20-nat margin it covers units of a single token for and of about 100 tokens for ); the DRY-C cap grows exponentially (§ 6). For a linear penalty and a finite supremum of the margin, Theorem 2 gives an explicit unlock time under top-p: no state is locked beyond . Second, the multiplicative penalty divides positive logits and multiplies negative ones, so its strength depends on where the model places the zero of its logits, a quantity with no meaning for the distribution; Hollows [13] measure this effect and its damage to structured output.
| Penalty | on loop token | Class |
| Presence | bounded | |
| Frequency , full context | linear | |
| Frequency , window | bounded | |
| Multiplicative | ‡ | bounded† |
| DRY, no breaker in unit | exponential | |
| DRY, breaker-free run | bounded | |
| DRY-C | exponential |
Table 1. Penalties along a loop. Exponential rows assume ; finite windows cap their growth. : loop-token logit. ‡For ; for it is . The DRY lower bound needs ; the DRY-C lower bound needs . †Bounded when is; multiplicative penalties depend on the logit origin.
DRY and Its Sequence Breakers
The penalty cap
We state DRY as implemented in llama.cpp (Gerganov and contributors, [9]). Parameters are a multiplier , a base , and an allowed length (defaults 0.8, 1.75, 2). Let be the set of breaker tokens, those whose text contains a newline, colon, quotation mark, or asterisk (with these default single-character breakers every breaker occurrence is a single token; we do not consider user-defined multi-token breakers). For context , choose a look-back window and put ( if ). Let be the trailing non-breaker length and the common-suffix length of and . The windowed match length is
with an empty maximum equal to zero, and
Breakers enter twice: they truncate the match, and breaker tokens themselves are never penalized.
For a unit containing at least one breaker token, arrange on a circle and let be the largest number of consecutive non-breaker tokens.
Proposition 4 (Penalty cap). For every state with ,
and the bound is attained for , , and .
Proof sketch. If the penalty is zero. Otherwise the trailing non-breaker tokens together with form consecutive non-breaker tokens on the circle, so and .
Corollary 3 (Blind spot). With top-p after DRY, every state of such a loop with is locked.
With default parameters, for , so locking under top-p 0.9 requires log-odds of 3.0, 3.6, 4.7, 6.5, 9.7, 15.3. Measured log-odds after many repetitions lie between about 6 and 20 (§ 7.2). The theory therefore predicts a transition between and : loops with short breaker-free runs—JSON records, key–value lines, quoted dialogue, short lines—remain locked under DRY. Without breakers and with unlimited look-back, the match length is at least ; a finite window eventually caps this growth.
DRY-C: a count term
Match length is capped by breakers, but a loop has a second signature that breakers do not affect: the same continuation recurs many times. Let (minimum length), (allowed recurrences) and . Let . Define
that is, how many earlier positions in the window are preceded by the same tokens as the current one, verbatim and ignoring breakers, and are followed by ( here). The count term is
it applies to breaker tokens as well, and the total penalty is . We call the combined sampler DRY-C.
Proposition 5 (Growth along every loop). For any unit , write . In every state with ,
With an unlimited window () the bound grows without limit in .
Proof sketch. The same position in each of the earlier copies is followed by ; for the -th most recent one, at least preceding tokens agree with the current suffix. Those with whose matching span lies in the window are counted.
Corollary 4. Let DRY-C be followed by top-, write , and assume ; put . With an unlimited window, no state is locked for . With a window of tokens the same holds whenever .
The unlock time is logarithmic in , compared with linear for the frequency penalty. With , and our parameters, the window condition holds for loop units of up to 814 tokens; our detector looks for periods of up to 400. The count term has a cost. A format skeleton that repeats, such as the same JSON keys line after line, can build up matching tokens and trigger it when nothing is looping; Appendix § 14 measures how often this happens and what it does to requested copying. We use , , and unless stated otherwise.
Experiments
Setup
Models. Eleven instruction-tuned models from 1.5B to 9B parameters: Qwen2.5 1.5B and 7B (Qwen Team, 2024); Qwen3 1.7B, 4B and 8B [32]; Llama 3.2 3B and 3.1 8B (Llama Team, 2024); Gemma 2 2B and 9B (Gemma Team, 2024); Phi-4-mini [25]; and the DeepSeek-R1 distillation of Qwen 7B [2].
Teacher-forced measurement. We sample 150 English sentences from the WikiText-103 test set [24] and 150 Chinese sentences from Chinese Wikipedia, stratified by length, and add 22 hand-written units (dialogue lines, list items, code). Each unit is repeated up to 200 times after the beginning-of-sequence token, in an inline variant (joined by a space) and a line variant (terminated by a newline), keeping units whose tokenization is stable under repetition. One forward pass with key–value caching yields , , and at every position; softmax is evaluated in 64-bit precision. Given the logits, the continuation probability under any sampler configuration is computed exactly, with penalties applied before truncation as in llama.cpp. Our DRY computation follows the definition of § 6 and was validated position by position against the llama.cpp sampler Appendix § 12.
Free generation. We run llama.cpp with its own samplers on GGUF quantizations of Qwen3-4B, Llama-3.1-8B and Qwen3.6-35B-A3B. Prompt set 1 has 20 prompts (reasoning, enumeration and eight structured-output tasks); prompt set 2 has 24 structured-output prompts (JSON, tables, YAML, CSV, logs, lists, dialogue) and 12 prose-writing prompts. “Default” denotes the sampler recommended by each model’s developers (Qwen: , top- 0.95, top- 20; Llama: , top- 0.9), with at most 3000 new tokens. A generation contains a loop if some span of at least 4 tokens occurs at least 5 times consecutively, covering at least 60 tokens. Details are in Appendix § 13.
Reinforcement curves
In Figure 1(a) the log-odds (median over positions, then over sentences) climb steeply over the first few repetitions. The log-odds keep rising, roughly as a saturating power law, to between 6 (Llama-3.2-3B) and 20 (Gemma-2-9B) after 200 repetitions; the copying behind this rise is usually attributed to induction heads ([27]). Every curve sits above the top- thresholds from the first repetition onward for the median token; locking requires this at every position, which happens after 5–40 repetitions for half of the sentences (Figure 1(b)). Onset is not monotone: several models dip around the tenth repetition.

Figure 1. (a) Log-odds after repetitions: median over positions within each inline corpus sentence, then median over sentences. Dotted lines mark the lock thresholds of top- 0.9 and 0.95. (b) Fraction of sentences in which every position satisfies at repetition .
Verification of the criteria. On four models (Qwen2.5-1.5B and 7B, Qwen3-4B, Llama-3.2-3B; about 160,000 positions each) the criteria of Theorem 1 agree with the exactly computed lock status at every position for top- 0.9 and 0.95 and min- 0.1 and 0.05. The sufficient and necessary conditions of Proposition 3(B) and Theorem 2 have zero violations; the sufficient conditions cover over 99% of locked positions, and the necessary condition with is tight (Appendix § 11). A Monte Carlo check with the transformers sampler reproduces the survival formula (0.789 ± 0.013 sampled against 0.786 computed).
Which settings lock
Table 2 reports which units stay locked through the last ten measured repetitions. Pure sampling locks nothing. Top- 0.9 locks 80%–100% of units through that interval. Among penalties, the split predicted by Section 5 is visible in every row: presence 1.0 (74%–100%) and windowed frequency 0.5 (56%–99%) leave most units locked; the mild multiplicative penalty leaves between 47% and 99%, a spread that reflects its dependence on the logit origin; a strong one removes most locks (0%–35% remain); and the full-context frequency penalty leaves none locked through the final ten repetitions. Under the full-context frequency penalty locks still form transiently, as late as repetition 86 (Qwen3-8B), before the linear term overtakes them. Figure 5 in Appendix § 13 puts the penalty classes side by side against the measured lock margin.
| Model | Truncation only: pure | Truncation only: top- 0.9 | Truncation only: min- 0.1 | Truncation only: +top- | top- 0.9 + bounded penalty: pres. | top- 0.9 + bounded penalty: freq 0.5 | top- 0.9 + bounded penalty: rep 1.1 | top- 0.9 + bounded penalty: rep 1.3 | top- 0.9 + other penalties: freq. 0.1 | top- 0.9 + other penalties: DRY | top- 0.9 + other penalties: DRY-C |
| Qwen2.5-1.5B | 0 | 1.00 | 1.00 | 1.00 | 1.00 | .96 | .80 | 0 | 0 | .02 | 0 |
| Qwen2.5-7B | 0 | .99 | .99 | .99 | .98 | .95 | .83 | 0 | 0 | .02 | 0 |
| Qwen3-1.7B | 0 | .99 | .99 | .99 | .99 | .99 | .98 | .21 | 0 | .02 | 0 |
| Qwen3-4B | 0 | 1.00 | 1.00 | 1.00 | .99 | .99 | .98 | .01 | 0 | .02 | 0 |
| Qwen3-8B | 0 | .99 | .99 | 1.00 | .99 | .99 | .99 | .35 | 0 | .02 | 0 |
| R1-Distill-7B | 0 | .88 | .91 | .95 | .79 | .70 | .50 | 0 | 0 | .01 | 0 |
| Llama-3.2-3B | 0 | .95 | .97 | 1.00 | .77 | .56 | .47 | 0 | 0 | .01 | 0 |
| Llama-3.1-8B | 0 | 1.00 | 1.00 | 1.00 | 1.00 | .90 | .89 | 0 | 0 | .01 | 0 |
| Gemma-2-2B | 0 | .80 | .85 | .87 | .74 | .69 | .59 | .01 | 0 | .01 | 0 |
| Gemma-2-9B | 0 | .91 | .92 | .92 | .91 | .90 | .88 | .20 | 0 | .02 | 0 |
| Phi-4-mini | 0 | .99 | .99 | 1.00 | .95 | .95 | .53 | 0 | 0 | 0 | 0 |
Table 2. Fraction of units locked through the last ten measured repetitions (150 sampled units: corpus and handwritten spans). Top-, DRY and DRY-C come from a second run in which DRY and DRY-C use a 4,096-token look-back (Appendix § 14); the other columns come from the first run. Subscript 64: penalty window. Temperature precedes top- in the column. Phi-4 is limited to 4,000 tokens throughout.

Figure 5. Penalty trajectories (analytic, unit length 24, unlimited look-back for growing curves; “count term” is the DRY-C count component) against the lock margin of Qwen3-4B (band: weakest to typical token of the median sentence). A penalty that stays below the band cannot unlock.
The DRY blind spot
Dose–response. To vary the breaker-free run length while holding content fixed, we take the first 24 tokens of 40 sentences per model and insert a colon (a breaker) after every tokens, for nominal ; as a control we insert a semicolon (not a breaker). Retokenization can change the actual gap; Appendix § 14 reports both groupings.
Figure 2 shows a sharp transition. Pooled over models, DRY leaves 400/400 units locked at , 404/409 at , 393/419 at , 276/416 (66%) at , and 5/422 (1%) at , and none beyond. With semicolons, none of the 2,919 units locked under top- alone remain locked under DRY (the control selects its locked units separately, hence the different denominator). The models that unlock earliest at are the two Llama models, whose reinforcement curves are the lowest in Figure 1, in line with Corollary 3, whose sufficient condition never predicts a lock that does not occur. Among the corpus units of Table 2, the 23 that stay locked under DRY all have , and DRY-C leaves none; Appendix § 14 also reports transient locks and finite-horizon survival.

Figure 2. Fraction of units that remain locked under DRY + top- 0.9, among units locked under top- alone. Thin lines: individual models; thick line: pooled over eleven models. Top axis: evaluated at the nominal gap; actual-gap regrouping is in Appendix § 14.
The real sampler. We queried the unmodified llama.cpp server for the post-sampling probability of the loop token along the repetition path of 12 units. For six ordinary sentences, top- locks between repetitions 5 and 15 and DRY removes every lock. Six breaker-dense units (short lines, a key–value line, a JSON object, quoted code) lock under DRY at exactly the repetition at which they lock without it.
Free generation. Figure 3 pools the loops found in four free-generation runs (Qwen3-4B on both prompt sets, Qwen3.6-35B, Llama-3.1-8B; 1,780 generations per setting in total). With the default sampler there are 233 loops, of which 110 have and 123 have or no breaker. With DRY added there are 109 loops, and all 109 have . DRY thus removes the loops outside the predicted blind spot, while the number inside it is unchanged (110 versus 109). Within the blind spot the distribution shifts: at , where the cap is close to typical log-odds, loops drop from 10 to 1, whereas loops with rise from 70 to 83: generations that DRY steers away from a long-run loop can fall into a shorter-run one. The pattern holds in each run separately (Appendix § 13) and the surviving loops are spread over many prompts. Loops are concentrated in structured output: with the default sampler, 20.8% (Qwen3-4B) and 16.1% (Llama-3.1-8B) of structured generations on prompt set 2 contain a loop, against 0% and 7.2% for prose; the prose loops of Llama all have or no breaker, and DRY removes all of them.

Figure 3. Loops found in free generation (four runs pooled), by the longest breaker-free run of the loop unit. The dotted line separates from .
Closing the blind spot
We implemented the count term as a patch to the llama.cpp DRY sampler, disabled by default; with it disabled, outputs are identical to the unpatched build.
Teacher-forced. With DRY-C () no unit stays locked: not in the dose–response experiment at any on any model, not among the corpus units (Table 2), and not among the six breaker-dense units in the real sampler.
Free generation. Figure 4 shows the effect on structured prompts. On Qwen3-4B, loops that run to the length limit fall from 59 (default) and 30 (DRY) to 0; on Llama-3.1-8B from 52 and 32 to 0. Loops still appear in 8 and 6 generations but end after a median of 6 and 5 repetitions, in line with the logarithmic unlock time of Corollary 4. The share of generated tokens that lie inside loops drops from 12.2% to 6.7% to 0.1% on Qwen3-4B and from 15.0% to 9.4% to 0.1% on Llama-3.1-8B.

Figure 4. Structured-output prompts (360 generations per bar). Light: a loop appears; dark: the loop continues to the length limit. Numbers are counts.
Side effects. DRY-C lowers item duplication (Table 3). Mean coverage moves a little either way, from 40.5% to 38.2% on Qwen and from 71.5% to 73.1% on Llama. Pure sampling leaves Llama a single loop in 360 generations but lowers the share of generations reaching 90% of the requested items to 23.1%. Appendix § 14 compares further baselines. Two results stand out: dropping DRY’s breakers also removes loops but roughly halves JSON validity, and a light repetition penalty (1.05) combines well with DRY-C, raising coverage to 46.8% and JSON validity to 51.1% on Qwen with no loop reaching the limit.
| Sampler | Ans. | ≥90% | Cov. | Dup. | JSON | |
| Qwen3-4B | default | 62.2 | 15.0 | 34.0 | 28.1 | 26.7 |
| + DRY | 68.3 | 20.0 | 40.5 | 18.5 | 31.1 | |
| + DRY-C | 65.6 | 20.3 | 38.2 | 15.0 | 31.1 | |
| pure | 69.2 | 21.4 | 40.1 | 18.5 | 24.4 | |
| Llama 3.1-8B | default | 100 | 52.8 | 66.1 | 23.0 | 13.3 |
| + DRY | 100 | 58.9 | 71.5 | 12.9 | 26.7 | |
| + DRY-C | 100 | 61.7 | 73.1 | 8.7 | 22.2 | |
| pure | 100 | 23.1 | 46.7 | 8.9 | 8.9 |
Table 3. Task completion on structured prompts (%, 360 generations per row). Ans.: an answer is produced within the limit (for Qwen3-4B, the reasoning block ends); ≥90%: at least 90% of the requested number of distinct items; Cov.: mean fraction of requested items produced; Dup.: duplicated items among those produced; JSON: outputs that parse, on the three JSON prompts (45 generations per cell).
Requested repetition. When the user asks for verbatim repetition, DRY and DRY-C both get in
the way: exact completion falls from above 90% to about 10% (Table 7). A stricter test shows that the count term costs extra on blocks of short repeated lines; raising to 6 recovers most of it on those blocks (Appendix § 14).
| Model | Sampler | sent. | para. | chorus | templ. | all |
| Llama-3.1-8B | default | 100 | 100 | 70 | 100 | 95 |
| + DRY | 22 | 0 | 0 | 8 | 10 | |
| + DRY-C | 22 | 0 | 0 | 8 | 10 | |
| + DRY-C, | 23 | 0 | 0 | 7 | 10 | |
| Qwen3-4B | default | 100 | 100 | 80 | 82 | 91 |
| + DRY | 0 | 0 | 75 | 0 | 12 | |
| + DRY-C | 0 | 0 | 75 | 0 | 12 | |
| + DRY-C, | 1 | 0 | 75 | 0 | 13 |
Table 7. Tasks that request verbatim repetition: generations (%) containing the required number of exact copies.
Discussion and Conclusion
Locked versus long. Pure sampling never locks a position, yet Qwen3-4B produces loops reaching the generation limit. Positive escape probabilities can be too small to end a loop within a finite budget (Proposition 2); conversely, a trajectory may deviate before a later lock forms.
Conclusion. Whether a loop still has an exit depends on how strongly the model prefers to continue it and on what the sampler does with that preference. Truncation can remove the exit outright; a bounded penalty only raises the bar, while a penalty that keeps growing reopens it. DRY’s breakers make it a bounded penalty on exactly the loops that matter most for structured output, and a count term lifts that cap without giving up the breakers.
Limitations
Our analysis covers verbatim loops only. Near-loops, in which a counter increments or wording drifts, fall outside the model; DRY-C turns a few verbatim loops into such near-repeats (Appendix § 14). We explain persistence, not onset: all results are conditional on a loop having begun. The reinforcement curve is treated as an empirical input; we fit but do not derive its shape. Proposition 1 applies to any sampler whose state is determined by the generated prefix (as with Mirostat), but we derive lock criteria only for top-, min- and greedy decoding, not for Mirostat or XTC; for with temperature before top- our sufficient condition is loose. Every deployed penalty, DRY-C included, has a finite look-back window and is therefore bounded; with and our parameters, the sufficient window condition holds for units of up to 814 tokens. The count parameters were chosen from format considerations; we test several alternatives, but do not optimize them. Side effects are measured by coarse task-completion and copying tests on two models, without human evaluation. DRY-C inherits from DRY a strong penalty on verbatim copying: when the user explicitly requests repetition, both samplers reduce exact completion from above 90% to about 10%. Beyond that, DRY-C by construction penalizes the -th verbatim recurrence of any span longer than , including legitimately repeated blocks of short lines that DRY’s breakers would protect. Teacher-forced experiments use eleven models up to 9B parameters; free-generation experiments use quantized weights, three models, and a 3000-token limit, and loop counts from the 35B model are small. Loop detection uses a fixed criterion (five consecutive repetitions covering at least 60 tokens); other thresholds change the counts but not the pattern (Appendix § 13).
Use of AI Assistance
An AI assistant (Claude, Anthropic) was used extensively in this work: in deriving and checking the proofs, writing the measurement and analysis code, running the experiments, and drafting the text. The authors reviewed the derivations, results and text, and take full responsibility for the content.
Proofs
Proof of Proposition 1. The event says that the next tokens equal the tokens of the loop. Write its probability by the chain rule in generation order. Each factor is conditioned on no deviation so far, in which case the context is exactly some state and the factor is . Grouping the factors of each copy gives for . The events decrease to , and continuity of probability gives the second formula.
Lemma 1. Let . Then iff .
Proof. For , ; for , (compare derivatives). If then for and , so the tail product is positive, and the first factors are positive. If then .
Proof of Proposition 2. A temperature-scaled softmax of finite logits gives every token a probability strictly between 0 and 1, so . The second claim is Proposition 1 with Lemma 1 applied to . For the third, and .
Proof of Theorem 1. A state is locked iff the retained set is .
(a) Suppose . Any other token has , so the mass strictly above is at least and is dropped; nothing lies strictly above , so is kept. Conversely suppose . If is not a most probable token, a most probable token is kept. If is the most probable token, let be most probable among the rest; the mass strictly above is at most (if several tokens tie with the mass strictly above them is still only ), so is kept.
(b) If is not the most probable token, the most probable token is kept and . Otherwise all other tokens are dropped iff .
(c) By definition. The last sentence of the theorem follows from Proposition 1.
Lemma 2. Let . If then . If then .
Proof. The case is trivial; otherwise normalize by and put . For , ; for , ; summing gives the bounds around . The remaining bound for is trivial and for is Jensen’s inequality for the concave map .
Proof of Proposition 3. (A) The retained set is determined by the raw distribution; temperature only reweights tokens inside it, and a singleton has probability 1 regardless.
(B) Let . After temperature the loop token has probability . By Lemma 2, , so
By Theorem 1(a) the state is locked iff . The left side is at least iff \logit(q)\ge\tau\logit(\pi); if the state is locked the right side is at least , i.e. . For min-, temperature preserves the order of tokens and raises probability ratios to the power , so by Theorem 1(b) the state is locked iff .
For and top-, the second part of Lemma 2 with gives in the same way
The sufficient condition is loose because it allows the remaining mass to be spread uniformly over the vocabulary.
Proof of Theorem 2. The penalized distribution is proportional to , which gives the formula for . Since , the sum in the denominator is at most ; keeping only unseen tokens, which have , it is at least . As is decreasing this gives the two-sided bound. The lower bound has log-odds and the upper bound has log-odds ; Theorem 1(a) applied to gives the two implications. The min- statement is Theorem 1(b) for the penalized distribution; note that the strongest rival may change after the penalty. □
Proof of Corollary 1. iff , which implies . □
Proof of Corollary 2. By the upper bound of Theorem 2, . The set retained by top- has mass at least , so after renormalization (or 0 if the loop token is dropped). Hence and by Proposition 1. If and , then . □
Proof of Proposition 4. If the penalty is zero by definition. Let . Since , the context ends with at least one complete copy of , which contains a breaker; the trailing non-breaker tokens therefore lie in the loop and form a contiguous arc of the circle. The token extends this arc, giving consecutive non-breaker tokens, so . Thus . If the penalty is zero; otherwise it is at most because . For attainment, let be the last token of a longest breaker-free arc, so that . For the position satisfies and is preceded by at least one full copy that agrees with the current suffix, so ; if , it also lies in the window with , so . □
Proof of Corollary 3. Proposition 4 bounds the penalty on the loop token by . DRY may also penalize other candidates, but the sufficient condition of Theorem 2 holds for arbitrary , so Corollary 1 applies. □
Proof of Proposition 5. Let be the last position of the context, so that is to be generated next. For put , the same position copies earlier; then . From the start of the loop up to there are loop tokens, and by periodicity they agree with the equally long suffix ending at , so . Therefore is counted whenever , i.e. for , provided its matching span of tokens lies within the last tokens, i.e. , i.e. . Hence , and the bound follows because . □
of tokens lies within the last tokens, i.e. , i.e. . Hence , and the bound follows because . □
Proof of Corollary 4. By the necessary condition of Theorem 2, a locked state has d(u_l) \le\ln(q/r^\circ)-\logit(\pi) \le\Delta. Let and suppose . Then , so Proposition 5 gives , and the state is not locked. If , then holds exactly when . □
Verification Details
Lock criteria. For Qwen2.5-1.5B, Qwen2.5-7B, Qwen3-4B and Llama-3.2-3B we compared, at every position of every unit, the lock status computed exactly from the full distribution with the status predicted from and alone. For top- and min- the two agree at all positions (about 160,000 per model). The smallest escape probability observed under pure sampling ranges from to across models and is always positive; the per-repetition escape probability settles between and .
Temperature. For before top- 0.9, the sufficient and necessary conditions of Proposition 3(B) have no violations, and the sufficient condition covers 99.6%–99.9% of locked positions. Lock onset moves from repetitions 10–13 to 4–6.
Penalties. For presence penalties 1 and 2 and full-context frequency penalties 0.1 and 0.5, the sufficient condition of Theorem 2 has no violations and covers 99.2%–100% of locked positions. The necessary condition with the measured has no violations, and the smallest slack among locked positions is 0.00; replacing by produces tens to thousands of violations, so the distinction matters.
Simulation versus the llama.cpp Sampler
The teacher-forced DRY results rely on our implementation of the definition in § 6. We compared it with llama.cpp (commit 03aa006) on 12 units and 40 repetitions (about 5,000 positions), using the server’s post-sampling probabilities with DRY followed by top- 0.9. Lock status differs at 15 positions and the largest probability difference is 0.24. The same comparison for top- alone, which involves no DRY computation, differs at 20 positions with a largest difference of 0.22; the residual is therefore due to numerical differences between the half-precision GGUF and the single-precision weights, at positions near the truncation threshold. The comparison is sensitive to the specification: a variant that omits the exemption of breaker tokens differs at 152 positions, with differences up to 1.0. The count term was validated in the same way against the patched sampler (13 and 10 differing positions for and 3). With the patch disabled, the patched and unpatched builds return identical probabilities at all 5,072 positions for top- and at all positions where both return a value for DRY.
Experimental Details
Teacher-forced runs. In the window reruns, Qwen2.5-1.5B uses float32, both Gemma models use bfloat16, and the other models use float16. Softmax and sampler calculations use float64. Contexts are limited to 12,288 tokens, and to 4,000 tokens for Phi-4-mini, whose outputs degrade abruptly beyond 4,096 tokens under chunked evaluation. Reinforcement curves use the inline variants of the corpus sentences whose tokenization is stable under repetition (277–300 per model); lock fractions and the DRY comparison use an evenly spaced subset of 150 units; the dose–response experiment uses 40 base sentences per model that contain no breaker characters or semicolons. A unit is counted as finally locked if its last ten measured repetitions are entirely locked (Table 2 and the 60-repetition dose experiment). Ever-locked means at least one measured repetition is entirely locked.
Free generation. Quantizations: Q8_0 for Qwen3-4B and Llama-3.1-8B, Q4_K_M for Qwen3.6-35B-A3B. Prompt set 1: 25 samples per prompt and setting for Qwen3-4B, 10 for the 35B model. Prompt set 2: 15 samples per prompt and setting. DRY uses , , , the default breakers, and a range of 4,096 tokens. Table 5 lists loop counts per run, and Table 4 gives every sampler setting run on prompt set 1. The windowed multiplicative penalty (rep. 1.1) yields fewer loops there than DRY, which we attribute to its also penalizing breaker tokens; in teacher forcing it leaves most units locked (Table 2).
| default | + DRY | + pres. 1 | + rep. 1.1 | pure | |
| Qwen3-4B | 78 | 28 | 44 | 24 | 37 |
| of which | 30 | 28 | 29 | 19 | 26 |
| Qwen3.6-35B | 9 | 4 | 1 | 0 | 1 |
| of which | 3 | 4 | 0 | 0 | 0 |
Table 4. Loops on prompt set 1 under every sampler setting (500 generations per cell for Qwen3-4B, 200 for the 35B model).
| Run | Sampler | loops | ||
| Qwen3-4B, set 1 | default | 78 | 30 | 48 |
| + DRY | 28 | 28 | 0 | |
| Qwen3-4B, set 2 | default | 75 | 45 | 30 |
| + DRY | 44 | 44 | 0 | |
| Qwen3.6-35B, set 1 | default | 9 | 3 | 6 |
| + DRY | 4 | 4 | 0 | |
| Llama-3.1-8B, set 2 | default | 71 | 32 | 39 |
| + DRY | 33 | 33 | 0 |
Table 5. Loops per free-generation run. The last column includes units without any breaker. Prompt set 2 includes both structured and prose prompts; on Llama, 58 of the 71 default loops and all 33 DRY loops occur on the structured subset used in Table 8.
DRY-C uses , , ; with on Qwen3-4B (prompt set 2), 25 structured generations contain a loop instead of 8, and again none runs to the length limit.
Sensitivity to the loop criterion. Table 6 repeats the count of Figure 3 under looser and stricter loop criteria. The number of loops changes, but under every criterion no loop that appears with DRY enabled has .
| Criterion | default all | default | default | default + DRY all | default + DRY | default + DRY |
| 3 reps., 30 tok. | 309 | 124 | 185 | 129 | 129 | 0 |
| 4 reps., 40 tok. | 262 | 120 | 142 | 116 | 116 | 0 |
| 5 reps., 60 tok. | 233 | 110 | 123 | 109 | 109 | 0 |
| 8 reps., 100 tok. | 184 | 95 | 89 | 99 | 99 | 0 |
| 10 reps., 150 tok. | 169 | 91 | 78 | 90 | 90 | 0 |
Table 6. Loops in the four pooled free-generation runs under different detection criteria (minimum consecutive repetitions and minimum total length). The third row is the criterion used in the paper.
Requested repetition. Twelve prompts ask for verbatim repetition of a text given in the prompt: four ask for a sentence to be copied 5 or 8 times, two for a paragraph to be copied 3 times, two for a four-line chorus after each of 4 verses, and four for a fixed line in each of 5–8 items (notes, functions, SQL statements); half are in English and half in Chinese. A generation succeeds if the given text occurs the required number of times in the answer, ignoring differences in whitespace. Table 7 reports this 12-task experiment, with 10 generations per task for default and DRY (120 per row) and three batches of 10 per task for each DRY-C setting (360 per row). A stricter 16-task version is reported in Appendix § 14. The chorus tasks, whose lines are short and newline-terminated, are the only ones on which Qwen3-4B still succeeds under DRY, as expected from § 6.
Larger models. The 35B model loops far less than the 4B model under the same sampler and prompts (4.5% of generations against 15.6%), in agreement with Pipis et al. [30]; the four loops that survive DRY all have .
Penalty trajectories. Figure 5 shows each penalty on the loop token as a function of , contrasting fixed caps with linear and exponential lower-bound trajectories. The curve labeled “count term” shows the count component alone, not the maximum of the DRY and count penalties.
Task completion. For each structured prompt we extract items from the answer (for reasoning models, the text after the reasoning block) with a prompt-specific pattern, and compare the number of distinct items with the number requested. Generations that reach the length limit before producing an answer count as zero items.
Additional Baselines and Robustness
Additional interventions. Antislop suppresses unwanted strings by backtracking (Paech et al. [28]); Local Temperature Beam Search uses deterministic calibration (Lee et al. [18]); Variance-
Calibrated Modulation adjusts decoding to address concentration in the distribution head (Ding et al. [3]); XTC excludes top choices (Weidmann et al. [36]). e-CUSUM studies reasoning monitors (Ettifouri et al. [5]), “One Neuron” explores internal-component edits (Lazaridis et al. [17]), “Feedback That Backfires” examines repeated failed actions after feedback (Gumaan [11]), and “Word Salad Chopper” detects unproductive reasoning from hidden states (Xie et al. [40]). None of them asks our question: whether the sampler still leaves any probability for leaving a given loop.
Additional baselines. Table 8 uses the same 24 structured prompts, 15 samples per prompt and setting, and 3,000-token generation limit as Table 3. The two token penalties with look back 4,096 tokens, which covers the whole generation, so the frequency penalty grows throughout. The bounded alternatives (rep. 1.1, DRY + rep. 1.05, newline-only breakers) still produce loops that run to the generation limit. Frequency 0.1 nearly removes such loops, but on Llama lowers mean item coverage from 66.1% (default) to 43.3%, with only 7.8% of generations reaching 90% of the requested distinct items. Removing every breaker eliminates detected loops in both models while reducing JSON validity relative to DRY (31.1% to 17.8% for Qwen; 26.7% to 11.1% for Llama). DRY-C again has no loop reaching the limit. On completion it neither beats nor trails DRY consistently: mean coverage is 38.2% against 40.5% on Qwen and 73.1% against 71.5% on Llama. Adding rep. 1.05 to DRY-C on Qwen yields 3 loops, none to the limit, 46.8% coverage and 51.1% JSON validity; the corresponding DRY + rep. 1.05 baseline has 11 run-to-limit loops and 47.4% coverage. The two combine well: the light penalty helps completion, and the count term removes the locks.
| Model | Sampler | Loops | To limit | Loop tokens (%) | Coverage (%) | JSON (%) |
| Qwen3-4B | default | 75 | 59 | 12.2 | 34.0 | 26.7 |
| DRY | 44 | 30 | 6.7 | 40.5 | 31.1 | |
| DRY-C | 8 | 0 | 0.1 | 38.2 | 31.1 | |
| frequency 0.1, | 19 | 4 | 0.7 | 39.6 | 15.6 | |
| rep. 1.1, | 31 | 22 | 4.1 | 52.9 | 51.1 | |
| DRY + rep. 1.05 | 20 | 11 | 2.7 | 47.4 | 42.2 | |
| DRY, newline breakers only | 31 | 28 | 4.9 | 43.3 | 15.6 | |
| DRY, no breakers | 0 | 0 | 0.0 | 42.7 | 17.8 | |
| DRY-C + rep. 1.05 | 3 | 0 | 0.3 | 46.8 | 51.1 | |
| Llama-3.1-8B | default | 58 | 52 | 15.0 | 66.1 | 13.3 |
| DRY | 33 | 32 | 9.4 | 71.5 | 26.7 | |
| DRY-C | 6 | 0 | 0.1 | 73.1 | 22.2 | |
| frequency 0.1, | 85 | 1 | 4.0 | 43.3 | 4.4 | |
| rep. 1.1, | 7 | 4 | 1.6 | 63.3 | 35.6 | |
| DRY + rep. 1.05 | 6 | 5 | 1.8 | 67.0 | 33.3 | |
| DRY, newline breakers only | 14 | 14 | 4.9 | 70.1 | 33.3 | |
| DRY, no breakers | 0 | 0 | 0.0 | 60.7 | 11.1 |
Table 8. Additional baselines, 360 structured generations per row. Loop tokens: fraction of all generated tokens covered by the detected loop; coverage and JSON use the definitions of Table 3 (45 JSON generations per row). All penalty variants are added to the model’s default sampler.
Count-parameter sensitivity. On Qwen, changing from (24, 2) to (12, 2), (48, 2) or (24, 4) yields respectively 4, 33 and 39 detected loops in 360 generations per setting, all ending before the generation limit. The loop-token shares are 0.04%, 0.41% and 1.31%; the baseline (24, 2) has 8 loops and a 0.1% share. With , more loops persist long enough to meet the detector criterion before ending, consistent with the later activation in Proposition 5. Coverage/JSON are 39.1%/28.9% for and 38.1%/37.8% for . For they are 37.8%/28.9%.
Windowed lock status and finite survival. The second run, with a 4,096-token look-back for DRY and DRY-C, covers all eleven models with 150 units each (Phi-4 again capped at 4,000 tokens). Top- is ever locked on 1,632/1,650 units and locked through the last ten repetitions on 1,577/1,650. DRY has 28 ever-locked and 23 finally locked units, all final locks with ; DRY-C () has 3 ever-locked units and no final locks. In Table 9, is the probability, starting with three copies in context, of following the loop to that unit’s measured endpoint, averaged over units.
| Model | top- ever/final | top- mean | DRY ever/final | DRY mean | DRY-C ever/final | DRY-C mean | |
| Gemma-2-2B | 150 | 144/120 | 0.0221 | 3/2 | 3.23e-10 | 0/0 | 0 |
| Gemma-2-9B | 150 | 150/137 | 0.0696 | 3/3 | 0.000738 | 0/0 | 0 |
| Llama-3.1-8B | 150 | 150/150 | 0.113 | 1/1 | 9.57e-06 | 0/0 | 0 |
| Llama-3.2-3B | 150 | 143/142 | 0.147 | 1/1 | 1.38e-06 | 0/0 | 0 |
| Phi-4-mini | 150 | 150/149 | 0.472 | 0/0 | 6.83e-35 | 0/0 | 0 |
| Qwen2.5-1.5B | 150 | 150/150 | 0.130 | 3/3 | 0.000435 | 0/0 | 0 |
| Qwen2.5-7B | 150 | 150/149 | 0.346 | 3/3 | 0.00173 | 0/0 | 0 |
| Qwen3-1.7B | 150 | 150/149 | 0.272 | 4/3 | 0.0061 | 0/0 | 0 |
| Qwen3-4B | 150 | 150/150 | 0.373 | 4/3 | 0.00839 | 1/0 | 0 |
| Qwen3-8B | 150 | 150/149 | 0.700 | 4/3 | 0.0146 | 2/0 | 0 |
| R1-Distill-7B | 150 | 145/132 | 0.000902 | 2/1 | 2.99e-08 | 0/0 | 0 |
Table 9. Window : ever-locked/finally-locked counts and mean finite-horizon . Final: last ten repetitions all locked. DRY-C uses .
Actual breaker gaps. Of 3,080 colon units, 2,914 satisfy the top- last-ten lock criterion. Retokenization changes the actual gap on 51 units overall, including 48 of these 2,914. Table 10 contrasts grouping by the intended insertion interval with grouping by the recorded actual token gap. The transition persists: at actual , 277/417 remain locked under DRY; at , 5/418 do. The semicolon control has 0/2,919 remaining locks; its denominator counts the control units (out of 3,080) that lock under top- alone.
| Nominal interval | Actual gap | |
| 2 | 400/400 | 392/392 |
| 3 | 404/409 | 410/415 |
| 4 | 393/419 | 393/418 |
| 5 | – | 1/2 |
| 6 | 276/416 | 277/417 |
| 8 | 5/422 | 5/418 |
| 9 | – | 0/3 |
| 10 | – | 0/1 |
| 11 | – | 0/2 |
| 12 | 0/423 | 0/421 |
| 23 | – | 0/30 |
| 24 | 0/425 | 0/395 |
Table 10. DRY-locked / top--locked colon units, pooled over eleven models, under nominal and actual gap grouping.
Stricter requested-copying evaluation. This experiment adds four tasks that repeat blocks of short lines to the twelve tasks of Appendix § 13. Each setting has 16 tasks with 10 samples each (160 generations per model and setting). We report both whitespace-normalized substring counts and strict counts that normalize only spaces/tabs immediately before a newline, preserving internal spaces and line structure (Table 11). Trailing whitespace is normalized because default outputs also use trailing double spaces as Markdown line breaks. The strict metric shows additional copying loss from DRY-C: overall success falls from DRY’s 10.6% to 6.3% on Llama and from 18.1% to 11.2% on Qwen at . On the four block tasks (40 generations), strict success is 42.5% to 25.0% on Llama and 30.0% to 10.0% on Qwen. Raising to 6 brings these to 40.0% and 27.5%, respectively. The count term therefore costs extra on legitimately repeated blocks, a cost the twelve-task test does not reveal.
| Sampler | Llama norm. | Llama strict | Qwen norm. | Qwen strict |
| default | 127 | 120 | 127 | 126 |
| DRY | 27 | 17 | 31 | 29 |
| DRY + rep. 1.05 | 28 | 12 | 35 | 31 |
| DRY, newline only | 32 | 18 | 26 | 24 |
| DRY-C, | 26 | 10 | 18 | 18 |
| DRY-C, | 30 | 16 | 28 | 22 |
Table 11. Requested repetition, 16-task experiment: successful generations out of 160 in every cell. Norm.: whitespace-normalized; strict: only trailing line whitespace normalized.
Count activation outside detected loops. Table 12 counts teacher-forced activations on default-sampler generations with no loop under our detector, using exact -token tuples and a 4,096-token window (all sequences are at most 3,000 tokens). At , at least one continuation would be penalized in 108/285 (37.9%) Qwen structured outputs and 57/302 (18.9%) Llama structured outputs; affected-position shares are 3.0% and 5.7%. For prose the corresponding generation shares are 9/180 (5.0%) and 50/167 (29.9%). Raising either threshold reduces them.
| Structured Qwen | Structured Llama | Prose Qwen / Llama | ||
| 12 | 2 | 68.1 | 53.0 | 14.4 / 49.7 |
| 12 | 4 | 42.8 | 42.7 | 2.8 / 19.8 |
| 24 | 2 | 37.9 | 18.9 | 5.0 / 29.9 |
| 24 | 4 | 14.4 | 13.2 | 0.0 / 15.0 |
| 48 | 2 | 27.0 | 10.3 | 1.7 / 18.0 |
| 48 | 4 | 6.7 | 6.0 | 0.0 / 9.0 |
Table 12. Potential count activations in generations without detected loops (% with at least one activation). Structured = 285/302, prose = 180/167 for Qwen/Llama; denominators are fixed across the grid.
Near-loops. Does DRY-C just push verbatim loops into approximate ones that our detector misses? We decoded all 8,280 structured generations and computed two text-level measures: the zlib compression ratio (lower means more repetitive) and the share of lines that are at least 90% similar (difflib) to an earlier line, ignoring lines under five characters. Going from DRY to DRY-C, the share of generations with no verbatim loop but more than half of their lines near-duplicated rises a little, from 8.9% to 12.2% on Qwen and from 17.8% to 19.7% on Llama. Overall repetition does not rise: the median compression ratio goes up (0.339 to 0.347 on Qwen, 0.323 to 0.347 on Llama), and the median near-duplicate line share is essentially unchanged (0.083 to 0.081; 0.050 to 0.054). So a few verbatim loops turn into drifting near-repeats, but the repetition is not simply moved out of sight.
References
- [1]Sourya Basu, Govardana Sachitanandam Ramachandran, Nitish Shirish Keskar, and Lav R. Varshney. 2021. Mirostat: A neural text decoding algorithm that directly controls perplexity. In International Conference on Learning Representations.
- [2]DeepSeek-AI. 2025. DeepSeek-R1: Incentivizing reasoning capability in LLMs via reinforcement learning. arXiv preprint arXiv:2501.12948.DOI
- [3]Yuanhao Ding, Meimingwei Li, Esteban Garces Arias, Matthias Aßenmacher, Christian Heumann, and Chongsheng Zhang. 2026. Breaking the likelihood trap: Variance-calibrated modulation for large language model decoding. arXiv preprint arXiv:2606.22511.arxiv.org/abs/2606.22511
- [4]Yixin Dong, Charlie F. Ruan, Yaxing Cai, Ruihang Lai, Ziyi Xu, Yilong Zhao, and Tianqi Chen. 2024. XGrammer: Flexible and efficient structured generation engine for large language models. arXiv preprint arXiv:2411.15100.arxiv.org/abs/2411.15100
- [5]El Hassane Ettifouri, Ayoub Belfatmi, Mahaman Sanoussi Yahaya Alassan, and Walid Dahbane. 2026. Calibrated e-CUSUM decoding for quantized reasoning models: Why token log-probability is the wrong observable for decoding monitors. arXiv preprint arXiv:2607.11317.arxiv.org/abs/2607.11317
- [6]Matthew Finlayson, John Hewitt, Alexander Koller, Swabha Swayamdipta, and Ashish Sabharwal. 2024. Closing the curious case of neural text degeneration. In International Conference on Learning Representations.arxiv.org/abs/2310.01693
- [7]Zihao Fu, Wai Lam, Anthony Man-Cho So, and Bei Shi. 2021. A theoretical analysis of the repetition problem in text generation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 12848–12856.arxiv.org/abs/2012.14660
- [9]Georgi Gerganov and contributors. 2023. llama.cpp: LLM inference in C/C++.
- [10]Antonio A. Ginart, Naveen Kodali, Jason Lee, Caiming Xiong, Silvio Savarese, and John R. Emmons. 2025. LZ penalty: An information-theoretic repetition penalty for autoregressive language models. arXiv preprint arXiv:2504.2031.arxiv.org/abs/2504.20131
- [11]Esmail Gumaan. 2026. Feedback that backfires: Why small language model agents repeat the call they just watched fail. arXiv preprint arXiv:2608.23651.arxiv.org/abs/2608.23651
- [12]John Hewitt, Christopher D. Manning, and Percy Liang. 2022. Truncation sampling as language model desmoothing. In Findings of the Association for Computational Linguistics: EMNLP 2022.arxiv.org/abs/2210.15191
- [13]Peter Hollows. 2026. Gauge dependence and structured-output corruption in sign-branched repetition penalties: Measurements across models, inference stacks, and alternative repetition controls. arXiv preprint arXiv:2607.09791.arxiv.org/abs/2607.09791
- [14]Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. 2020. The curious case of neural text degeneration. In International Conference on Learning Representations.
- [15]Nitish Shirish Keskar, Bryan McCann, Lav R. Varshney, Caiming Xiong, and Richard Socher. 2019. CTRL: A conditional transformer language model for controllable generation. arXiv preprint arXiv:1909.05858.arxiv.org/abs/1909.05858
- [16]Guillaume Klein, Yoon Kim, Yuntian Deng, Jean Senel-lart, and Aleksander Rush. 2017. OpenNMT: Open-source toolkit for neural machine translation. In Proceedings of ACL 2017, System Demonstrations.arxiv.org/abs/1701.02810
- [17]Aristotelis Lazaridis, Aman Sharma, Dylan Bates, Brian King, Vincent Lu, and Jack FitzGerald. 2026. When can one neuron fix repetition loops in LLMs? arXiv preprint arXiv:2606.13705.arxiv.org/abs/2606.13705
- [18]Dongkyu Lee, Gyeonghun Kim, Janghoon Han, Tae-suk Hong, Yi-Reun Kim, Stanley Jungkyu Choi, and Nevin L. Zhang. 2023. Local temperature beam search: Avoid neural text DeGeneration via enhanced calibration. In Findings of the Association for Computational Linguistics: ACL 2023, pages 9903–9915.DOI
- [19]Junyoung Lee, Sehyeon Park, Shinhyoung Jang, Seonha Ryu, Hojeong Kim, Hyunsei Lee, Il Hong Suh, and Yeseong Kim. 2026. FOCUS & RePAIR: Mitigating text degeneration via token-level guidance for pruned large language models. arXiv preprint arXiv:2608.26676.arxiv.org/abs/2608.26676
- [20]Huayang Li, Tian Lan, Zihao Fu, Deng Cai, Lemao Liu, Nigel Collier, Taro Watanabe, and Yixuan Su. 2023. Repetition in repetition out: Towards understanding neural text degeneration from the data perspective. In Advances in Neural Information Processing Systems, volume 36.arxiv.org/abs/2310.10226
- [22]Matéo Mahaut and Francesca Franzon. 2025. Repetitions are not all alike: Distinct mechanisms sustain repetition in language models. arXiv preprint arXiv:2504.01100.arxiv.org/abs/2504.01100
- [23]Clara Meister, Tiago Pimentel, Gian Wıher, and Ryan Cotterell. 2023. Locally typical sampling. Transactions of the Association for Computational Linguistics, 11:102–121.
- [24]Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. 2017. Pointer sentinel mixture models. In International Conference on Learning Representations.arxiv.org/abs/1609.07843
- [25]Microsoft. 2025. Phi-4-mini technical report: Compact yet powerful multimodal language models via mixture-of-LoRAs. arXiv preprint arXiv:2503.01743.
- [26]Minh Nhat Nguyen, Andrew Baker, Clement Neo, Allen Roush, Andreas Kirsch, and Ravid Shwartz-Ziv. 2024. Turning up the heat: Min-p sampling for creative and coherent LLM outputs. arXiv preprint arXiv:2407.01082.arxiv.org/abs/2407.01082
- [27]Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, et al. 2022. In-context learning and induction heads. arXiv preprint arXiv:2209.11895.arxiv.org/abs/2209.11895
- [28]Samuel Paech, Allen Roush, Judah Goldfeder, and Ravid Shwartz-Ziv. 2025. Antislop: A comprehensive framework for identifying and eliminating repetitive patterns in language models. arXiv preprint arXiv:2510.15061.arxiv.org/abs/2510.15061
- [29]Romain Paulus, Caiming Xiong, and Richard Socher. 2018. A deep reinforced model for abstractive summarization. In International Conference on Learning Representations.arxiv.org/abs/1705.04304
- [30]Charilaos Pipis, Shivam Garg, Vasilis Kontonis, Vaishnavi Shrivastava, Akshay Krishnamurthy, and Dimitris Papailiopoulos. 2025. Wait, wait, wait... why do reasoning models loop? arXiv preprint arXiv:2512.12895.arxiv.org/abs/2512.12895
- [32]Qwen Team. 2025. Qwen3 technical report. arXiv preprint arXiv:2505.09388.
- [33]Yixuan Su, Tian Lan, Yan Wang, Dani Yogatama, Lingpeng Kong, and Nigel Collier. 2022. A contrastive framework for neural text generation. In Advances in Neural Information Processing Systems, volume 35.arxiv.org/abs/2202.06417
- [34]Weiwei Wang, Weijie Zou, and Jiyong Min. 2025. Solving LLM repetition problem in production: A comprehensive study of multiple solutions. arXiv preprint arXiv:2512.04419.arxiv.org/abs/2512.04419
- [35]Philipp Emanuel Weidmann. 2024. DRY: A modern repetition penalty that reliably prevents looping. Pull request #5677, oobabooga/text-generation-webui.
- [36]Philipp Emanuel Weidmann, Allen Roush, Judah Goldfeder, Sanjay Basu, and Ravid Shwartz-Ziv. 2026a. XTC: Head-aware sampling by excluding top choices. arXiv preprint arXiv:2608.22758.arxiv.org/abs/2608.22758
- [37]Philipp Emanuel Weidmann, Allen G. Roush, Judah Goldfeder, Sanjay Basu, and Ravid Shwartz-Ziv. 2026b. Don’t repeat yourself: Stopping verbatim loops at sampling time. arXiv preprint arXiv:2608.22761.arxiv.org/abs/2608.22761
- [38]Sean Welleck, Ilia Kulikov, Stephen Roller, Emily Dinan, Kyunghyun Cho, and Jason Weston. 2020. Neural text generation with unlikelihood training. In International Conference on Learning Representations.
- [39]Brandon T. Willard and Rémi Louf. 2023. Efficient guided generation for large language models. arXiv preprint arXiv:2307.09702.arxiv.org/abs/2307.09702
- [40]Wenya Xie, Shaochen Zhong, Hoang Anh Duy Le, Zhaozhuo Xu, Jianwen Xie, and Zirui Liu. 2025. Word salad chopper: Reasoning models waste a ton of decoding budget on useless repetitions, self-knowingly. arXiv preprint arXiv:2511.00536.arxiv.org/abs/2511.00536