{
  "id": "repetition-penalty",
  "code": "PTL-0258",
  "term": "Repetition Penalty",
  "aliases": [
    "penalized sampling",
    "repetition_penalty"
  ],
  "category": "foundations",
  "definition": "A repetition penalty is a decoding setting that lowers the probability of tokens that have already appeared in the generated text, to discourage a language model from repeating itself.",
  "description": "Keskar et al. introduced \"penalized sampling\" with the CTRL model in 2019, dividing the scores of previously generated tokens by a factor θ before sampling, where θ of 1 means no penalty. They found greedy decoding with θ of about 1.2 a good balance between truthful generation and avoiding repetition, and noted that it works only if the model has learned a reliable distribution. Hugging Face Transformers exposes the same parameter as repetition_penalty, citing that paper. Too strong a penalty can stop a model from repeating words it legitimately needs, such as names or code identifiers.",
  "example": null,
  "broader": [],
  "narrower": [],
  "related": [
    "text-degeneration",
    "temperature",
    "greedy-decoding",
    "top-p-sampling",
    "log-probabilities"
  ],
  "introduced": 2019,
  "added": "2026-11-27",
  "sources": [
    {
      "title": "CTRL: A Conditional Transformer Language Model for Controllable Generation",
      "authors": "Keskar et al.",
      "year": 2019,
      "url": "https://arxiv.org/abs/1909.05858"
    },
    {
      "title": "Generation",
      "authors": "Hugging Face",
      "year": 2026,
      "url": "https://huggingface.co/docs/transformers/main_classes/text_generation"
    }
  ],
  "url": "https://protologue.com/t/repetition-penalty/",
  "citation": "Protologue. (2026). Repetition Penalty. In Protologue: A Taxonomy of Prompting and LLM Techniques (v1.9.1, PTL-0258). https://protologue.com/t/repetition-penalty/"
}