Choosing Training Data
local graph
Module 14 — Choosing Training Data
Section titled “Module 14 — Choosing Training Data”Training data composition determines what a language model can actually do after learning stops. Each category of text that enters a pretraining corpus carries distinctive properties that shape specific model behaviors, from the length of coherent argument the model can sustain to the precision with which it follows procedural instructions. Understanding what each category teaches is the foundation of intentional capability design, because a team that selects sources based on convenience alone relinquishes meaningful control over the resulting model. This module examines four major data categories that dominate modern pretraining corpora and explains what each contributes to model behavior in technical terms. The discussion centers on the pedagogical function of each category, clarifying why a model trained on only one type produces a different kind of intelligence than a model trained on a balanced mix. You should come away with the vocabulary needed to reason about data composition as a deliberate design decision.
Books and Long-Form Text
Section titled “Books and Long-Form Text”Books occupy a special position in the pretraining landscape because they are among the few large-scale sources of continuous, edited writing that unfolds across thousands of tokens within a single coherent argument. When a model reads section after section of a novel or monograph, it learns to predict tokens under conditions where meaning extends far beyond the local sentence. This long-range dependency training produces internal representations that can track entities and logical commitments across extended spans of text, which is the capability that short-form sources fail to develop. Web comments and social posts rarely exceed a few hundred tokens of related content, so models trained predominantly on such material struggle to maintain the narrative and argumentative threads that longer contexts demand. Book training addresses this deficiency directly by providing unbroken sequences in which early content shapes later expectations.
The editorial quality of book content also matters in ways that extend beyond surface grammaticality. Professional editing enforces consistency of voice and discipline in argument structure, both of which carry statistical signal that a model can internalize. That the density of well-formed prose in books provides learning signal that web crawls cannot easily replicate. Long-form writing also exposes the model to genres that teach specific cognitive habits, including narrative fiction that builds characters across hundreds of pages and academic monographs that defend a thesis through structured section. The accumulated exposure to such writing shapes what the model treats as a well-formed extended response, and this effect carries into contexts far removed from the original genres.
A further contribution of book data concerns the modeling of implicit reader expectations, such as the anticipation that a referent introduced in an earlier section will reappear later with additional context. When a model is trained to predict text that assumes such continuity, it develops representational capacity for the long-context coherence that users expect from conversational assistants. Books also contain explicit discourse markers and logical connectors that signal the relationship between ideas across paragraph boundaries, and learning to associate these surface cues with underlying argumentative moves such as concession or qualification supports the discursive competence that allows a model to produce paragraphs whose parts hang together as genuine arguments. Teams building models for applications such as document summarization or technical writing should weight their corpora accordingly, because these capabilities are difficult to recover through later fine-tuning alone.
Web Data
Section titled “Web Data”Web-crawled text is the foundation of modern pretraining at scale because no other source offers comparable volume. Projects such as Common Crawl provide hundreds of billions of tokens spanning the topics that humans write about publicly, and this breadth is what makes broadly capable models possible in the first place. Raffel et al. (2020) introduced the Colossal Clean Crawled Corpus, known as C4, which demonstrated how filtered web data could serve as the primary pretraining substrate for a general-purpose model. The linguistic diversity of web text is particularly valuable because it exposes the model to variation in register and subject matter that curated sources cannot match. A model trained on sufficient web data will produce fluent output in contexts ranging from casual conversation to technical explanation, reflecting the sheer heterogeneity of the underlying source.
The same breadth that makes web data valuable also introduces serious quality concerns that must be actively managed. Raw crawls contain machine-generated spam and templated boilerplate among other low-value material, all of which can corrupt training if admitted without filtering. Dodge et al. (2021) also documented that certain filtering heuristics disproportionately removed text from marginalized communities, meaning that quality filtering choices encode value judgments that affect what the model learns about the world. Teams that accept web data uncritically therefore inherit a set of distributional properties whose downstream effects may not become visible until evaluation or deployment.
Safety considerations add another dimension to the handling of web data. Toxic content and personally identifiable information can both appear in raw crawls, and the absence of active management means that such material may be memorized and reproduced by the resulting model. Penedo et al. (2023) demonstrated with the RefinedWeb corpus that aggressive filtering and deduplication of web data can produce training material whose downstream quality matches or exceeds mixed corpora that include curated sources. This finding is useful for teams that want to build competitive models without relying on licensed or proprietary text, though it requires substantial engineering investment in the cleaning pipeline itself. A careful team will treat the web data pipeline as an ongoing concern, because the decisions embedded in filter thresholds and classifier choices materially affect what enters the model and therefore what the model eventually becomes.
╲‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾╱ ╲ Raw web crawl ╱ ╲ Hundreds of billions of tokens╱ ╲ - - - - - - - - - - - - - - - - - ╱ ╲ Language and quality filter ╱ ╲ Remove spam and boilerplate ╱ ╲ - - - - - - - - - - - - - - ╱ ╲ Deduplication ╱ ╲Strip near-duplicate docs╱ ╲ - - - - - - - - - - - ╱ ╲Safety & toxicity ╱ ╲Remove toxic + PII ╱ ‾‾‾‾‾‾‾‾┬‾‾‾‾‾‾‾‾‾ ↓ ┌──────────────────────┐ │Usable training tokens│ │ A fraction of input │ └──────────────────────┘[!visual-conversion] Printed as a funnel; full labels: “Deduplication — Strip near-duplicate documents”; “Safety and toxicity filter — Remove toxic content and PII”; “Usable training tokens — A fraction of the input”.
Figure 3-3. Web Data Filtering Pipeline from Raw Crawl to Usable Training Tokens
Code data occupies an interesting position in pretraining because its effects on the model extend well beyond the obvious capability of writing programs. Programming languages are extremely structured and unforgiving of ambiguity, so models that learn to predict code tokens are effectively trained on sequences where every symbol matters and every nesting level must resolve correctly. The Codex project showed that training on code produced models capable of solving nontrivial programming problems (Chen et al., 2021), and subsequent research has accumulated evidence that code exposure also improves performance on reasoning tasks that have nothing to do with programming. The signal density of code is therefore unusually high for a given token count, since each token carries strict compositional obligations that the model must learn to respect.
The mechanism behind this transfer is informative. Code imposes a discipline of compositional structure in which every function and control flow element has a precise role, and learning to predict such tokens develops internal representations for hierarchical relationships and stepwise logical operations. The fact that code typically includes comments alongside implementation also gives models paired examples of natural language intent and formal realization, which may contribute to instruction-following behavior because the model repeatedly sees how a human-language specification maps onto an executable procedure. This coupling is difficult to obtain from prose alone.
Another property of code data that teams sometimes overlook is its diversity in the programming-language sense. A pretraining mix that includes implementations in several programming languages exposes the model to the same abstract operations expressed in different syntactic forms, which encourages representations that generalize beyond any single language convention. The balance between languages in the code portion of the corpus also matters for capability targeting, because a model that sees mostly Python will behave differently when asked about Rust than one trained on a more uniform distribution. Teams building general-purpose models should therefore consider code inclusion as a capability investment, because the improvement in logical precision carries over to domains such as planning and procedural explanation. Current practice in leading pre-training efforts tends toward meaningful code fractions even for general assistants (Chowdhery et al., 2022).
Domain Corpora
Section titled “Domain Corpora”Domain corpora are specialized text collections that represent the knowledge and linguistic conventions of a particular field, and their inclusion is the primary mechanism through which teams target specific expertise in the resulting model. Scientific literature exposes the model to the dense technical vocabulary and citation-heavy argument structure of research writing, while legal text provides exposure to statutory language and precedent-based reasoning that follows different rhetorical conventions. Beltagy et al. (2019) demonstrated with SciBERT that pretraining on biomedical and computer science papers produced a model whose performance on domain tasks significantly exceeded that of a general model. This indicates that domain data carries genuine capability that cannot be recovered by adding more general text. Technical documentation, when included at sufficient volume, similarly imparts the procedural and reference-oriented patterns that characterize operational knowledge in applied fields.
Domain vocabulary itself deserves specific attention in corpus design. Specialized fields often employ terms whose meaning differs from general usage or that do not appear in general text at all, and models that have never encountered such terms produce plausible-sounding outputs that are wrong in subtle ways. Continued pretraining on unlabeled domain text improves downstream task performance across several technical fields (Module 10). The practical implication is that a team targeting a specific domain should audit the vocabulary coverage of its base model against domain terminology before deciding how much specialized data the pretraining run requires, because the answer depends heavily on what the base model already knows.
The question of how to compose a balanced corpus that includes domain content is one of the more consequential design decisions a team faces. When the domain fraction is set too small, the model will acquire fluency in the domain vocabulary without developing the deeper representations needed for expert-level reasoning in the field. When the domain fraction grows too large, the model may suffer from reduced general capability and become narrowly useful only within the target domain, limiting its value for adjacent applications. Finding the right composition typically requires iteration based on evaluation results, because the optimal mix depends on factors including the base rate of domain content already present in general corpora and the depth of capability the team aims to achieve in the final model.