Skip to content
Stanford CS229 I Machine Learning I Building Large Language Models (LLMs)
This video isn’t embeddableWatch on YouTube →
Stanford OnlineStanford Online

Stanford CS229 I Machine Learning I Building Large Language Models (LLMs)

For more information about Stanford's Artificial Intelligence programs visit: https://stanford.io/ai This lecture provides a concise overview of building a ChatGPT-like model, covering both pretraining (language modeling) and post-training (SFT/RLHF). For each component, it explores common practices in data collection, algorithms, and evaluation methods. This guest lecture was delivered by Yann Dubois in Stanford’s CS229: Machine Learning course, in Summer 2024. Yann Dubois PhD Student at Stanford https://yanndubs.github.io/ About the speaker: Yann Dubois is a fourth-year CS PhD student advised by Percy Liang and Tatsu Hashimoto. His research focuses on improving the effectiveness of AI when resources are scarce. Most recently, he has been part of the Alpaca team, working on training and evaluating language models more efficiently using other LLMs. To view all online courses and programs offered by Stanford, visit: http://online.stanford.edu Chapters: 00:00 - Introduction 00:10 - Recap on LLMs 00:16 - Definition of LLMs 00:19 - Examples of LLMs 01:16 - Importance of Data 01:20 - Evaluation Metrics 01:33 - Systems Component 01:41 - Importance of Systems 01:47 - LLMs Based on Transformers 01:57 - Focus on Key Topics 02:00 - Transition to Pretraining 03:02 - Overview of Language Modeling 04:17 - Generative Models Explained 05:15 - Autoregressive Models Definition 06:36 - Autoregressive Task Explanation 07:49 - Training Overview 08:48 - Tokenization Importance 10:50 - Tokenization Process 13:30 - Example of Tokenization 16:00 - Evaluation with Perplexity 20:50 - Current Evaluation Methods 24:30 - Academic Benchmark: MMLU

Yann Duboishost
Aug 27, 20241h 44mWatch on YouTube ↗

Summaries, chapters, transcripts, and FAQs on this page are made by uListen, not YouTube.

At a glance

WHAT IT’S REALLY ABOUT

Building LLMs: Pretraining, Scaling Laws, Post-Training, Evaluation and GPU Systems Explained

  1. Dubois argues that data, evaluation and systems matter more in practice than architecture and loss tweaks, which is where academia tends to focus.
  2. Pretraining models the distribution of text with an autoregressive next-token objective trained with cross-entropy, relying on tokenizers (such as byte pair encoding) and evaluated with perplexity and benchmarks like MMLU.
  3. Scaling laws let teams predict performance from compute, data and parameters, guiding choices like model size versus tokens (Chinchilla's roughly 20 tokens per parameter) and informing cost estimates such as his roughly $75M back-of-envelope figure for Llama 3 400B.
  4. Post-training turns a raw language model into an assistant through supervised fine-tuning and preference optimization (PPO-based RLHF or the simpler DPO), increasingly using LLM-generated data and LLM judges instead of humans.
  5. Because compute is the bottleneck, systems tricks such as low-precision arithmetic, operator fusion and torch.compile help GPUs avoid sitting idle.

IDEAS WORTH REMEMBERING

5 ideas

Data, evaluation and systems matter more than architecture in practice

Dubois says academia over-focuses on architectures and losses, while industry spends its effort on data, evaluation and systems; he ties this to the 'bitter lesson' that scalable compute and data dominate small architectural differences.

Tokenizers are a quiet but important design choice

Tokens are more general than words and shorter than character sequences, which would be too long for quadratically scaling transformers. Tokenization quirks (such as numbers and code whitespace) can hurt math and code ability, so some hope to move away from tokenizers eventually.

Scaling laws make large training runs plannable

Loss falls predictably as a straight line on log-log plots of compute, data and parameters, so teams can tune on small models and extrapolate to the final run. Dubois says small architectural changes mostly shift the intercept, whereas data quality changes scaling more.

Evaluation is harder than it looks

Different implementations of MMLU gave very different scores for the same model (Llama 65B at 63.7 versus 48.8), and train-test contamination is a real problem for academics. Perplexity depends on the tokenizer and stops being meaningful after PPO-style alignment.

SFT mostly teaches format, not new knowledge

Dubois cites LIMA showing that going from 2,000 to 32,000 SFT examples helps little, because the knowledge already lives in the pretrained model. He also notes that SFT can encourage hallucination when humans write answers the model never actually learned.

WORDS WORTH SAVING

5 quotes

In reality, honestly, what matters in practice is mostly the three other topics, so data, evaluation, and systems, which is what most of industry actually focuses on.

— Yann Dubois

This is actually pretty different than what you see in this class. In this class, we teach you about overfitting. Overfitting doesn't happen with large language models. Larger models, better performance.

— Yann Dubois

All the architecture differences that we can make, like the small minor ones, all they do is maybe change a little bit the intercept. But really that doesn't matter, 'cause just train it for ten hours longer or, like, wait for the next GPUs.

— Yann Dubois

So don't spend time overcomplicating. Do the simple things, do it well, scale them.

— Yann Dubois

If you've ever been annoyed at ChatGPT answering you super long sentences, this is because of RLHF.

— Yann Dubois

Autoregressive language modeling and tokenizationPerplexity and benchmark evaluation (MMLU, HELM)Pretraining data collection and filteringScaling laws and ChinchillaSupervised fine-tuning and synthetic dataRLHF, PPO and DPOGPU systems optimization

High quality AI-generated summary created from speaker-labeled transcript.

Get more out of YouTube videos.

Read along on your phone, search it beside the video, or ask your favorite AI app what was said.