repetition penalty
**Repetition penalty** is the **decoding constraint that down-weights tokens already used in recent output to reduce loops and redundant phrasing** - it is a common safeguard against text degeneration.
**What Is Repetition penalty?**
- **Definition**: Token-score adjustment that penalizes previously generated tokens during subsequent steps.
- **Mechanism**: Modifies logits based on token recurrence history before final token selection.
- **Scope Options**: Penalty can apply to full history or a rolling recent-token window.
- **Behavioral Effect**: Discourages repeated words, phrases, and structural loops.
**Why Repetition penalty Matters**
- **Quality Improvement**: Reduces repetitive artifacts that degrade readability.
- **Long-Form Stability**: Helps maintain novelty in extended generations.
- **User Trust**: Less repetition improves perceived intelligence and polish.
- **Operational Robustness**: Prevents worst-case loop failures in interactive systems.
- **Decoding Synergy**: Pairs well with temperature and sampling filters for balanced output.
**How It Is Used in Practice**
- **Penalty Calibration**: Tune magnitude to remove loops without harming essential term reuse.
- **Window Design**: Use recent-window penalties for context-sensitive control.
- **Domain Testing**: Validate on tasks requiring technical terminology repetition to avoid over-penalization.
Repetition penalty is **a key anti-degeneration control in modern decoding stacks** - proper repetition penalties improve readability while preserving semantic accuracy.