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

Stop sequences, EOS and log probabilities

Watch a server decide when a reply ends and how sure the model was.


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.23 · DECODE LOOPSTEP 1 · THE · LN P −0.24
01
Stage 1 of 5 · Pick a token
The model gives each of its 10 tokens a probability. Greedy decoding picks “The” and keeps its log probability.
Explain it simply

The bars under the tokens show how likely each next token is after the prompt. The tallest bar wins, so the reply starts with The. The server also writes down the log of its chance, minus 0.24 here. A log of a chance is never above zero.

Ten probability bars. The token The has probability 0.79 and log probability minus 0.24.

promptreply tokens, log probabilitiesEOS, stop sequence, token limit
one decode loop on the serverprompt Q: What colour is the sky?↵A:1The23456789101112step 1: next-token probabilities after “:”greedy pick The · p 0.786 · ln p −0.240.00EOS0.79The0.06sky0.01is0.05blue0.04grey0.01.0.02↵0.01Q0.01:server checks after each tokenEOS: ends the turnstop sequence: nonemax tokens: 12one decode loop on the serverprompt Q: What colour is the sky?↵A:1The23456789101112step 1: next-token probabilities after “:”greedy pick The · p 0.786 · ln p −0.240.00EOS0.79The0.06sky0.01is0.05blue0.04grey0.01.0.02↵0.01Q0.01:server checks after each tokenEOS: ends the turnstop sequence: nonemax tokens: 12
Toy: a 10-token bigram model, greedy, max 12 tokens
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
log⁡p(yt)=ln⁡pt\sy{lp}{out}{\log p(y_t)} = \ln \sy{p}{out}{p_t}
ln⁡0.786=−0.24\ln 0.786 = -0.24

The log probability is the natural log of the chosen token's probability.

Common mix-ups

MYTHThe model sees the stop sequence and stops by itself.

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

Predict, then reveal
3 CHECKS · PRO
Q01With no stop sequence and EOS ending the turn, does a chat-tuned reply run to 12 tokens?

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.