Presence penalty is a decoding parameter for language models that subtracts a fixed amount from the logit of every token that has already appeared in the generated text, regardless of how many times it appeared. In artificial intelligence systems built on large language models, it is one of the main controls for reducing repetition and encouraging the model to introduce new words, entities and topics instead of circling back to the ones it has already used.
The parameter acts only at inference time, during sampling, and does not change the model weights. It is usually exposed in generation APIs next to temperature, top-p sampling and the closely related frequency penalty, and it typically accepts values from -2.0 to 2.0 with a default of 0, which means no effect.
How presence penalty adjusts token scores
Presence penalty works by editing the logits before the softmax turns them into probabilities. At each decoding step, the system checks which tokens already occur in the output so far and subtracts the penalty value once from the raw score of each of them. A token used one time and a token used twenty times receive exactly the same deduction, which is the defining property that separates it from count-based penalties.
A common formulation, used by several commercial APIs, combines both penalties in one expression: the adjusted logit equals the original logit minus count × frequency_penalty minus (count > 0) × presence_penalty. Because logits live on a logarithmic scale, subtracting a value shrinks the token’s odds by a multiplicative factor. The table below shows how strongly typical settings reduce the odds of a repeated token, all else being equal.
| Presence penalty | Odds multiplier for a used token | Practical effect |
|---|---|---|
| 0.0 | 1.0 (unchanged) | No influence on sampling |
| 0.3 | About 0.74 | Subtle push toward variety |
| 0.6 | About 0.55 | Noticeable topic diversification |
| 1.0 | About 0.37 | Strong avoidance of reused tokens |
| 2.0 | About 0.14 | Aggressive avoidance, risk of odd wording |
| -1.0 | About 2.7 | Encourages reuse of earlier tokens |
The adjustment interacts with the rest of the decoding strategy. Temperature, top-k sampling and min-p sampling operate on the already penalized scores, so a penalty can push a repeated token out of the candidate set entirely. Under greedy decoding, the penalty changes which token has the highest score; under sampling, it reshapes the whole distribution.
Scope, value ranges and implementation details
Implementations differ in which tokens count as present. Most hosted APIs track only tokens generated in the current response, while some open-source inference engines can also include prompt tokens. This distinction matters: when prompt tokens count, the model is discouraged from repeating terms the user supplied, which can harm tasks that require quoting names or variables.
The penalty also operates on tokens, not words. A tokenizer based on byte-pair encoding usually assigns different IDs to “model”, ” model” and “Model”, so penalizing one form leaves the others untouched. The following table summarizes the parameters that typically accompany presence penalty and what each controls.
| Parameter | Typical range | What it controls |
|---|---|---|
| Presence penalty | -2.0 to 2.0 | Flat deduction for any used token |
| Frequency penalty | -2.0 to 2.0 | Deduction growing with each use |
| Repetition penalty | 1.0 to 1.3 | Multiplicative scaling of used tokens |
| Temperature | 0.0 to 2.0 | Overall sharpness of the distribution |
| Logit bias | -100 to 100 | Manual boost or ban of chosen tokens |
Negative values are permitted in many APIs but are rarely useful. A negative presence penalty rewards tokens that already appeared, which can increase looping and contribute to neural text degeneration, the well-documented tendency of models to fall into repetitive or bland output.
Presence penalty compared with related controls
Presence penalty differs from its neighbors mainly in how the deduction scales. Frequency penalty grows linearly with the number of occurrences, so it targets tokens that are overused; presence penalty targets any reuse at all, so it pushes the model toward new vocabulary and new subjects. The repetition penalty introduced in early controllable generation research is multiplicative: it divides positive logits and multiplies negative ones by a factor above 1.
| Control | Scaling with repeats | Best suited for |
|---|---|---|
| Presence penalty | Constant after first use | Broadening topics and vocabulary |
| Frequency penalty | Linear in the count | Stopping verbatim loops |
| Repetition penalty | Multiplicative, constant | Local open-weight model serving |
| No-repeat n-gram rule | Hard ban on repeated sequences | Summaries and translation |
| Logit bias | Fixed per chosen token | Forcing or blocking specific tokens |
In practice, the two additive penalties are often combined. A small presence penalty with a small frequency penalty gives a balanced result: the first discourages returning to used tokens at all, while the second adds increasing pressure against tokens that keep recurring.
Choosing a presence penalty value
The right setting depends on whether variety or precision matters more for the task. Creative and exploratory generation benefits from moderate values, while structured output, code and factual extraction usually require leaving the penalty at zero, because correct answers often reuse the same identifiers, keys and terms many times.
| Task | Suggested value | Reason |
|---|---|---|
| Brainstorming and idea lists | 0.5 to 1.0 | Pushes the model to new concepts |
| Creative writing | 0.2 to 0.6 | Reduces stock phrases without derailing |
| Conversational assistants | 0.0 to 0.3 | Keeps replies natural and on topic |
| Code generation | 0.0 | Code legitimately repeats names and syntax |
| JSON and structured output | 0.0 | Keys and brackets must repeat exactly |
| Summarization and extraction | 0.0 to 0.2 | Source terms must be reproduced |
Tuning should be empirical: change one parameter at a time, generate several samples per setting and review both diversity and correctness. Raising the penalty and the temperature together often compounds the risk of incoherent or off-topic output.
Limitations and common mistakes
Presence penalty is a blunt statistical tool with no understanding of meaning. It cannot tell a harmful repetition from a necessary one, and it penalizes punctuation, function words and formatting tokens just as heavily as content words.
- High values damage fluency: above roughly 1.0, models may choose awkward synonyms or rare tokens to avoid ordinary words.
- Long outputs accumulate penalties: as the response grows, more of the vocabulary becomes penalized, which can degrade later paragraphs more than early ones.
- It does not fix factual errors: hallucination and repetition are separate problems, and a penalty addresses only the second.
- Provider differences matter: the same value can behave differently across APIs that count prompt tokens differently or that apply penalties before or after other filters.
- Reasoning models may ignore it: some providers disable or restrict sampling parameters for reasoning models, so settings should be verified against current documentation.
In simple terms
A language model writes one small piece of text at a time. Before each step, it gives every possible next piece a score. Presence penalty lowers the score of anything already used. It does not matter whether the word appeared once or ten times. The cut is the same.
Think of a dinner host who tries not to serve any dish twice. The host is not banned from repeating a dish, but new dishes get a small advantage. A small penalty makes the writing more varied. A large penalty can make it strange, because the model starts avoiding words it really needs.
A practical example
A marketing team uses a language model to generate forty candidate slogans for a new hiking boot. With the default presence penalty of 0, most slogans circle around the same words, such as “trail”, “adventure” and “comfort”, and the list contains many near duplicates.
The team raises the presence penalty to 0.8 and keeps temperature at 0.9. Because each used token now carries a fixed deduction, later slogans move toward fresh angles such as weight, weather resistance and city use. Reviewers find that the number of clearly distinct ideas roughly doubles, although a few slogans become awkward and are discarded.
For the follow-up task, generating a JSON product feed with repeated field names, the same team resets the penalty to 0, because penalizing keys and brackets would break the required structure.