Loading

Quipoin Menu

Learn • Practice • Grow

prompt-engineering / Frequency & Presence Penalties
tutorial

Frequency & Presence Penalties

Models sometimes repeat themselves. To reduce repetition, you can use frequency penalty and presence penalty. These discourage the model from using the same words or topics over and over.

Penalties reduce repetition by making already‑used tokens less likely to appear again.

Frequency Penalty

Frequency penalty reduces the probability of tokens that have already appeared, proportional to how many times they have been used.
  • Range: -2.0 to 2.0 (positive values reduce repetition).
  • 0.0 = no penalty.
  • 0.5 = moderate reduction of repeated words.
  • 1.0 = strong reduction.
Example: If the model says "very very good", frequency penalty makes the second "very" less likely.

Presence Penalty

Presence penalty reduces the probability of tokens that have already appeared, regardless of how many times. It penalises any repetition at all.
  • Range: -2.0 to 2.0.
  • Positive values encourage new topics.
  • Useful for generating diverse lists or avoiding loops.
Example: Once the word "cat" appears, the model is discouraged from mentioning "cat" again, even once.

Difference Between the Two

  • Frequency penalty: penalises more for repeated occurrences (tamps down overused words).
  • Presence penalty: penalises any occurrence equally (discourages returning to a topic).
  • Use both together for best results.

Example Settings

frequency_penalty = 0.5
presence_penalty = 0.5
Start with 0.3–0.7 and adjust based on observed repetition.


Two Minute Drill
  • Frequency penalty reduces repeated tokens; stronger for repeated occurrences.
  • Presence penalty discourages any repetition of a token.
  • Both help prevent loops and repetitive phrasing.
  • Use positive values (0.2–1.0) to encourage diversity.

Need more clarification?

Drop us an email at career@quipoinfotech.com