Skip to main content

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​

SourceWhat It Provides
Web PagesDiverse topics, conversational text, opinions
BooksStructured arguments, storytelling, deep knowledge
WikipediaFactual knowledge, neutral tone
Scientific PapersTechnical knowledge, research findings
Code RepositoriesProgramming patterns, documentation
News ArticlesCurrent events, journalistic style
Social MediaCasual 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?​

The Core Process

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:

  1. You look at millions of historical weather patterns
  2. You notice: "When clouds gather, rain often follows"
  3. You adjust your mental model to predict rain when you see clouds
  4. Over time, your predictions get better

LLMs do the same thing, but with language:

  1. The model sees billions of sentences
  2. It learns patterns like: "After 'The cat sat on the', 'mat' often follows"
  3. It adjusts parameters to make better predictions
  4. Over time, it learns the structure of language

The Training Process (Simplified)​

Step by Step:​

  1. Take a sentence: "The cat sat on the mat"
  2. Hide the last word: "The cat sat on the ___"
  3. Ask the model to predict: Model might say "floor"
  4. Compare to reality: Actual word was "mat"
  5. Adjust slightly: Make "mat" more likely next time in this context
  6. 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 ReaderLLM
Reads thousands of booksProcesses billions of text samples
Develops intuition about languageDevelops statistical patterns
Remembers key facts (imperfectly)Encodes patterns (imperfectly)
Can generalize to new topicsCan generalize to new prompts
Makes mistakes from memoryMakes 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
  • 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​

  1. Why might an LLM give outdated information about a recent event?
  2. If the internet contains both true and false information, how might that affect an LLM?
  3. 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.