Skip to main content
Lesson 11 of 16 · Mastering Prompts with Mistral

Penalties and Repetitions

Lesson 11 of 16 Updated July 28, 2026 Beginner
On this page
  1. Avoiding Loops and Repetitions
  2. The Presence Penalty
  3. The Frequency Penalty
  4. Difference Between the Two Penalties
  5. When to Use Each Penalty
  6. Watch Out for Extreme Values
  7. Key Takeaways

Avoiding Loops and Repetitions

One of the most frustrating behaviors of a language model is repetition: the model loops on the same words, sentence structures, or ideas. You ask for an in-depth article and get three paragraphs that all start with “Furthermore,” with the word “innovation” on every line. Mistral models offer two parameters to combat this: presence penalty and frequency penalty. They look similar, but their mechanics differ enough that choosing one over the other genuinely changes the output.

The Presence Penalty

The presence penalty is a one-time penalty applied to any token that has already appeared at least once in the generated response. It doesn’t matter if the token was used once or 50 times: the penalty is the same. The parameter accepts values from -2.0 to 2.0, with 0 as the default (disabled). A positive value encourages the model to use new words; a negative value, which is rarer, encourages it to reuse the same ones.

# Positive presence penalty: more varied vocabulary
response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "user", "content": "Describe the benefits of remote work."}
    ],
    presence_penalty=0.6
)

In practice, presence penalty is ideal when you want the model to explore a broader vocabulary and cover different aspects of a topic. In the remote work example above, it pushes the model from hourly flexibility to corporate real estate to carbon footprint, rather than rehashing the time-saving argument three times.

The Frequency Penalty

The frequency penalty, on the other hand, is cumulative: it increases every time a token is reused. The more frequently a word appears, the more it is penalized, making it significantly more effective than presence penalty at breaking loops. It shares the same value range, from -2.0 to 2.0, with 0 as the default.

# Frequency penalty: reduces repetition of frequent words
response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "user", "content": "Write a 300-word article on artificial intelligence."}
    ],
    frequency_penalty=0.5
)

Its sweet spot: long texts where the model tends to repeat the same words or structures. A 300-word article on artificial intelligence, without penalty, risks hammering “AI” and “technology” in every sentence; frequency penalty gradually forces the model to vary its language.

Difference Between the Two Penalties

To grasp the nuance, let’s look at a numerical example. The model has already generated the word “innovation” 5 times in its response. With a presence penalty of 0.5, “innovation” receives a penalty of 0.5—fixed, the 5 occurrences change nothing. With a frequency penalty of 0.5, the same word receives a penalty of 2.5, or 0.5 multiplied by its 5 occurrences. Frequency penalty is therefore much more aggressive against tokens that return often, while presence penalty applies gentle, uniform pressure on everything that has already been said.

When to Use Each Penalty

Use presence penalty when the goal is thematic diversity. In a brainstorming session, you want ten truly distinct ideas, not ten reformulations of the first one:

response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "user", "content": "List 10 digital marketing trends for 2026."}
    ],
    presence_penalty=0.8,
    temperature=0.7
)

Use frequency penalty when the goal is text fluidity. On a long guide, it prevents language tics from setting in without distorting the message:

response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "user", "content": "Write a comprehensive guide on agile project management."}
    ],
    frequency_penalty=0.4,
    temperature=0.5
)

Nothing stops you from combining both for a cumulative effect—a creative newsletter, for example, benefits from both varied vocabulary and text without repetition:

response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "user", "content": "Write a creative newsletter on tech trends."}
    ],
    presence_penalty=0.3,
    frequency_penalty=0.5,
    temperature=0.6
)

Watch Out for Extreme Values

These penalties aren’t knobs to crank to the maximum: values that are too high degrade quality instead of improving it. Beyond 1.0 for presence penalty, the model starts avoiding common words that are actually necessary—articles, prepositions—and the text becomes strange. Beyond 1.0 for frequency penalty, it forces inappropriate synonyms just to avoid repeating itself: “car” becomes “automobile,” then “vehicle,” then “motorized vehicle” in the same paragraph. As for negative values, they encourage repetition, which is rarely desirable. The practical recommendation: stay in the 0.0 to 0.8 range for both parameters; beyond that, side effects outweigh benefits.

To guide you by task: extraction and classification happen without any penalty (presence_penalty=0, frequency_penalty=0, accuracy comes first); short writing under 200 words makes do with frequency_penalty=0.2; long writing over 500 words benefits from combining presence_penalty=0.3 and frequency_penalty=0.5; brainstorming flips the dominance with presence_penalty=0.6 and frequency_penalty=0.3; and a list of unique points goes up to presence_penalty=0.8 with frequency_penalty=0.2.

Key Takeaways

  • Presence penalty encourages the use of new words (fixed penalty)
  • Frequency penalty discourages repetition of frequent words (cumulative penalty)
  • Both parameters range from -2.0 to 2.0, with 0 as default
  • Stay in the 0.0 to 0.8 range to avoid unwanted effects
  • Use presence penalty for thematic diversity, frequency penalty for text fluidity