---
title: "What are frequency and presence penalties in LLMs? | BroadRouter"
description: "Frequency and presence penalties lower the odds of tokens a model has already used, to cut repetition. How they differ, their ranges, and repetition_penalty."
url: https://broadrouter.com/glossary/frequency-and-presence-penalty/
lang: en
updated: 2026-11-15
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# Frequency and presence penalty

Updated 2026-11-15

Frequency and presence penalties are sampling settings that lower the score of tokens already in the output. The presence penalty applies once a token has appeared at all; the frequency penalty grows with each repeat. In OpenAI's API both range from -2.0 to 2.0, with 0 as the default.

Also called: frequency penalty, presence penalty, frequency\_penalty, presence\_penalty, repetition penalty

A model stuck in a loop repeats the same phrase until it runs out of tokens. Penalties are a blunt fix applied at sampling time.

## How it works

Before each next [token](https://broadrouter.com/glossary/token/) is drawn, the server adjusts the scores of tokens already generated.

| Setting | What vLLM’s docs say it penalises | Range and default |
| --- | --- | --- |
| `presence_penalty` | Tokens “based on whether they appear in the generated text so far” | OpenAI: -2.0 to 2.0, default 0 |
| `frequency_penalty` | Tokens “based on their frequency in the generated text so far” | OpenAI: -2.0 to 2.0, default 0 |
| `repetition_penalty` | Tokens “based on whether they appear in the prompt and the generated text so far” | vLLM and Hugging Face: 1.0 means no penalty |

Positive values push away from used tokens; negative values make repeats more likely. OpenAI says a positive frequency penalty lowers “the model’s likelihood to repeat the same line verbatim”, and a positive presence penalty raises “the model’s likelihood to talk about new topics”. For `repetition_penalty`, vLLM says values above 1 favour new tokens and values below 1 favour repetition. Hugging Face’s docs point to the CTRL paper for this penalty.

```json
{"model": "...", "messages": [...], "frequency_penalty": 0.5, "presence_penalty": 0.3}
```

## Why it matters

-   **Loops in long outputs.** Agents and long summaries can fall into repeating text. A small penalty can break the loop, and a hard [max\_tokens](https://broadrouter.com/glossary/max-tokens/) limit caps the damage.
-   **Side effects.** Penalties act on tokens, not ideas. A strong one can stop a model reusing words it needs, such as a variable name in code, a JSON key, or a name in an Arabic text that repeats by design. Start at 0 and change in small steps.
-   **Overlap with sampling.** [Temperature](https://broadrouter.com/glossary/temperature/) and [top-p](https://broadrouter.com/glossary/top-p/) also change variety. Change one setting at a time when you test.

## On BroadNet Inference

BroadNet’s [API reference](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=glossary-frequency-and-presence-penalty&utm_content=body) does not document `frequency_penalty`, `presence_penalty` or `repetition_penalty`. Test them before relying on them: send a prompt that tends to repeat, with and without the field, and compare. If repetition shows up in long runs, try a clearer prompt, a lower output limit, or stop the run and resume from a checkpoint; the [overnight agent runs post](https://broadrouter.com/blog/overnight-coding-agent-runs/) covers that pattern.

## Common mistakes

-   Setting penalties high to fix a prompt problem. Repetition often means the model has no clear stopping point.
-   Using a penalty on structured output, where keys must repeat.

## Questions

### What is the difference between frequency and presence penalty?

Presence penalty asks "has this token appeared?" and applies once. Frequency penalty asks "how often?" and grows with each repeat. vLLM describes them as penalising tokens by whether they appear and by their frequency in the text so far.

### Is repetition\_penalty the same thing?

No. It is a separate multiplier used by vLLM and Hugging Face, where 1.0 means no penalty. vLLM applies it to tokens in the prompt and the output, not only the output.

### Does BroadNet Inference support these penalties?

BroadNet's API reference does not document frequency\_penalty, presence\_penalty or repetition\_penalty. Test them before relying on them.

## See also

-   [Temperature](https://broadrouter.com/glossary/temperature/) (term)
-   [Top-p (nucleus sampling)](https://broadrouter.com/glossary/top-p/) (term)
-   [Token](https://broadrouter.com/glossary/token/) (term)
-   [Logprobs](https://broadrouter.com/glossary/logprobs/) (term)
-   [Seed parameter](https://broadrouter.com/glossary/seed-parameter/) (term)
-   [How to run coding agents unattended overnight, safely](https://broadrouter.com/blog/overnight-coding-agent-runs/) (article)
-   [Agent token budget: where an agent loop's tokens go](https://broadrouter.com/blog/agent-token-budget/) (article)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=glossary-frequency-and-presence-penalty&utm_content=page-cta) ·

**Sources**

-   [OpenAI API reference, create chat completion (frequency\_penalty, presence\_penalty) (checked 2026-11-15)](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create)
-   [vLLM documentation, SamplingParams (presence, frequency and repetition penalties) (checked 2026-11-15)](https://docs.vllm.ai/en/latest/api/vllm/sampling_params/)
-   [Keskar et al., CTRL: A Conditional Transformer Language Model for Controllable Generation, arXiv 1909.05858 (checked 2026-11-15)](https://arxiv.org/abs/1909.05858)
-   [Hugging Face Transformers, GenerationConfig (repetition\_penalty) (checked 2026-11-15)](https://huggingface.co/docs/transformers/main_classes/text_generation)
