Understanding the Repeat Curse in Large Language Models from a Feature Perspective

Junchi Yao, Shu Yang, Jianhua Xu, Lijie Hu, Mengdi Li, Di Wang

Overview

Large Language Models (LLMs) frequently suffer from the "Repeat Curse," a phenomenon where they generate repetitive tokens or paragraphs indefinitely. This research investigates the internal mechanisms driving this behavior using Sparse Autoencoders (SAEs) to identify specific "Repetition Features"—monosemantic units in the model's hidden layers. By surgically deactivating these features, researchers can mitigate repetition without compromising the model's general intelligence.

The Problem: Defining the Repeat Curse

The "Repeat Curse" manifests in two primary forms: token-level repetition and paragraph-level repetition. Traditional solutions, such as repetition penalties during decoding, often act as blunt instruments that can degrade output coherence or punish necessary word usage. This study shifts the focus toward mechanistic interpretability to understand why the model's internal activations trigger these loops in the first place.

Examples of token and paragraph repetition illustrating the "Repeat Curse" in LLM outputs.

Methodology: The "Duplicatus Charm" (DUC) Pipeline

The authors propose the Duplicatus Charm (DUC) pipeline, a structured approach to induce, identify, and silence repetition features within LLMs.

The DUC pipeline: from dataset construction and metric selection to feature identification and steering.

The pipeline consists of four key stages:

  1. Repeat Pattern Construction: Creating datasets designed to trigger repetitive behaviors (e.g., modifying Orca-Chat samples).
  2. Evaluation and Metric Selection: Identifying sensitive indicators of repetition. The study concluded that 1-gram repeat scores and Information Entropy were the most effective metrics.
  3. Repetition Feature Identification: Using SAEs to decompose messy, polysemantic neuron activations into thousands of monosemantic features. Layer localization revealed these features are primarily located in intermediate and final layers.
  4. Feature Steering: Validating features by artificially boosting their activation (to induce the curse) or zeroing them out (to break it).

Key Insights: Repetition as a Feature

A central finding is that repetition is not a random error but is driven by specific directions in the model's activation space. These "repetition features" are often semantically grounded, clustering around categories like Names, Time, or Mathematics. For instance, over-activating a feature associated with "proper names" can cause the model to list names endlessly. Deactivating these features doesn't just stop the looping; it often improves output diversity by allowing the model to move past the repetitive trigger.

Results and Mitigation Performance

The DUC method achieved a 88.9% state-of-the-art probability in reducing repetition across various models. Crucially, this intervention resulted in a zero performance hit to general model intelligence. Unlike traditional penalties, deactivating internal features did not significantly increase perplexity. In some cases, such as with Gemma-2-2B on academic tasks, the model's performance actually improved after the "curse" was lifted.

Limitations and Future Work

While effective, the method currently relies on the availability of high-quality pre-trained SAEs, which are currently most accessible for models under 10B parameters. Additionally, setting the threshold for identifying a "repetition feature" involves some subjectivity. Future work will focus on automatically detecting and neutralizing these features during the training process to prevent the Repeat Curse from developing.

Summary updated

BibTeX
@inproceedings{yao2025understanding,
  author = {Junchi Yao and Shu Yang and Jianhua Xu and Lijie Hu and Mengdi Li and Di Wang},
  title = {{Understanding the Repeat Curse in Large Language Models from a Feature Perspective}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure