TAKE THE LONGER ROUTE

Open the complete high-school lesson →

Worked explanations, full local narration, and connected Signal Room, Workbench and Field Notes.

← Connected lesson

PretrainingA gentler route.

Separate the size of the learner from the amount of practice it receives.

More time for: Data leakage, deduplication, evaluation splits and compute-optimal assumptions.

Open high-school classroom and assessment ↗

Welcome & Overview

Welcome everyone! Today, we’re starting an exciting journey into the world of AI pretraining. This course will help you understand how large language models learn before they ever start chatting with us.

First, let’s look at what pretraining actually means in AI. Think of it like teaching a robot tons of information before it can make smart decisions on its own.

Next, we'll explore why pretraining is really important for large language models, which are the brains behind tools like chatbots and translators you might use every day.

Finally, I’ll give you an overview of the course agenda and explain how we’ll interact, including activities and discussions to keep things engaging.

As we go through this, keep your questions ready. Understanding pretraining will build a strong foundation for all the AI topics ahead.

Welcome & Overview

What is Pretraining in AI?

Why Important for Large Language Models?

Course Agenda & Interactive Format Preview

• Step-by-step learning with examples

• Real-world analogies and visuals

• Live Q&A and hands-on activities

From Raw Text to Tokens

Today, we're diving into how massive amounts of raw text get transformed into tokens, the basic building blocks that AI understands.

First, we start with raw text—imagine gigabytes or even terabytes of unprocessed text data from all over the internet.

Think of this like LEGO bricks: just like big LEGO structures break down into small pieces, text is split into smaller, manageable units.

Before tokenizing, the data is filtered and cleaned—removing duplicates and useless parts to improve quality.

Finally, the text is tokenized, which means turning words or parts of words into tokens that AI algorithms can process.

This process is crucial because AI can't work with raw text directly; tokens are like its language. Understanding this helps us see how AI learns from language.

From Raw Text to Tokens

• Raw text: Gigabytes or terabytes of unprocessed words from books, websites, and chats

• Tokenization: Breaking text into smaller pieces called tokens — the basic language units AI understands

Like LEGO Bricks

Text is split into small pieces, just like building blocks

Filtering & Deduplication

Removing useless or repeated text for clean data

Tokenizing

Turning words into tokens AI can process efficiently

Tokenization Demo

Today, let's explore how computers break down text into smaller pieces called tokens. This process is called tokenization, and it helps machines understand language, just like we do when we read.

Notice how the sentence gets split into individual words. It's like cutting a cake into slices so the computer can study each piece.

Next, each word might split into smaller tokens—like breaking big LEGO blocks into tiny pieces. Spaces, punctuation, emojis, and hashtags all get special treatment here.

Try hovering over the example tokens to see how tricky words or emojis get split. This gives you a real feel for tokenization working.

Finally, all these tokens line up to form a sequence—the computer’s recipe for understanding your text. Feel free to experiment with social media style text like slang or emojis to watch the process.

Data Quality: Garbage In, Garbage Out

Let's dive into why data quality is absolutely critical for AI training. The phrase "Garbage In, Garbage Out" means that if we feed bad data into an AI, the results will also be bad.

First, we need to understand why data quality matters. It’s about filtering out bad or duplicate data so the AI learns from only clean and useful information.

One key step is filtering and deduplication. This means removing repeated or junk entries to keep the dataset unique and reliable.

For example, removing junk text like typos, spam, or irrelevant content helps the AI focus on meaningful data.

Another important point is domain balancing. This keeps the data diverse, so the AI doesn’t get too focused on one type of example.

In short, keeping data clean and unique, removing typos and repeats, and ensuring variety help AI learn better and make smarter decisions.

Now that we’ve covered these core ideas, let's keep these principles in mind the next time we work with any data-driven system.

Data Quality: Garbage In, Garbage Out

Why Data Quality Matters

• Filtering & Deduplication: Remove junk and repeats

• Examples: Junk text like typos, spam; repeated data can bias results

• Domain Balancing: Keeps data diverse and fair for AI learning

Filtering & Deduplication

Removing Junk Text

Domain Balancing

Keep data clean and unique

Remove typos, spam, repeats

Ensure diverse examples

Training Objective: Predict the Next Token

Let's dive into the core training objective of language models: predicting the next token in a sequence. Think of it like finishing someone's sentence before they even get there.

At its heart, this uses a simple loss function, which means the model learns by measuring how good its guesses are. It's like a friendly game where the model tries to get the next word right.

For example, if the sentence is 'I like to eat', the model's job is to guess what comes next, maybe 'pizza' or 'apples.' This guessing game is the core of how it learns language patterns.

And here's something really cool: no human labels are needed. The model just learns from tons of text on its own, without someone telling it the right answers. It's like learning by reading a huge library.

So, to sum up, this training method teaches the model to predict what comes next in a sentence by guessing and checking, using a simple loss to improve, all without extra human help.

Training Objective: Predict the Next Token

Simple loss function idea
in everyday words

Guessing the next word
in a sentence

No human labels needed

• The model learns by predicting what comes next in data sequences

• Like guessing the next word on social media or in video chats

• This simple goal lets it learn from lots of text without manual labeling

Loss Curve & What It Means

Today, we're going to explore the loss curve and understand what it tells us about a model's training progress.

Think of loss like a game score—except in this game, a lower score means you're doing better. The loss measures how far off your model’s predictions are from the correct answers.

As the model learns, the loss curve will move, usually dropping downward. This shows the model is improving and making fewer mistakes.

