LLM Library
TrainingAnimated
Pretraining: Predicting the Next Token
The first and most expensive training stage.
The idea
The model reads trillions of tokens and is trained to predict each next token. The error (cross-entropy loss) is used to update the weights by gradient descent.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- candidates kept
- chosen
The model produces a raw score (logit) for every word in its vocabulary. Only eight are shown here.
1/3
Temperature reshapes the probabilities; top-k and top-p cut the tail.
Step by step
- 1Collect and clean a huge text dataset
- 2Cut it into sequences
- 3Predict each next token
- 4Update the weights to reduce the loss
Where it is used
Creating a base model.
Watch out for
A base model completes text; it does not follow instructions well until post-training.