Abstract
Large language models (LLMs) have made remarkable progress in various domains, yet they often suffer from repetitive text generation, a phenomenon we refer to as the "Repeat Curse". While previous studies have proposed decoding strategies to mitigate repetition, the underlying mechanism behind this issue remains insufficiently explored. In this work, we investigate the root causes of repetition in LLMs through the lens of mechanistic interpretability. Inspired by recent advances in Sparse Autoencoders (SAEs), which enable monosemantic feature extraction, we propose a novel approach, "Duplicatus Charm", to induce and analyze the Repeat Curse. Our method systematically identifies "Repetition Features"—the key model activations responsible for generating repetitive outputs. First, we locate the layers most involved in repetition through logit analysis. Next, we extract and stimulate relevant features using SAE-based activation manipulation. To validate our approach, we construct a repetition dataset covering token and paragraph level repetitions and introduce an evaluation pipeline to quantify the influence of identified repetition features. Furthermore, by deactivating these features, we have effectively mitigated the Repeat Curse.
1. Introduction
The "Repeat Curse" is a persistent challenge in the deployment of Large Language Models (LLMs). It manifests as the unintended and often infinite repetition of tokens, phrases, or entire paragraphs, significantly undermining the utility of generated text. Historically, this issue has been addressed at the decoding stage using heuristics such as nucleus sampling or repetition penalties. However, these methods are often "blunt instruments" that can suppress necessary repetitions or reduce the overall coherence of the output.
This research shifts the paradigm from output-level mitigation to internal mechanistic understanding. By leveraging Sparse Autoencoders (SAEs), we introduce "Duplicatus Charm" (DUC), a pipeline designed to identify, validate, and deactivate the specific internal features—termed "Repetition Features" (RFs)—that drive this behavior.
2. The Duplicatus Charm (DUC) Framework
The DUC framework consists of four primary stages aimed at providing a surgical "cure" for the Repeat Curse:
- Layer Localization: Using "logit lens" analysis, we identify the specific layers within the transformer architecture that contribute most significantly to the probability of repeating the preceding token. Our findings indicate that these features are predominantly concentrated in the intermediate and final layers of the model.
- Feature Extraction: We employ SAEs to decompose the dense, polysemantic activations of the identified layers into a sparse set of human-interpretable features. This allows us to isolate specific semantic components from the model's internal state.
- Feature Steering: To establish a causal link between a feature and the Repeat Curse, we perform activation steering. By artificially stimulating a candidate feature, we observe whether it induces repetitive behavior in the model's output.
- Mitigation: Once RFs are identified, we deactivate them. Our experiments revealed that setting these activations to a minimal positive value (0.01) is more effective than total zero-ablation, as it preserves the model's functional sanity while successfully breaking the repetition loop.
3. Experimental Setup and Evaluation
To rigorously evaluate the DUC framework, we developed a custom repetition dataset derived from Orca-Chat, comprising 5,500 samples that include both token-level and paragraph-level repetitions.
Performance was measured using:
- 1-Gram Repeat Scores and Information Entropy: These metrics were found to be more sensitive indicators of repetition than traditional metrics like BLEU.
- General Benchmarks: To ensure that deactivating RFs did not impair the model's general intelligence, we tested on Academic ShortQA (AQ) and Natural Questions (NQ).
- Diversity-Challenge Dataset (EQ): A new dataset designed to provoke enumerative repetition, testing the model's robustness in difficult scenarios.
4. Key Results
The DUC method was validated across GPT-2 Small, Gemma-2-2B, and Llama-3.1-8B. Key findings include:
- Causal Induction: Activating identified RFs in GPT-2 Small caused the repetition score to nearly double, rising from 0.37 to 0.72.
- Effective Suppression: Deactivating these features reduced repetition scores significantly (e.g., to 0.19 in specific scenarios) across all tested models.
- Performance Preservation: Crucially, the model's perplexity remained stable. In the case of Gemma-2-2B on the AQ dataset, the model's coherence actually improved (lower perplexity) following the deactivation of repetition features.
- State-of-the-Art Impact: The DUC approach achieved an 88.9% probability of successfully reducing repetition across the diverse range of models and datasets tested.
5. Discussion and Conclusion
Our research demonstrates that repetition in LLMs is often tied to specific, monosemantic features rather than being a generalized architectural failure. We identified that these features are frequently category-specific, such as features dedicated to proper names, mathematical symbols, or temporal references.
While the current implementation of DUC relies on manual thresholding for feature identification and is limited by the availability of high-quality SAEs for larger models, it represents a significant step toward mechanistic control of LLM behavior. Future work will focus on automating feature discovery and scaling these techniques to models with 70B+ parameters. By treating the Repeat Curse at the feature level, we provide a path toward more reliable and diverse AI generation.
Summary updated