What Are Frequency and Presence Penalties?
What frequency and presence penalties do to repeated words in AI output, when to turn them up, and where they break things, for your AI interview.
In short
Frequency and presence penalties are settings that make a model less likely to repeat words it has used. The frequency penalty counts how often a word has appeared, and the presence penalty only asks whether it has appeared. They reduce repetition, but they can also push out names and IDs that must repeat.
9 min readIntermediateOccasional · estimateFacts checked 27 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
Frequency and presence penalties are two settings that stop a model repeating itself. Frequency counts how many times a word has already appeared. Presence only checks whether it has appeared at all. They cut repetition, but turn them up too far and the model avoids words it must repeat, like a claim number or a defined term. So I start at zero, raise them a little, and check the output.
When a model writes, it picks each next token from a list of scores. Left alone, it can fall into a loop and repeat the same sentence again and again. Frequency and presence penalties are two settings that push the scores of tokens already used down, so the model tries something new.
The frequency penalty depends on how often a token has appeared. OpenAI says a positive value decreases the model's likelihood to repeat the same line word for word. The presence penalty only asks whether a token has appeared at all, and increases the model's likelihood to talk about new topics. OpenAI takes values from minus 2.0 to 2.0, and Google's maximum stops just short of 2.0.
The catch is that the penalty works on tokens. A token is a chunk of text, often part of a word. So a claim number or a defined term that has to repeat gets penalised like any other repeat, and common small words get hit too. I treat them as a gentle nudge, and I would not use them as a hard ban.
In practice I keep them at zero for anything that must stay exact, like a policy quote or a legal summary. I change one setting at a time, then check real drafts side by side. And I check the model's docs first, because some newer Google models return an error if these values are set.
What are frequency and presence penalties, in plain words?
A language model writes by picking one token at a time, and each candidate token gets a score. Left alone, it can fall into a loop and repeat the same sentence. A frequency or presence penalty lowers the score of tokens that have already appeared, so the model is pushed towards new wording.
OpenAI and Google both offer these two settings in their model APIs (the way a program asks the model for text). OpenAI takes a number from minus 2.0 to 2.0. Google's minimum is minus 2.0, and its maximum stops just short of 2.0. They work on different signals: one counts how often a token has appeared, and the other only asks whether it has appeared at all.
Picture a claims clerk writing letters all day. After the tenth letter that opens with "We are reviewing your claim", a good supervisor asks them to vary the wording.
The real version is a drafting bot writing hundreds of claim letters. A penalty is the rule built into its scoring that pushes it to vary the wording.
Key words
- Token
- A chunk of text the model reads and writes, often part of a word.
- Frequency penalty
- A cut to a token's score based on how often it has appeared.
- Presence penalty
- A cut to a token's score based on whether it has appeared at all.
- Repetition
- The same words or lines coming back, often a sign the model is looping.
- Sampling
- How the model picks its next token from the scored list.
How do the two penalties differ?
Both only push down tokens that have already appeared. They differ in what they look at. Frequency looks at how often a token has appeared, so a token used six times is treated differently from one used twice. Presence looks only at whether it has appeared, so the second repeat and the sixth are treated the same.
“Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.”
OpenAI, Completions API reference: frequency_penalty
“Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.”
OpenAI, Completions API reference: presence_penalty
How the two penalties push down a repeat
Word already in the text
every single token so far
Two penalties
Frequency penalty
counts each repeat
Presence penalty
checks whether it has appeared
Model picks next word
repeated words score lower
Less repeated text
new words get a fair chance
- 1The word's past use goes to the frequency penalty.
- 2Whether it appeared at all goes to the presence penalty.
- 3The frequency cut, which counts each repeat, comes off its score.
- 4The presence cut, which only checks if it appeared, comes off its score too.
- 5The model picks from the words left, so repeats fall.
Tip
A quick way to remember it: frequency counts the repeats, and presence only checks whether the word has come up at all.
Why do models repeat in the first place?
Penalties are one answer to a model that loops. A research paper by Holtzman and colleagues, "The Curious Case of Neural Text Degeneration", found that choosing text by likelihood gives text that is bland and strangely repetitive.
“using likelihood as a decoding objective leads to text that is bland and strangely repetitive”
Holtzman and colleagues, arXiv 1904.09751
Penalties are a blunt fix. They act only on tokens and have no sense of meaning, so the model cannot tell a repeat it should keep from one it should drop.
Worked example, with made-up numbers. A claims team at a mid-size insurer uses a drafting bot to write repayment letters. Its drafts repeat "We are reviewing your claim" four times, and every letter must quote the claim number, CL-48213, in full.
- 1
Try a small penalty first
The team sets the frequency penalty to 0.3 on a test batch of 20 letters, then reads the batch side by side with the old one.
- 2
Watch what drops out
The repeats fall, but the bot can now swap the claim number out for words like 'your file' or 'the matter'. The customer is left unsure which claim the letter means.
- 3
Keep exact bits out of reach
Fill the claim number and policy terms from the claim record in code, and check each letter for them before it is sent. The penalty only shapes the wording around them.
Do the settings work on every model?
No. Google's Vertex AI reference warns that custom values for these two settings "aren't supported for Gemini 3.6 Flash and later models and return an error if set." The same setting can work on one model and fail on the next, so check the docs for the exact model before you ship.
Tip
Asked how you'd tune them? Say you start at zero, raise one setting a little, and compare real outputs. Don't name a number as the right answer for every case.
What does the interviewer want to hear?
A strong answer covers
- A plain definition: each setting lowers the score of words already in the text.
- Frequency counts repeats; presence only checks whether a word has appeared.
- Both work on tokens, so exact terms, IDs and names can get hurt.
- Start at zero, raise a little, and check real output.
- Not every model accepts them; check the docs for the one in use.
Common traps
Trap"Turn the penalty up to stop hallucinations."
BetterPenalties only change which words repeat. A wrong answer stays wrong, so check it against a source.
Trap"Max out both penalties so the answer is always fresh."
BetterValues near 2.0 push hard and break exact text. Start near zero and measure.
Trap"Frequency and presence are the same setting."
BetterFrequency counts repeats. Presence only checks whether a word has appeared at all.
Can you spot the damage?
Spot the damage
Which claim letter shows a penalty that pushed too hard, so the exact reference was lost?
Quick check
A legal team's clause summariser must keep the defined term Customer Data exactly as the contract writes it. The team sets the frequency penalty to 1.5 to stop repeats. What is the most likely result?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Last updated on 27 November 2026
Building a drafting or summary tool that must repeat exact terms?
I design and build AI products and agents (the UI and the system behind it). Book a short call and tell me what you need.