Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed
Language Modeling from Scratch · Lecture 13 of 17 · 1:19:06
Lecture 13: Data
Study guide
What this lecture covers
Earlier lectures assumed a fixed training set and focused on architecture, optimization, tokenization, scaling laws, and parallelism. This lecture turns to the question those lectures avoided: what data actually goes into a language model, and why model developers say so little about it. The instructor argues that data, more than architecture, is what differentiates one model from another, and traces the history of pre-training corpora from BERT through recent open releases like DCLM and Nemotron-CC.
After watching, you should be able to describe the pipeline that turns a raw web crawl into training tokens, name the major open pre-training datasets and how each one filters Common Crawl, and explain the legal basis (and limits) of training on copyrighted web content. The lecture also outlines how mid-training and post-training data differ from pre-training data, setting up later lectures on alignment.
Key ideas
- Training stages: pre-training uses large amounts of raw web data, mid-training curates smaller high-quality sets for specific capabilities (math, code, long context), and post-training fine-tunes on instruction and chat data.
- Common Crawl: a monthly, publicly available web crawl since 2007 that most open pre-training datasets start from; it is large but noisy, biased toward text, and not comprehensive.
- Model-based vs. rule-based filtering: some pipelines (CCNet, DCLM, Nemotron-CC) train classifiers to find pages that resemble Wikipedia or instruction data, while others (C4, Gopher, RefinedWeb) rely on hand-written heuristics to avoid biasing the data.
- Wikipedia as a quality surrogate: because Wikipedia is well-curated, many filtering pipelines use it (or pages it links to) as a stand-in for what "high quality" text looks like, even though this misses whole categories of useful content.
- Copyright and fair use: almost everything on the web is copyrighted by default; training on it without a license depends on a fair-use argument, and the situation is legally unsettled.
- Shadow libraries: datasets like Books3 and LibGen supply large amounts of book text but were built by disregarding copyright, and their use has led to lawsuits.
- Instruction data: post-training datasets (Alpaca, Vicuna, OpenHermes, Tulu) are increasingly built by prompting existing language models rather than collecting data from scratch.
Walkthrough
Why data is the differentiator (0:05)
The lecture opens by noting that model papers like Llama 3's disclose architecture and training details in depth but say very little about the data itself, largely for competitive and legal reasons. The instructor argues data deserves the most attention because it is highly parallelizable across a team (different people can work on code, multilinguality, math, and so on) in a way architecture work is not. The lecture then defines the three stages of training: pre-training on raw web data, mid-training on curated high-quality subsets aimed at specific capabilities, and post-training on instruction and chat data, noting that in practice these stages blur together.
From BERT to Common Crawl (6:14)
Starting from BERT (2018), which trained on books and Wikipedia, the lecture walks through early corpora: the Smashwords-derived BooksCorpus, and Wikipedia itself, including a digression on data poisoning, where an attacker can time malicious edits to land in a periodic Wikipedia dump. GPT-2's WebText dataset is introduced as an early attempt to filter the web cheaply, by keeping only pages linked from Reddit posts with enough upvotes. This leads into Common Crawl: how it crawls the web using seed URLs and a crawl frontier, respects (or is ignored by) robots.txt, and produces both raw HTML (WARC) and extracted text (WET) formats, where the choice of HTML-to-text tool can measurably affect downstream quality.
Filtering Common Crawl: CCNet, C4, and the Pile (21:33)
The lecture compares two early filtering approaches: CCNet, which trains an n-gram model on Wikipedia to score how "Wikipedia-like" a document is, and C4, which uses purely rule-based heuristics (removing short pages, bad words, and code-like text). It then covers GPT-3's dataset, which combines Common Crawl with WebText2, books, and Wikipedia and uses a quality classifier trained to distinguish curated sources from the rest. The Pile, assembled by EleutherAI, is presented as a more deliberately diverse, community-curated mix of 22 domains including PubMed Central, arXiv, Enron emails, Project Gutenberg, Books3, Stack Exchange, and GitHub, each with its own processing quirks.
Newer pre-training datasets (42:51)
The lecture surveys Gopher's MassiveText (rule-based filtering), Llama's Common Crawl mix filtered with a classifier trained on pages linked from Wikipedia, and RedPajama as an open reproduction. RefinedWeb and FineWeb are introduced as datasets that argue heavy filtering of web text alone, without mixing in curated sources, can be enough. Dolma, from AI2, and DataComp's DCLM baseline (which aggressively filters Common Crawl using a classifier trained on instruction-like data) are covered, along with Nvidia's Nemotron-CC, which pushes token yield higher by ensembling multiple quality classifiers and using a language model to rewrite low-quality pages and generate synthetic instruction-style pairs from high-quality ones.
Copyright and fair use (1:00:10)
This section explains that copyright applies automatically to original creative works without requiring registration, and that most of the web is technically copyrighted. Training on such data legally requires either a license (contracts, or Creative Commons licenses like those covering much of Wikipedia) or an appeal to fair use, which depends on factors like the purpose of use, the nature of the original work, and effect on the market for that work. The lecture notes that copyright covers more than verbatim copying, plot and characters can also be protected, and that even licensed or fair-use content may still be off-limits under a platform's terms of service.
Mid-training and post-training data (1:09:27)
The final section covers long-context extension, typically added at mid-training using books and math data with long-range dependencies, and the evolution of instruction-tuning datasets: early NLP-task collections like Super-Natural Instructions and FLAN, synthetic approaches like Alpaca's self-instruct and Vicuna's ShareGPT conversations, and more recent aggregations like OpenHermes and the Llama-Nemotron post-training data. The lecture closes by noting that generating instruction data by distilling open-weight models is more permissive than distilling GPT-4, and that hiring human annotators remains the most controlled but expensive option.
Before you watch
- Review earlier lectures on tokenization and scaling laws, since this lecture assumes you already know how a model consumes tokens and why data quantity interacts with model size.
- Some familiarity with how web crawlers work (URLs, HTML, robots.txt) will make the Common Crawl discussion easier to follow.
Check your understanding
- Why does the instructor argue that data is more important than architecture for differentiating language models?
- How do CCNet and C4 differ in their approach to filtering Common Crawl?
- What is the difference between how DCLM baseline and RefinedWeb decide whether to use model-based filtering?
- Under what conditions might using copyrighted web text for training be considered fair use?
- Why do many recent instruction-tuning datasets rely on generating data from existing language models rather than manual collection?
Vocabulary
- differentiator (noun)
- A factor that makes one thing clearly different from another.
Data, not architecture, is the biggest differentiator between models. - curate (verb)
- To carefully select and organize a collection of items.
Mid-training curates smaller, higher-quality data subsets. - crawl (verb)
- To automatically browse and collect pages across the internet.
Common Crawl crawls the web every month. - noisy (adjective)
- Containing a lot of irrelevant or low-quality information.
Raw web data is large but very noisy. - heuristic (noun)
- A practical, hand-crafted rule used to make quick decisions.
Some filters use simple heuristics instead of trained classifiers. - classifier (noun)
- A model trained to sort items into categories.
A classifier can score whether a page looks like Wikipedia. - surrogate (noun)
- A stand-in used to represent something else that is harder to measure directly.
Wikipedia is used as a surrogate for high-quality text. - fair use (noun)
- A legal doctrine allowing limited use of copyrighted material without permission under certain conditions.
Training on web text often relies on a fair-use argument. - copyright (noun)
- Legal ownership rights over an original creative work.
Almost everything on the web is copyrighted by default. - distill (verb)
- To generate training data by using an existing model's outputs.
Some instruction data is created by distilling open-weight models. - annotator (noun)
- A person who labels or writes examples for training data.
Human annotators are the most controlled but expensive data source. - corpus (noun)
- A large collection of text used for training or study.
Common Crawl is a huge public web corpus. - boilerplate (noun)
- Standard, repeated text used across many pages, like legal notices.
Rule-based filters remove obvious boilerplate text. - quality classifier (noun)
- A model trained to score how good or useful a piece of text is.
GPT-3's dataset used a quality classifier to filter Common Crawl. - aggregation (noun)
- Combining many smaller pieces into one larger collection.
Instruction datasets are often an aggregation of many sources. - seed URL (noun)
- A starting web address a crawler begins from before following links.
Common Crawl starts from a list of seed URLs. - license (noun)
- Legal permission to use a specific piece of content.
Some text can only be used for training under a license. - differentiate (verb)
- To make one thing clearly different from another.
Data quality differentiates one language model from another. - digression (noun)
- A temporary move away from the main topic to discuss something else.
The lecture takes a digression into data poisoning on Wikipedia. - reproduction (noun)
- A recreated version of an existing dataset or system.
RedPajama is an open reproduction of an earlier dataset.
From the YouTube description
For more information about Stanford's online Artificial Intelligence programs visit: https://stanford.io/ai
To learn more about enrolling in this course visit: https://online.stanford.edu/courses/cs336-language-modeling-scratch
To follow along with the course schedule and syllabus visit: https://stanford-cs336.github.io/spring2025/
Percy Liang
Associate Professor of Computer Science
Director of Center for Research on Foundation Models (CRFM)
Tatsunori Hashimoto
Assistant Professor of Computer Science
View the entire course playlist: https://www.youtube.com/playlist?list=PLoROMvodv4rOY23Y0BoGoBGgQ1zmU_MT_
← Lecture 12: Evaluation · Lecture 14: Data Filtering and Deduplication →
