Large Language Model Training Datasets: A Practical Guide to Building General-Purpose Corpora
This article breaks down the datasets used at each stage of large language model training—pretraining, supervised fine-tuning, and preference alignment—and explains how to build a general-purpose corpus from raw crawls. It covers corpus sources and their licensing risks, a processing pipeline that includes extraction, layered quality filtering, deduplication, and privacy handling, plus data mixture experiments, observability metrics, and common pitfalls such as over-filtering and benchmark contamination.
1. Why Datasets Set the Upper Bound on Model Capability
Model architecture, parallelism strategy, and compute scale determine how fast training runs. Data determines what the model ultimately learns. A widely held industry observation is that, under a fixed compute budget, corpus quality and mixture ratios often explain downstream performance differences better than parameter count does. Asking “which datasets are used to train large language models” is therefore really asking three separate questions: what distribution each training stage needs, how to measure whether that distribution is healthy, and how to keep data traceable before and after training.
One baseline judgment is worth establishing first: there is no universal “standard dataset list” to copy. Data selection depends heavily on the target scenario (general chat, code, multilingual coverage, domain knowledge), context length requirements, and compliance boundaries. The methodology is reusable; the specific list is not.
2. Data Responsibilities Across the Three Training Stages
2.1 Pretraining Corpora: World Knowledge and Language Ability
Pretraining typically consumes the majority of the training budget. Its goal is to give the model language modeling ability, factual knowledge, and basic reasoning habits. A typical composition includes:
- Web text: the broadest coverage and the highest noise; the main source of scale.
- Books and long-form text: long-range dependencies and narrative structure, with a clear contribution to long-context ability.
- Encyclopedic and knowledge-oriented text: high factual density, useful as an “anchor” for factuality.
- Code and structured text: even for a general-purpose model, a certain proportion of code usually improves logical reasoning and format following.
- Multilingual corpora: determine language coverage and cross-lingual transfer.
- Academic and patent text: standardized terminology and complete argumentation, suitable for improving professional expression.
2.2 Supervised Fine-Tuning Data: Instruction Following and Output Shape
Supervised fine-tuning (SFT) data is usually several orders of magnitude smaller than pretraining data, but the influence of each individual sample is amplified significantly. A high-quality instruction sample should contain a clear instruction, a verifiable reference answer, and as little ambiguity as possible. The common approach is “a small amount of careful human labeling + large-scale synthesis + strict filtering.” Synthetic data must pass rule-based validation and cross-review by models; otherwise it hard-codes annotator bias into the model.
2.3 Preference Alignment Data: Value Orientation and Refusal Boundaries
Preference data uses “multiple candidate responses to the same instruction plus a quality ranking” as its basic unit, and is used to train a reward model or for direct preference optimization. What matters is not volume but annotation consistency: if different annotators give contradictory preferences for the same pair, the training signal cancels itself out.
3. Sources of General-Purpose Corpora and Licensing Risk
A general-purpose corpus is a base text collection not restricted to a single business domain and usable across a wide range of tasks. Its sources fall into four categories, each with a completely different risk structure:
| Source type | Advantages | Main risks |
|---|---|---|
| Public web pages | Large scale, strong diversity | Copyright and robots conventions, noise, injected content |
| Public datasets and competition corpora | Clear structure, relatively explicit licenses | License terms restricting commercial use, high duplication |
| First-party business data | Close scenario fit, controllable annotation | Personal and sensitive data, scope of authorization |
| Synthetic data | Controllable, targeted gap filling | Model self-confirmation bias, diversity collapse |
Three things must be enforced for compliance: sources must be enumerable, licenses must be verifiable, and deletion must be executable. On the engineering side, keep a four-element tuple for every piece of corpus data—“source fingerprint + license type + ingestion timestamp + processing pipeline version”—to form an auditable chain.
4. The Corpus Processing Pipeline: From Raw Crawl to Trainable Sample
4.1 Extraction and Normalization
Start with main-content extraction and encoding unification, removing template text such as navigation, ads, and copyright notices. Then normalize whitespace, punctuation, and full-width/half-width characters so that the same semantics is not split into multiple token sequences due to formatting differences.
4.2 Quality Filtering
Quality filtering usually has three layers; each layer raises both cost and precision:
Rule layer: length thresholds, symbol ratio, repeated-line ratio, language ID confidenceStatistical layer: perplexity filtering, n-gram repetition rate, similarity to a high-quality seed setModel layer: classifier scoring, small-model discrimination, human spot-check calibration
The key practice is “stratified sampling with human evaluation”: after each filtering layer, randomly sample a number of records and have humans judge the retention rate and false-kill rate, avoiding overly strict rules that wipe out long-tail domains entirely.
4.3 Deduplication
Deduplication is the most underestimated step. Duplicate data causes memorization (the model recites the original text verbatim) and evaluation contamination. Engineering practice generally applies two levels:
- Exact deduplication: hash the normalized text; extremely low cost.
- Near deduplication: use MinHash/SimHash or paragraph-level embedding clustering, and merge near-duplicate documents with a similarity threshold.
In addition, “decontamination between the training set and the evaluation set” is mandatory: retrieve n-gram fragments of evaluation samples in the training corpus and remove them, otherwise leaderboard scores are not trustworthy.
4.4 Privacy and Sensitive Information Handling
Use a three-step “identify—redact—re-evaluate” process: first use rules and models to identify patterns such as ID numbers, contact details, addresses, and keys; then substitute or generalize them; finally sample and re-evaluate the miss rate. Note that redaction changes the language distribution, so its impact on downstream tasks must be assessed.
5. Data Mixture: Turning Corpora into a Recipe
Mixture design is the part of data engineering that most resembles experimental science. An executable process:
- Build a small proxy model (for example, on the order of one percent of the total parameter count) and fix the remaining hyperparameters.
- Design candidate mixtures, running orthogonal experiments across four dimensions: general web text, code, knowledge-oriented text, and multilingual data.
- Use a set of validation metrics covering knowledge, reasoning, code, long context, and multilingual ability as the scoring function.
- Select the Pareto-optimal mixture, then run a single-point validation in large-scale training.
Two points deserve emphasis. First, the optimal mixture drifts with model scale and context length, so conclusions from small models cannot be extrapolated directly. Second, data annealing (raising the proportion of high-quality data and instruction samples in the later stage of training) is usually more cost-effective than a uniform mixture throughout.
6. Evaluation and Observability
Data-side observability should cover three categories of metrics:
- Distribution metrics: language share, domain share, length distribution, and how repetition rate changes over time.
- Quality metrics: retention rate of each filtering layer, human spot-check pass rate, redaction miss rate.
- Impact metrics: per-domain loss on a fixed validation set, downstream task gains, memorization probe hit rate.
It is advisable to bind corpus versions to model versions in records, so that “given a model, its training corpus snapshot can be traced back.” This is the prerequisite for later problem localization and compliance audits.
7. Implementation Advice and Common Pitfalls
- Pitfall 1: chasing a single “strongest dataset.” Real gains come from a continuously iterated pipeline, not a one-time list.
- Pitfall 2: filtering harder is better. Over-filtering sacrifices diversity and causes long-tail and specialized-domain capability to collapse.
- Pitfall 3: ignoring evaluation contamination. If leaderboard gains come from contamination, production performance drops immediately.
- Pitfall 4: treating synthetic data as a free lunch. Synthetic data must be paired with diversity constraints and anchored by external real data.
At the implementation level, separate corpus storage from compute: the raw layer keeps immutable snapshots, the processing layer uses replayable pipelines to generate intermediate artifacts, and the training layer reads only versioned sample manifests. If cloud resources are used, object storage holds raw and intermediate corpora, a container platform runs parallel cleaning and deduplication jobs, a message queue decouples the pipeline, and logging and monitoring services track retention and failure rates—together forming a reproducible, auditable data foundation.
