Skip to the workspace
Pebellslearn by building
Tokens, Context and Sampling  ›  Capstone Project

Repetition Penalties

Repetition Penalties 12 minRepetition penalties lower the chance of tokens that have already appeared, with presence penalties asking whether a token was used at all and frequency penalties growing with how often.

ai engineer / Repetition Penalties

Explore each scene at your own pace.

01 · The rule

The rule

Repetition Penalties

The marketing team asks the Pedal Point assistant for ten taglines for a winter sale. It returns "Ride into winter", "Ride the winter", "Winter riding made easy", "Ride winter in style"... Every line leans on the same two words. Temperature alone did not fix it. A repetition penalty will.

The rule

Penalties make tokens already used less likely to be used again.

As the model writes, the app keeps track of which tokens have appeared. A penalty lowers the score of those tokens before the next pick. There are two common flavours:

  • A presence penalty applies a flat reduction to any token that has appeared at least once. It asks: "Have we used this before?" It nudges the model toward new words and topics.
  • A frequency penalty grows with how many times a token has appeared. It asks: "How often have we used this?" It mostly stops one word from being hammered again and again.

Some tools, especially for running open models locally, offer a single "repetition penalty" that scales down the scores of recent tokens. Names, ranges and exact formulas differ between providers, so read the documentation for the one you use and start with small values.

Penalties are also a fix for loops, where a model gets stuck repeating a phrase or list item. They are not free. A penalty does not know which repeats are good. In a support answer, the order number, the product name and words like "the" must repeat. Push too hard and the model starts avoiding them, choosing odd synonyms or even changing a number.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.