Language model repetition loops lock under certain sampling settings
When Do Repetition Loops Lock? Truncation Sampling, Bounded Penalties, and a Blind Spot in DRY
Computation and LanguageMachine Learning
Summary
Language models sometimes get stuck repeating the same text over and over until they hit a limit. This paper studies when it is still possible for the model to escape these repetition loops once they have started. The authors analyze how different sampling methods affect whether the model can break out of the loop and identify particular weaknesses in a common sampling method called DRY, which can keep loops stuck. They propose a new version, DRY-C, that reduces repeated loops without harming the quality of the generated text.
What this means in practice
- •For language model engineers: Improve text generation quality by reducing endless repetition loops with a modified sampling method that ensures escape from locked loops.
- •For natural language processing teams: Enhance the robustness of generation in applications producing structured outputs by preventing repeated loops that degrade output quality.
Authors
Yichuan Chen, Xin Wang
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 $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 $λb^{g-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\le 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.