19/29
Part 4 of 5 · The loss and the length limitLearn and do
Guess the next token, everywhere at once
The model predicts each next token from the tokens before it. So the targets are the inputs shifted by one. With the sentence:
# the cat sat on the mat, as a plain list
ids = [0, 1, 2, 3, 0, 4]
# inputs: all but the last
print(ids[:-1])
# targets: all but the first
print(ids[1:])
[0, 1, 2, 3, 0]
[1, 2, 3, 0, 4]
position01234
idxtargetsPosition 2 sees “the cat sat” and must guess on. 5 guesses from one sentence, all graded at once.
One sentence of six tokens gives five guesses, one per position, all graded at once. The shift happens where the batch is built, not inside the model.
You shift the targets where the batch is built, and again inside the model. What happens?
Pick an answer above to see the rest