Presence Penalty.
A sampling parameter that reduces the probability of tokens that have already appeared in the text, encouraging models to introduce new topics and vocabulary.
Presence penalty is a sampling parameter used during text generation that systematically reduces the likelihood of selecting tokens that have already appeared anywhere in the generated text. Unlike frequency penalty which considers how often a token has appeared, presence penalty applies a flat reduction to any token that has been used at least once, regardless of frequency. This mechanism encourages language models to explore new vocabulary and introduce fresh topics rather than repeating the same words and concepts.
The parameter works by maintaining a record of all tokens that have appeared in the current generation and applying a consistent penalty value to their logits before sampling. When set to positive values, presence penalty makes previously used tokens less likely to be selected, while negative values would theoretically make them more likely (though this is rarely useful). The penalty is applied uniformly regardless of how many times a token has appeared - a word used once receives the same penalty as one used ten times, distinguishing it from frequency-based penalties.
Presence penalty proves particularly valuable for creative writing, brainstorming, and exploratory content generation where diversity and novelty are desired over consistency. However, it can sometimes lead to awkward phrasing or unnatural language as the model avoids common function words and necessary repetitions. The optimal setting depends on the use case: higher values promote more diverse vocabulary but may sacrifice coherence, while lower values maintain natural language patterns but may result in repetitive content. Most applications benefit from moderate presence penalty values combined with other sampling parameters for balanced output.
Related terms.
- SamplingThe method used to select each next token from a probability distribution during text generation, controlling the randomness and creativity of model outputs.
- Top-KA sampling parameter that restricts token selection to the k most probable next tokens, discarding the long tail of unlikely options.
- Top-PAlso called nucleus sampling — a method that selects from the smallest set of tokens whose combined probability exceeds a threshold p, adapting dynamically to the model's confidence at each step.