ML Datasets: Deep Dive
Comprehensive guide to ML datasets: C4, Wikipedia, StackExchange, web crawled content, collection methods, and finding quality training data.
What is an ML dataset?
An ML dataset is a versioned collection of examples, labels, and metadata used to teach or evaluate a model. For a language model, an example may be a document or a conversation; for an image classifier, it may be an image and a class label.
In plain language, a dataset is the model's experience. It cannot reliably learn a case that was absent, mislabeled, overrepresented by duplicates, or excluded by an unsafe license. The model architecture matters, but the dataset decides what signal is available to learn.
The core invariant is separation: training data teaches the model, validation data guides choices during development, and a final test set estimates performance without influencing either of them.
Start with a dataset contract
A dataset contract is a short, testable description of what data may enter a model and what evidence must travel with it. Write it before collecting data so a large corpus cannot hide an unclear purpose.
Task and population
Name the prediction or generation task, the intended users, relevant languages, and the cases the model must not decide.
Rights and provenance
Record origin, license, consent or lawful basis, collection time, and permitted uses for every source.
Quality and coverage
Define the required labels, error tolerance, domains, time window, and slices that must be represented.
Evaluation boundary
Define how train, validation, and test examples stay independent, including duplicate and temporal controls.
Before choosing a source, answer these questions:
- What decision will the model support, and what is the harm when it is wrong?
- Which people, regions, languages, devices, or rare cases need explicit coverage?
- Which rights, privacy, retention, and redistribution constraints apply?
- What unit must remain together when data is split: a user, document family, patient, merchant, or time period?
Turn raw sources into a reproducible corpus
Collection is not just downloading files. A production dataset pipeline preserves evidence about where examples came from and makes each transformation repeatable.
1 Permission
Acquire
Capture source, license, consent or policy basis, retrieval time, and immutable raw-file reference.
2 Structure
Normalize
Extract useful fields, standardize encoding and language, and retain a stable example ID with provenance.
3 Quality
Filter
Remove unwanted formats, personal data, unsafe material, spam, boilerplate, and duplicates with recorded rules.
4 Evidence
Freeze manifests
Create split manifests, compute statistics, version code and thresholds, then make the snapshot reproducible.
Choose sources for the signal they add
- Web crawls provide broad language and long-tail coverage, but need aggressive quality, rights, and duplication controls. Common Crawl archives raw web material in WARC files, extracted text in WET files, and metadata in WAT files.
- Curated reference material such as encyclopedias, documentation, books, and academic papers can provide denser signal and clearer structure. It still needs license and freshness review.
- Community and code data can teach dialogue, troubleshooting, and programming patterns. Quality signals such as accepted answers or repository activity are useful filters, not proof that use is permitted.
- Synthetic or simulated data can fill rare scenarios or expensive labels. Keep it distinguishable from real data and evaluate whether it improves performance on independently collected real examples.
Do not treat public availability as permission to train. Dataset documentation must record use restrictions, personal-data handling, opt-out obligations, and who approved the source.
Inspect well-known corpus patterns
Named datasets are useful examples of design choices, not ready-made defaults. Their snapshots, licensing terms, filters, and known limitations change over time; read the dataset card and release manifest for the exact version you intend to use.
C4 and filtered web corpora
C4 is a cleaned web corpus introduced with T5. It demonstrates a common pattern: start from a broad crawl, extract text, apply heuristic filters, and publish a reproducible snapshot. That pattern increases scale, but filtering choices can also remove dialects, low-resource languages, or useful unusual formats.
Common Crawl
Common Crawl is a large public web archive. It is source material rather than a model-ready corpus: downstream teams choose extraction, content policies, deduplication, language handling, and the final mixture.
Wikipedia and research sources
Wikipedia offers linked, multilingual, community-maintained articles. Academic and reference sources add terminology and long-form structure. Their value is traceability and concentrated signal, not an assumption of complete correctness or universal permission.
Stack Exchange and public repositories
Question-answer communities expose explanations, revisions, and quality signals. Public repositories add source code and documentation. Both require a repository- or item-level policy for licenses, credentials, personal data, and generated or copied material.
Compare sources by the unique signal they contribute, the rights you can establish, and the error modes they introduce. Raw token count is only one input to the decision.
Build a mixture that serves the task
Dataset mixing is the weighted combination of source streams during training. A source's raw size does not have to equal its training weight: smaller, trusted material is often sampled more often when it supplies a capability that a large noisy source lacks.
Use the lab to select a target workload, allocate a fixed 100% training budget, and see the capability gaps or overexposure the mixture creates. There is no universally correct ratio; the lesson is to make the intended capability and its trade-off explicit.
Spend a finite training budget deliberately
Choose the workload, then allocate a 100% sampling budget. The remaining share goes to community Q&A so every change has an observable trade-off.
100%
Similarity to the selected capability target
45%
Filtered web of training updates
Capability coverage is balanced
The mix is close to this workload’s target. Freeze the sampling manifest, then validate on protected task slices before scaling training.
Use source-specific controls
- Apply deduplication across sources, not only within each source. A copied document can appear in a crawl, a forum post, and a repository.
- Keep provenance fields through every join and transformation so a source can be audited or removed later.
- Measure coverage by task-relevant slice. A mixture that looks diverse at the domain level can still omit a language, time period, or rare intent.
- Make the sampling manifest immutable for a training run. Record source versions, weights, filtering rules, tokenizer version, and random seed.
Protect evaluation from contamination
Data contamination happens when an evaluation example, or a close enough relative, enters training data. The model may then appear capable because it memorized the answer or context rather than generalizing to unseen inputs.
A leakage-resistant evaluation boundary
Keep the decision unit intact before any model or hyperparameter sees the final test partition.
Source snapshot
Raw examples
Store stable IDs, timestamps, origin, and the entity or document family each example belongs to.
Boundary design
Group and deduplicate
Cluster exact and near duplicates, then keep each group in one partition.
Held out
Freeze test manifest
Limit access and never use results to make training or tuning choices.
Development
Train and validate
Fit models and choose changes using only the permitted training and validation partitions.
Try three split policies in the lab. Add duplicate or future-looking records to reveal why random row splitting is sometimes insufficient even when the train, validation, and test percentages look sensible.
Make leakage visible before a score is trusted
Choose a split rule, then inject realistic overlap. The model’s apparent test score becomes less reliable whenever related or future information crosses the boundary.
2/3
Controls currently holding
45/100
Higher pressure inflates offline results
55%
Confidence in the held-out estimate
Training
Related evidence can influence the reported estimate.
Validation
This partition is isolated from the conflicting record.
Final test
Related evidence can influence the reported estimate.
Investigation required
Close copies can make a held-out result look strong. Cluster or screen near duplicates before assigning partitions.
Check more than exact matches
Exact hashes catch byte-for-byte copies. Near-duplicate methods such as n-gram overlap, MinHash, SimHash, or embedding similarity catch paraphrases and template variants. For benchmarks, also check:
- Entity leakage: keep one user, patient, merchant, conversation, or document family in one split when their repeated appearances would reveal the answer.
- Temporal leakage: train only on information available before the prediction or benchmark cutoff.
- Benchmark leakage: search training candidates for benchmark prompts, answers, and close variants; remove matches and document the procedure.
- Process leakage: restrict access to final-test labels and results so repeated tuning cannot turn the test set into validation data.
Evaluate a candidate dataset before training
Dataset evaluation turns a vague claim such as "this looks clean" into evidence that a specific snapshot is suitable for a defined use. Start with a small, representative sample and make the decision reviewable before spending on a full training run.
100%
Provenance coverage
Every retained record maps to a source and policy decision
0 known
Test overlaps
Exact and near-duplicate findings are investigated before release
By slice
Coverage report
Measure quality across the populations and cases that matter
Versioned
Dataset manifest
Freeze files, transforms, and statistics together
Review the evidence in order
- Documentation: read the collection method, intended uses, known limitations, license, and version history. Dataset cards are a starting point, not a substitute for policy review.
- Schema and samples: inspect missingness, encoding, language, labels, personally identifying fields, and failure cases. Sample by source and important slice, not only at random.
- Statistics and coverage: calculate class balance, length distributions, temporal coverage, duplicate rate, and representation across the chosen population.
- Pilot evaluation: train a bounded baseline, evaluate on protected holdouts, and compare errors by slice. A score increase can still be unacceptable if it worsens a critical group.
- Release decision: version the approved manifest with its documentation, filters, quality report, and approval record. Preserve the raw snapshot according to retention policy.
Operate datasets as production assets
A dataset changes when its source, extraction logic, filters, label policy, split rule, or sampling weights change. Treat that as a release with traceable inputs and gates, not as a background file update.
- Version raw source references, transformation code, configuration, output manifest, feature or tokenizer assumptions, and quality report together.
- Monitor production inputs for schema changes, drift, unexpected languages, missing fields, and new privacy or policy risks.
- Keep a removal path. When a source is withdrawn or a defect is found, identify affected examples, training runs, evaluations, and deployed model versions.
- Re-run contamination and slice checks whenever a source or split procedure changes.
- Document residual bias and known gaps so downstream users do not mistake a dataset limitation for model behavior.
More data is not automatically safer data. A smaller, documented, appropriately licensed, leakage-resistant corpus can be more useful than a larger mixture whose origin and evaluation boundary are unknown.