TL;DR
Large Language Models (LLMs) frequently fall into infinite loops of repetitive text generation, a flaw known as the "Repeat Curse." This paper uses mechanistic interpretability and Sparse Autoencoders (SAEs) to pinpoint the exact internal "repetition features" driving this behavior. By gently deactivating these specific features, the authors successfully cure the curse without degrading the model's overall intelligence or performance.
What Problem Does This Paper Address?
Despite their impressive capabilities, LLMs often suffer from degeneration loops where they repeat tokens or entire paragraphs over and over (see Figure 1). Traditional fixes rely on decoding-stage patches, such as repetition penalties or nucleus sampling. While these methods can reduce repetition, they act as external band-aids that often compromise text diversity and overall model performance.
The authors address a fundamental gap: we don't actually know why LLMs repeat themselves on a mechanistic level. By shifting the focus from decoding-layer hacks to internal feature representations, this paper aims to find the root cause of the Repeat Curse and fix it from the inside out.
Methods
The authors introduce a novel pipeline called "Duplicatus Charm" (DUC), inspired by Harry Potter, to induce, locate, and deactivate repetition mechanisms. The pipeline consists of four key stages:
- Metric Selection: The authors tested multiple metrics (n-gram, Self-BLEU, and Information Entropy) to see which best identifies repetition. They found that a 1-gram repeat score provided the highest sensitivity.
- Layer Localization: Using a "logit lens" approach, they analyzed the residual streams of models to determine which layers contribute most to predicting a repeated token. The signal was strongest in the intermediate and final layers.
- Feature Localization: To move from coarse layers to precise concepts, they leveraged pre-trained Sparse Autoencoders (SAEs). SAEs disentangle complex, polysemantic neuron activations into clean, human-interpretable "monosemantic" features. By amplifying specific feature activations (by 1.5–2x), they identified the exact "Repetition Features" that triggered looping text.
- Feature Steering: Once identified, the authors mitigated the curse by deactivating these features. Crucially, instead of completely zeroing them out (which can break the model's reasoning), they set them to a minimal positive value (0.01) to suppress the looping behavior while retaining the model's core knowledge.
Datasets
The study utilized several datasets for both pattern construction and model evaluation:
- Custom Repetition Dataset: Because no standard repetition benchmark existed, the authors sampled 1,000 raw QA pairs from Orca-Chat and programmatically modified them to create 5,500 samples split between token-level and paragraph-level repetitions.
- Evaluation Datasets: The mitigation pipeline was tested across three distinct open-source datasets to evaluate performance under different difficulties:
- Diversity-Challenge-Dataset (EQ): Challenging enumeration tasks.
- Academic ShortQA (AQ): Difficult academic questions.
- Natural Questions (NQ): Simple, straightforward questions.
Key Insights and Ideas
- Repetition is Concept-Driven: Repetition features are not random structural glitches; they are highly correlated with specific semantic concepts. Across multiple models, repetition was most frequently triggered by features representing Names, Time, and Mathematics. Names were the most volatile trigger.
- The Difficulty Correlation: The Repeat Curse is highly sensitive to prompt difficulty. More complex questions or tasks requiring enumeration (like the EQ dataset) significantly amplify the activation of repetition features.
- Behavioral Mitigation vs. Unlearning: Total feature ablation (zeroing out) often causes model collapse or unlearning. The authors discovered that maintaining a tiny positive activation (0.01) acts as a behavioral dampener—it stops the loop without destroying the model's underlying knowledge.
Key Results
The authors validated their DUC pipeline across three different model families and scales: GPT2-small, Gemma-2-2B, and Llama-3.1-8B.
- SOTA Repetition Reduction: Deactivating the identified repetition features achieved an 88.9% state-of-the-art (SOTA) probability in reducing repetition across the evaluation datasets, outperforming standard decoding strategies like Beam Search, Top-K, and Top-P.
- Preserved Model Capability: Unlike decoding penalties that harm text quality, the DUC method reduced repetition while keeping Perplexity stable. In fact, for Gemma-2-2B on the academic dataset, perplexity actually improved after mitigation.
Limitations and Future Work
- Subjective Thresholds: Identifying whether a feature is a "repetition feature" relies on a human-defined threshold ($\rho = 0.4$) based on manual evaluation, introducing a minor element of subjectivity.
- SAE Scale Constraints: The experiments were limited by the availability of high-quality, open-source Sparse Autoencoders, restricting the study to models up to 8B parameters. The authors plan to scale this approach to larger models as the SAE community open-sources more models.
Summary updated