When Do Repetition Loops Lock? Truncation Sampling, Bounded Penalties, and a Blind Spot in DRY
Organizations: School of Art and Design, Zhejiang Sci-Tech University, Hangzhou, China
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.
Figures & tables
| 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 |
| Truncation only | top- 0.9 + bounded penalty | top- 0.9 + other penalties | |||||||||
| Model | pure | top- | min- | =0.7 | pres. | freq. 64 | rep. 64 | rep. 64 | freq. | DRY | DRY-C |
| 0.9 | 0.1 | +top- | 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 |
| 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 |
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 | 30 | 28 | 29 | 19 | 26 |
| Qwen3.6-35B | 9 | 4 | 1 | 0 | 1 |
| of which | 3 | 4 | 0 | 0 | 0 |
| 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 |
| default | default + DRY | |||||
|---|---|---|---|---|---|---|
| Criterion | all | all | ||||
| 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 |
| 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, =6 | 23 | 0 | 0 | 7 | 10 | |
| Qwen3-4B | default | 100 | 100 | 80 | 82 | 91 |
| + DRY | 0 | 0 | 75 | 0 | 12 |
| 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 |
| top- | DRY | DRY-C | |||||
|---|---|---|---|---|---|---|---|
| Model | ever/final | mean | ever/final | mean | ever/final | 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 |
| 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 |
| 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, | 26 | 10 | 18 | 18 |
| Structured | Prose | |||
|---|---|---|---|---|
| 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 |