arXiv(opens in a new tab)cs.CLAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.22761

Don't Repeat Yourself: Stopping Verbatim Loops at Sampling Time

Philipp Emanuel Weidmann, Allen Roush, Judah Goldfeder, Sanjay Basu, Ravid Shwartz-Ziv

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Philipp Emanuel Weidmann †^{\dagger}

Independent Researcher

pew@worldwidemann.com

Allen G. Roush ‡^{\ddagger}

Thoughtworks

allen.roush@thoughtworks.com

Judah Goldfeder

Columbia University

jag2396@columbia.edu

Sanjay Basu

Oracle

sanjay.basu@oracle.com

Ravid Shwartz-Ziv

New York University

ravid.shwartz.ziv@nyu.edu

Abstract

Large Language Models (LLMs) generate text by sampling tokens autoregressively, but open-ended generation is prone to verbatim looping, where the model repeats spans already present in its context. Standard defenses, such as repetition, presence, and frequency penalties, and n-gram blocking, act on token recurrence rather than on the sequential structure of a loop, and suppress looping only at strengths that also degrade formatting and 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, with sequence breakers that protect chat templates and formatting tokens. Our experiments across models from 1.5B to 120B parameters, nine prompt families, and a 600-pair human study show that DRY reduces the suffix-extension rate by 47% while improving lexical diversity. An intervention-matched placebo produces no such reduction, identifying suffix-matching as the operative mechanism. On AWQ-quantized 70B and 120B models, DRY reduces the loop rate by roughly half while preserving MT-Bench, MMLU, and GSM8k, where 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 impact on practical text generation.

1 Introduction

Autoregressive language models [Bengio et al., 2003, Brown et al., 2020, Radford et al., 2019, Vaswani et al., 2017] remain susceptible to a well-documented failure mode: verbatim looping, in which the model begins repeating spans that have already appeared in the context [Fu et al., 2021, Holtzman et al., 2019, Welleck et al., 2019, Yao et al., 2025]. This failure is especially visible in long-context chat, small locally deployed models, and quantized inference settings [Dettmers et al., 2022, Frantar et al., 2022, Lin et al., 2024]. Once a loop begins, the model's own output reinforces the repetition, often producing dozens or hundreds of repeated tokens before generation terminates.

The standard inference-time response is a family of token-level repetition controls: multiplicative repetition penalties, additive presence and frequency penalties, and hard no-repeat n-gram blocking [ggml-org, 2024, Hugging Face, 2024a,b, Keskar et al., 2019]. These controls are ubiquitous

∗^{*}Equal contribution.

†^{\dagger}Proposed the DRY (Don’t Repeat Yourself) sampling method and wrote the original reference implementations, which were merged into llama.cpp, text-generation-webui, and other open-source inference engines.

‡^{\ddagger}Designed and ran all experiments, evaluations, and statistical analysis.

Preprint.

and easy to configure. However, they penalize tokens based on prior occurrence rather than on the sequential structure of the failure. A newline token, a speaker label, or a formatting marker may be penalized simply for having appeared before, even when its reuse is part of the intended output structure [See et al., 2019, Wiher et al., 2022]. As a result, practitioners face an uncomfortable tradeoff: increasing penalty strength suppresses loops but also degrades formatting and fluency, while reducing strength preserves fluency but leaves loops uncontrolled.

We present Don’t Repeat Yourself (DRY), a sampling-time logit adjustment that reframes repetition control from token recurrence to suffix continuation. DRY penalizes a candidate token only when generating it would extend the current context suffix into a sequence that has already occurred elsewhere in the context. The penalty grows exponentially with the length of the matching span, and configurable sequence breakers prevent matching across structural boundaries such as newlines and quotation marks [Weidmann, 2024]. This design yields a control that is inactive when there is nothing to suppress and progressively stronger as a verbatim loop develops.

DRY has been adopted across production inference frameworks including text-generation-webui [Weidmann, 2024], llama.cpp [l3utterfly, 2024], and ExLlamaV2 [awtrisk, 2024], with integration requests filed for vLLM [Kwon et al., 2023, Shreyansh1311, 2024]. Despite this ecosystem adoption, no controlled empirical study has evaluated DRY against the repetition controls it is designed to replace. This paper provides that evaluation.

Our contributions are:

• We formalize DRY as a selective sequence-aware logit adjustment and establish its key property: at most decoding steps, for most candidate tokens, DRY leaves the distribution unchanged.

• We evaluate DRY against six baseline methods (including contrastive decoding) and an intervention-matched placebo control across three primary models (1.5B to 7B) with extension to 14B, nine prompt families, three random seeds, and two decoding regimes.

• We show that DRY reduces SER@4 by 47% while simultaneously improving lexical diversity (distinct-4 from 0.958 to 0.975) and achieving the highest macro-average MAUVE relative to a fixed WikiText-103 human reference distribution.

• We extend the evaluation to the frontier scale on AWQ-quantized Llama-3-70B-Instruct and GPT-OSS-120B, where DRY halves the loop rate while tracking the uncontrolled baseline on MT-Bench, MMLU, and GSM8k within run-to-run variance, whereas the repetition penalty and no-repeat n-gram blocking lose measurable ground on the same suites.

• We validate these results through a blind 600-pair MTurk human evaluation and an intervention-matched placebo control that confirms suffix-matching as the operative mechanism.

• We demonstrate that DRY composes safely with standard decoding controls (temperature, nucleus sampling, repetition penalties), improving every stacking configuration it is added to, and that its inference-time overhead remains under 3% out to a 128K context.

References (73)