Chapter 1: Training on Text Data
Teaching a Machine to Understand Language
Training an LLM is like teaching a very fast reader to understand how language works. But instead of teaching facts, we're teaching patterns.
Where Does Training Data Come From?
Modern LLMs are trained on a staggering amount of text:
Common Data Sources
| Source | What It Provides |
|---|---|
| Web Pages | Diverse topics, conversational text, opinions |
| Books | Structured arguments, storytelling, deep knowledge |
| Wikipedia | Factual knowledge, neutral tone |
| Scientific Papers | Technical knowledge, research findings |
| Code Repositories | Programming patterns, documentation |
| News Articles | Current events, journalistic style |
| Social Media | Casual conversation, trends |
The Scale Is Mind-Boggling
- GPT-3 was trained on roughly 570 GB of text
- That's about 300 billion words
- Equivalent to reading non-stop for thousands of years
What Does "Training" Actually Mean?
Training is adjusting the model's parameters so it gets better at predicting what text comes next.
Think of It Like This:
Imagine you're learning to predict the weather:
- You look at millions of historical weather patterns
- You notice: "When clouds gather, rain often follows"
- You adjust your mental model to predict rain when you see clouds
- Over time, your predictions get better
LLMs do the same thing, but with language:
- The model sees billions of sentences
- It learns patterns like: "After 'The cat sat on the', 'mat' often follows"
- It adjusts parameters to make better predictions
- Over time, it learns the structure of language
The Training Process (Simplified)
Step by Step:
- Take a sentence: "The cat sat on the mat"
- Hide the last word: "The cat sat on the ___"
- Ask the model to predict: Model might say "floor"
- Compare to reality: Actual word was "mat"
- Adjust slightly: Make "mat" more likely next time in this context
- Repeat billions of times
What the Model Learns
Language Structure
- Grammar rules (without being told them)
- How sentences are constructed
- Word order for different languages
Relationships Between Concepts
- "Paris" relates to "France" like "Tokyo" relates to "Japan"
- "King" relates to "Queen" like "Man" relates to "Woman"
Writing Styles
- Formal vs. casual language
- Academic vs. creative writing
- Technical vs. general audience
World Knowledge (Sort Of)
- Facts mentioned frequently in training data
- Common associations between concepts
- But NOT a verified fact database!
What the Model Does NOT Learn
❌ Verified Facts
The model doesn't know if something is true—just that it was written a lot.
❌ Real-Time Information
The model only knows what existed in training data (before its "knowledge cutoff").
❌ Personal Experiences
It hasn't lived, felt, or experienced anything.
❌ True Understanding
It recognizes patterns, but doesn't "understand" in the human sense.
The "Reading Everything" Analogy
Think of training like this:
| Human Reader | LLM |
|---|---|
| Reads thousands of books | Processes billions of text samples |
| Develops intuition about language | Develops statistical patterns |
| Remembers key facts (imperfectly) | Encodes patterns (imperfectly) |
| Can generalize to new topics | Can generalize to new prompts |
| Makes mistakes from memory | Makes mistakes from patterns |
The key insight: LLMs develop intuition about language without understanding it the way humans do.
Training Data Problems
1. Bias in Data
If the training data contains biases, the model learns them:
- Historical prejudices
- Cultural blind spots
- Overrepresentation of certain viewpoints
2. Outdated Information
- Training data has a cutoff date
- Information changes after training
3. Quality Variation
- Not everything on the internet is accurate
- The model can't distinguish reliable from unreliable sources
4. Copyright Questions
- Some training data may be copyrighted
- Legal debates are ongoing
Pre-Training vs. Fine-Tuning
Pre-Training (The Foundation)
- Massive dataset (the entire internet, essentially)
- Learn general language patterns
- Very expensive and time-consuming
- Done once, by the company
Fine-Tuning (The Specialization)
- Smaller, specific dataset
- Adjust for particular tasks (chat, code, etc.)
- Much cheaper and faster
- Can be done by anyone with resources
RLHF (Making It Helpful)
- Human raters score responses
- Model learns to produce higher-rated answers
- Makes outputs more helpful and less harmful
- What turns GPT into ChatGPT
Key Takeaways
✅ LLMs are trained on billions of text samples from the internet and books
✅ Training means adjusting parameters to predict text better
✅ The model learns patterns and relationships, not verified facts
✅ Training data limitations (bias, age, quality) affect outputs
✅ Fine-tuning and RLHF make base models more useful
Think About It
- Why might an LLM give outdated information about a recent event?
- If the internet contains both true and false information, how might that affect an LLM?
- Why would a company want to fine-tune a pre-trained model instead of training from scratch?
Next Steps
Now let's look at the core mechanism in Chapter 2: Predicting the Next Word.