# Repetition Penalty

> 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.

- Identifier: PTL-0258
- Category: Foundations
- Canonical URL: https://protologue.com/t/repetition-penalty/
- Also known as: penalized sampling, repetition_penalty
- Introduced: 2019

## 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.

## Related terms

- [Text Degeneration](https://protologue.com/t/text-degeneration/)
- [Temperature](https://protologue.com/t/temperature/)
- [Greedy Decoding](https://protologue.com/t/greedy-decoding/)
- [Top-p Sampling](https://protologue.com/t/top-p-sampling/)
- [Log Probabilities](https://protologue.com/t/log-probabilities/)

## Sources

- Keskar et al. (2019). CTRL: A Conditional Transformer Language Model for Controllable Generation. https://arxiv.org/abs/1909.05858
- Hugging Face (2026). Generation. https://huggingface.co/docs/transformers/main_classes/text_generation

## Cite this entry

Protologue. (2026). Repetition Penalty. In Protologue: A Taxonomy of Prompting and LLM Techniques (v1.9.1, PTL-0258). https://protologue.com/t/repetition-penalty/

License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
