Log inStart free
LESSON 29.21 · 5 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Repetition, frequency and presence penalties

Watch three penalties push a looping greedy decoder onto new tokens.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 29.21 · DECODERGREEDY · 16 TOKENS · 11 REPEATS
01
Stage 1 of 5 · Greedy loops
Greedy decoding takes the top logit at every step. The text falls into a loop: “cat sat on the”.
Explain it simply

Greedy decoding always takes the token with the highest score, its logit. After “on” the top logit is “the”, and after “the” it is “cat”. So the same four words come back again and again. The top row shows this loop, and a mark under a chip shows a repeated phrase.

The top row shows 16 greedy tokens with no penalty: cat sat on the, four times. The rows below show the logits at step 4, after on. The top logit is the at 2.20.

logits and countsbefore the penalty: logit, pickpenalty, repeated phrasepicked token
no penaltypresence α 0.5step 4, after “on”0the2.20cat−1.00dog−1.00sat−1.50ran−1.50on−2.00mat1.90rug1.30and−1.50.−1.00pickthepromptcat1sat2on3the4cat5sat6on7the8cat9sat10on11the12cat13sat14on15the16theprompt12345678910111213141516no penaltypresence α 0.5step 4, after “on”0the2.20cat−1.00dog−1.00sat−1.50ran−1.50on−2.00mat1.90rug1.30and−1.50.−1.00pickthepromptcat1sat2on3the4cat5sat6on7the8cat9sat10on11the12cat13sat14on15the16theprompt12345678910111213141516
Toy: a 10-token bigram model with hand-set logits, prompt “the”, 16 greedy steps
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
next=arg⁡max⁡jzj\sy{nx}{out}{\text{next}} = \arg\max_j \sy{z}{data}{z_j}
arg⁡max⁡jzj=the, z=2.20\arg\max_j z_j = \text{the},\ z = 2.20

Greedy takes the token with the largest logit.

Common mix-ups

MYTHA repetition penalty divides every seen logit by θ.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01At weak strength, which penalty never breaks the “cat sat on the” loop?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.