Why does this matter? A smooth drop in the loss curve usually means the model will perform better in the end, giving us higher quality AI results.

By tracking this curve step-by-step, we get a clear picture of how training is going and if the model is learning effectively.

So, in summary, the loss curve is our way of measuring progress in training, just like watching your score improve while playing a game.

Loss Curve & What It Means

Tracking Training Progress Step-by-Step

• Loss as a game score

Imagine loss like your video game score—lower is better!

• Curve moves as model learns

The curve drops as the AI gets smarter and improves.

• Why it matters

A smooth drop means better final AI performance and accuracy.

Loss Curve Simulator

Today, we're going to explore the Loss Curve Simulator and see how training steps, tokens processed, and model size impact the shape of the loss curve during AI pretraining.

Now try selecting different preset scenarios like Large Model or More Tokens to observe how combined changes influence the curve and what it means for AI learning.

Remember, the shape of the loss curve reveals how fast and how well an AI model is improving — insightful for understanding AI’s abilities in the real world.

Scaling Laws & Efficiency

Let's begin by exploring the concept of scaling laws and efficiency in AI training. This is a key idea that helps us understand how increasing resources affects AI performance.

So, what exactly are scaling laws? Simply put, they’re mathematical rules that show how changing factors like data size or computing power can improve an AI model’s learning and accuracy.

Think of scaling laws like cooking a recipe. Just as you balance ingredients to get the perfect dish, AI training balances different resources to achieve better results.

Here’s a real-world example: comparing Llama 3 and GPT-3. Llama 3 trained on twice the amount of tokens but with much lower cost, showing how scaling efficiently can make a big difference.

Understanding these principles helps AI developers decide where to invest resources for the best improvements, making AI both powerful and cost-effective.

Scaling Laws & Efficiency

What are scaling laws in AI training?

• Mathematical rules to predict AI performance as we grow resources

Real-world analogy:

• Balancing ingredients in cooking

• More salt, spice, or time changes taste like more compute affects AI

Example: Llama 3 vs GPT-3

• Llama 3 trained on twice tokens of GPT-3

• Costs and speed reflect scaling laws in practice

Continued Pretraining & Domain Adaptation

Today, we are diving into the topic of Continued Pretraining and Domain Adaptation. This is all about how AI models can keep learning even after their initial training, especially when they need to handle special types of data.

First, let's understand the difference between full pretraining and continued pretraining. Full pretraining means training a model from scratch on a huge general dataset. Continued pretraining is like giving that model extra lessons on specific topics without starting over.

For example, if we want AI to understand medical terminology or coding languages, we use continued pretraining on those kinds of texts. This helps the AI become more specialized without the huge cost of retraining everything.

The benefits here are clear: it's cheaper than full training and gives the AI specific abilities. This way, AI can adapt to new tasks or fields much faster.

So, continued pretraining is like giving an already smart student some extra tutoring in one subject, instead of going back to school for every new topic. Let's keep this image in mind as we explore AI training techniques.

Continued Pretraining & Domain Adaptation

Full vs Continued Pretraining

• Full: training from scratch on big data
• Continued: extra training on special data

Examples

• Medical texts
• Coding languages
• Other specialized topics

Benefits

• Cheaper than full training
• AI learns special skills
• Faster adaptation to needs

Check Your Understanding

Now it's time to check how well you grasped the key ideas we just covered. Give each question your best shot on your own.

Once you finish and submit, we’ll go through anything that needs clarification together.

Recap & Key Takeaways

Let's start our recap with the first key step: raw text gets cleaned and tokenized. This means the model breaks down huge amounts of text into smaller pieces called tokens, which it can understand more easily.

Next, the model learns by predicting the next tokens. Imagine you're playing a word game where you guess the next word; the model does something similar to learn language patterns.

We track training progress with a loss curve. Think of it like a scoreboard showing how well the model is doing—the lower the loss, the better it predicts.

Scaling up the model and using high-quality data are crucial. Just like how a bigger engine with better fuel makes a car run faster and smoother, larger models with great data perform better.

Here's a fun fact to end with: no humans actually label the training data. The model learns patterns directly from raw text, without anyone tagging all the words or sentences.

So, in summary, we covered how data is prepared, how the model learns, how progress is tracked, why scale and quality matter, and that humans don’t hand-label this data. Great work today—these key takeaways form the foundation for understanding advanced language models.

Recap & Key Takeaways

Raw Text Gets Cleaned and Tokenized

Model Learns by Predicting Next Tokens

Training Progress Shown by Loss Curve

Scaling and Data Quality Are Crucial

Fun Fact: No Humans Label the Training Data!

Next Steps & Resources

Now let's explore the next steps and resources you can use to deepen your understanding and practice of AI training.

First, we have interactive AI playgrounds. These are online spaces where you can try hands-on demos and experiment with AI models directly.

Playing around with these demos is a great way to see how AI behaves and learn by doing, which often sticks better than just reading.

Alongside that, I encourage you to check out further reading suggestions. These will help build a stronger foundation in the concepts we discussed.

Remember, experimenting with AI demos and practicing regularly will boost your skills and confidence in understanding how AI works behind the scenes.

To sum up, using these interactive tools and resources will help you explore further and learn by doing, which is key in mastering AI concepts.

Next Steps & Resources

• Interactive AI playgrounds

Try hands-on demos to experiment live

• Further reading suggestions

Explore articles, books, and online courses

• Experiment with AI demos

Learn by testing ideas and observing results