How a Model Picks Its Next Word
What a Beam Keeps, and What It Costs
Last timeThe Likeliest Word Is Not the Likeliest Sentence
Beam search is greedy selection applied to sets instead of tokens. Writing its score out reveals a bias towards short sequences, and the standard repair introduces a bias of its own.
Beam search was described in one sentence in the previous lesson: keep the best
partial sequences, extend them all, keep the best again. Writing down
the score being compared shows where its known biases come from.
The score is a sum
Probabilities of long sequences underflow, so beam search accumulates logarithms
instead.
- the running score, always negative and always decreasing
- the logarithm of the probability of one token, a negative number
Every token makes it worse
That last point is worth dwelling on. Since each term is negative, a longer
sequence scores lower than a shorter one, other things being equal. Between two
finished candidates, one of six tokens and one of twelve, the six-token one
starts with an advantage that has nothing to do with quality.
The lesson stops here
7 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents