liveBook · Manning

Frequency penalty

As explained in The Complete Obsolete Guide to Generative AI

A generation parameter that penalizes tokens in proportion to how often they have already been sampled, reducing repeated words or phrases.

If an AI keeps circling back to the same words, frequency penalty is the nudge that says, “We’ve already used that one.” It reduces repetitive or redundant output by making previously sampled tokens less likely. section 2.10

Use it as a creativity-versus-coherence dial:

  • The model adjusts its token probabilities after words or token sequences appear in the output. section 2.10
  • Higher values discourage repetition more strongly; lower values leave the model more flexibility. The described range is −2.0 to 2.0. section 2.10
  • Unlike presence penalty, frequency penalty responds to how often a token has appeared, rather than applying a one-time penalty after its first appearance. section 2.11

From ordinary smartphone ideas to unusual ones

Without a frequency penalty, a model may suggest familiar features such as a high-resolution display, multiple cameras, fast processing, long battery life, and a sleek design. Increasing the penalty can steer it toward less common ideas such as a holographic display, graphene-based battery, modular hardware, real-time translation, or palm-vein authentication. Check that the result remains useful; novelty alone is not a quality guarantee. section 2.10

Generate some ideas for a new smartphone.

Sure! Here are a few ideas: a high-resolution display, multiple camera lenses, fast processing speed, long battery life, and a sleek design.

Compare the ordinary smartphone suggestions with the higher-novelty alternative in the paired output tables. section 2.10

How The Complete Obsolete Guide to Generative AI covers it

How deep it goes
Explains probability adjustment, tuning range, and tradeoffs, but stops short of implementation code or model internals.
Examples
Uses smartphone feature generation and a comparison with presence-penalty sports-team responses.
What you can do after
Operate/configure generation settings to reduce repeated wording while checking that responses remain coherent and relevant.
How it connects
Contrasts frequency penalty with presence penalty and places both among completion configurations alongside temperature and top-p.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Complete Obsolete Guide to Generative AI. The section links point to the parts of the book it draws on.