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 n 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-p with threshold π>1/2 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-p. The same analysis predicts a blind spot in the widely deployed DRY sampler: its sequence breakers cap the penalty at λbg−1−a for loops whose longest breaker-free run has g tokens. On eleven open models, 66% of locked units with g=6 stay locked under DRY and 1% with g=8. In free generation with llama.cpp, all 109 loops that survive DRY have g≤7. 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.
Figures & tables
Penalty
d on loop token
Class
Presence βp
βp
bounded
Frequency α , full context
≥αn
linear
Frequency α , window W
≤αW
bounded
Multiplicative ϱ
z(1−ϱ1)‡
bounded †
DRY, no breaker in unit
≥λb(n−1)L−a
exponential
DRY, breaker-free run g
≤λbg−1−a
bounded
Table 1: Penalties along a loop. Exponential rows assume W=∞ ; finite windows cap their growth. z : loop-token logit. ‡ For z>0 ; for z<0 it is ∣z∣(ϱ−1) . The DRY lower bound needs (n−1)L≥a ; the DRY-C lower bound needs n−⌈a′/L⌉≥c0 . † Bounded when z is; multiplicative penalties depend on the logit origin.
Figure 1: (a) Log-odds after n repetitions: median over positions within each inline corpus sentence, then median over sentences. Dotted lines mark the lock thresholds of top- p 0.9 and 0.95. (b) Fraction of sentences in which every position satisfies q≥0.9 at repetition n .
Truncation only
top- p 0.9 + bounded penalty
top- p 0.9 + other penalties
Model
pure
top- p
min- p
τ =0.7
pres.
freq. 64
rep. 64
rep. 64
freq.
DRY
DRY-C
0.9
0.1
+top- p
1.0
0.5
1.1
1.3
0.1
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
Table 2: Fraction of units locked through the last ten measured repetitions (150 sampled units: corpus and hand-written spans). Top- p , DRY and DRY-C come from a second run in which DRY and DRY-C use a 4,096-token look-back (Appendix E ); the other columns come from the first run. Subscript 64: penalty window. Temperature precedes top- p in the τ =0.7 column. Phi-4 is limited to 4,000 tokens throughout.
Figure 2: Fraction of units that remain locked under DRY + top- p 0.9, among units locked under top- p alone. Thin lines: individual models; thick line: pooled over eleven models. Top axis: Dg evaluated at the nominal gap; actual-gap regrouping is in Appendix E .
Figure 3: Loops found in free generation (four runs pooled), by the longest breaker-free run g of the loop unit. The dotted line separates D7=7.5 from D8=13.1 .
Figure 4: Structured-output prompts (360 generations per bar). Light: a loop appears; dark: the loop continues to the length limit. Numbers are counts.
Sampler
Ans.
≥ 90%
Cov.
Dup.
JSON
Qwen3
default
62.2
15.0
34.0
28.1
26.7
4B
+ 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
default
100
52.8
66.1
23.0
13.3
3.1-8B
+ DRY
100
58.9
71.5
12.9
26.7
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).
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
default
+ DRY
+ pres. 1
+ rep. 1.1
pure
Qwen3-4B
78
28
44
24
37
of which g≤7
30
28
29
19
26
Qwen3.6-35B
9
4
1
0
1
of which g≤7
3
4
0
0
0
Appendix
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
g≤7
g≥8
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
Appendix
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 .
default
default + DRY
Criterion
all
g≤7
g≥8
all
g≤7
g≥8
≥ 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
Appendix
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.
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, c0 =6
23
0
0
7
10
Qwen3-4B
default
100
100
80
82
91
+ DRY
0
0
75
0
12
Appendix
Table 7: Tasks that request verbatim repetition: generations (%) containing the required number of exact copies.
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 logit(q)−logit(0.9) of Qwen3-4B (band: weakest to typical token of the median sentence). A penalty that stays below the band cannot unlock.
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, W=4096
19
4
0.7
39.6
15.6
rep. 1.1, W=4096
31
22
4.1
52.9
51.1
DRY + rep. 1.05
20
11
2.7
47.4
42.2
Appendix
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.
top- p
DRY
DRY-C
Model
N
ever/final
mean k3
ever/final
mean k3
ever/final
mean k3
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
Appendix
Table 9: Window W=4096 : ever-locked/finally-locked counts and mean finite-horizon k3 . Final: last ten repetitions all locked. DRY-C uses bc=3 .
g
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
Appendix
Table 10: DRY-locked / top- p -locked colon units, pooled over eleven models, under nominal and actual gap grouping.
Llama
Qwen
Sampler
norm.
strict
norm.
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, c0=2
26
10
18
18
Appendix
Table 11: Requested repetition, 16-task experiment: successful generations out of 160 in every cell. Norm.: whitespace-normalized; strict: only trailing line whitespace normalized.
Structured
Prose
a′
c0
Qwen
Llama
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
Appendix
Table 12: Potential count activations in generations without detected loops (% with at least one activation). Structured N=285/302 , prose N=180/167 for Qwen/Llama; denominators are fixed across the grid.
Large Language Models generate text autoregressively, but open-ended generation is prone to verbatim looping, in which models repeat spans already present in context. Standard defenses such as repetition, presence, and frequency penalties and n-gram blocking act on token recurrence rather than the sequential structure of a loop, and often suppress looping only at strengths that also degrade formatting or fluency. We propose Don't Repeat Yourself (DRY), a sampling-time logit adjustment that penalizes a candidate token only when generating it would extend the current suffix into an exact continuation of a span seen earlier in the context. Sequence breakers protect chat templates and formatting tokens. Across models from 1.5B to 120B parameters, nine prompt families, and a 600-pair human study, DRY reduces suffix-extension rate by 47% while improving lexical diversity. An intervention-matched placebo produces no comparable reduction, identifying suffix matching as the operative mechanism. On AWQ-quantized 70B and 120B models, DRY reduces loop rate by roughly half while preserving MT-Bench, MMLU, and GSM8K performance, whereas standard alternatives lose measurable ground. DRY has been adopted by popular open-source LLM inference frameworks including llama.cpp, ExLlamaV2, and text-generation-webui, highlighting its practical impact on text generation.
Philipp Emanuel Weidmann, Allen Roush, Judah Goldfeder +2
Reasoning models (e.g., DeepSeek-R1) generate long chains of thought to solve harder problems, but they often loop, repeating the same text at low temperatures or with greedy decoding. We study why this happens and what role temperature plays. With open reasoning models, we find that looping is common at low temperature. Larger models tend to loop less, and distilled students loop significantly even when their teachers rarely do. This points to mismatches between the training distribution and the learned model, which we refer to as errors in learning, as a key cause. To understand how such errors cause loops, we introduce a synthetic graph reasoning task and demonstrate two mechanisms. First, risk aversion caused by hardness of learning: when the correct progress-making action is hard to learn but an easy cyclic action is available, the model puts relatively more probability on the cyclic action and gets stuck. Second, even when there is no hardness, Transformers show an inductive bias toward temporally correlated errors, so the same few actions keep being chosen and loops appear. Higher temperature reduces looping by promoting exploration, but it does not fix the errors in learning, so generations remain much longer than necessary at high temperature; in this sense, temperature is a stopgap rather than a holistic solution. We end with a discussion of training-time interventions aimed at directly reducing errors in learning.
Charilaos Pipis, Shivam Garg, Vasilis Kontonis +3
MIT · Microsoft Research · University of Wisconsin–Madison
Looped language models (LMs) reuse one block of layers several times per token generation, promising more latent computation at no additional storage cost. Despite their rising popularity, the analysis of looped LMs is still in its infancy: little is known about whether the iterative transformations actually improve their capabilities, or whether these models remain stable under prompt perturbation. We construct an inspection protocol rooted in Mechanistic Interpretability comprising five diverse lenses. We apply it to examine eight looped LMs from four families. Models differ in many aspects but the key one is whether the prompt is transmitted only within the looped state (carry loops: Ouro, LoopUS) or re-supplied at every iteration (re-read loops: Parcae, and Rec-OLMo & Huginn from the Raven family). The results of our study provide valuable insights concerning safety and efficient use of looped language models.
Pawel Olszowiec, Paulina Tomaszewska, Maciej Żelaszczyk +2
Samsung AI Center, Warsaw, Poland · IFTR, Polish Academy of Sciences, Warsaw, Poland · University of Warsaw, Poland