Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 1 of 12
LLM Pretraining
Pretraining is the first and most expensive phase of training an LLM. It is where the model learns language, facts, and reasoning from enormous amounts of text.
What Happens During Pretraining
Pretraining is the process of training an LLM on a massive corpus of text with the goal of predicting the next token. This phase:
- Takes weeks or months on thousands of AI chips
- Processes trillions of tokens of text
- Teaches the model grammar, facts, reasoning, and code patterns as side effects
- Produces a 'base model' (or 'pretrained model') that can complete text but is not yet optimized for conversation
The output of pretraining is called a base model or foundation model. Base models are powerful but raw — they will complete any text, including harmful content, because they simply learned to predict text continuations without any filters.
For example, GPT-3 before instruction tuning would respond to 'Write instructions for making a bomb:' by completing the text as it appeared in training data. This is why further training (fine-tuning and alignment) is essential.
LLM Pretraining Diagram
Why Pretraining Cannot Be Skipped
- Pretraining gives the model its core language understanding — without it, fine-tuning has nothing to build on
- Pretraining is where world knowledge is acquired — all the facts, reasoning patterns, and language skills
- Fine-tuning with small datasets only works because the model already understands language from pretraining
- Even the most specialized model starts as a pretrained base model
Quick Q&A
Key Takeaways
- Pretraining is the first and most expensive phase of training an LLM.
- Pretraining gives the model its core language understanding — without it, fine-tuning has nothing to build on
- Pretraining is where world knowledge is acquired — all the facts, reasoning patterns, and language skills
- Fine-tuning with small datasets only works because the model already understands language from pretraining
Finished this lesson?