Lesson 1 · Unit 03
Predict the next token
Logits, cross-entropy and text that labels itself
What you practise
- Logits over the vocabulary, cross-entropy against the true next token, every position is a training example, teacher forcing
Try a question from this lesson
Pick one
You have a mountain of raw text and nobody to label it. Which training task can you run on it right away?
Correct answer
Hide the next token and have the model predict it
Why
Every position in every text already comes with its answer: the token that follows. The other tasks all need someone to supply labels. This one free task, repeated at enormous scale, is how language models are pretrained.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Scores, probabilities, loss
For each position the model outputs logits: one raw score per token in the vocabulary. Softmax turns them into probabilities.
The loss is the cross-entropy: minus the log of the probability the model gave to the token that really came next. Certain and right costs 0. The less probability on the truth, the higher the loss.
logits one score per vocab token
softmax probabilities, sum to 1
loss -log p(true next token)Concept
Teacher forcing
During training the model always reads the true text, never its own guesses.
If it predicts position 2 badly, position 3 still gets the real token 2 as input. Every position is scored against the truth in parallel, and one mistake cannot derail the rest of the sequence.
10 more exercises in the app
- 4× type the answer
- 2× multiple choice
- 1× fill the blanks
- 1× true or false
- 1× order the lines
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.