Prompts Forms Resume Reports ★ Saved ★ Saved★ + Submit a tool
Techniques

Corpus Quality Filtering

About 3656 characters Updated Nov 30, 2026 29 views AI wiki

Corpus quality filtering is the process of removing low-quality text with rules, models and statistical methods before pretraining or building a retrieval corpus. It determines what books the model "grows up reading"; under the same token budget, filtering often improves results more than simply adding data, so it is regarded as one of the highest-return steps in data engineering.

Core Principles

Raw web-crawl data is mixed with large amounts of navigation bars, ads, template text, machine-generated junk, stitched-together SEO pages and duplicated reposts. Quality filtering generally proceeds in layers. The first layer is heuristic rules: the classic rules proposed in the Gopher paper include word-count ranges, average word length, the ratio of symbols to letters, the share of stop words, the proportion of lines starting with bullet points, whether the text contains the placeholder phrase "lorem ipsum", dirty-word blocklists and so on, each of which can independently remove one type of obvious junk. The C4 dataset uses another, plainer set of heuristics: keep only lines ending with punctuation, drop pages containing banned words, drop code-like or overly short lines, and deduplicate at the paragraph level, finally washing about fifteen billion tokens of trainable corpus out of Common Crawl.

The second layer is classifier scoring: train a binary classifier, with positive examples taken from recognized high-quality text such as Wikipedia, books and academic abstracts and negative examples from random web pages, use the output probability as a quality score, then truncate by threshold or sample by tier. Lightweight FastText and small transformers are both common; the latter discriminates semantic coherence more strongly but infers more slowly. The third layer is deduplication, including exact hash deduplication, line-level and paragraph-level fuzzy deduplication (MinHash and SimHash for approximate duplicate detection), and the newer semantic deduplication; in large-scale cleaning the removed proportion can exceed thirty percent. The fourth layer is harmful content and privacy cleaning, removing personally identifiable information, pornography and violence, and hate speech; this step is usually bound to compliance review.

Key Points

Stricter thresholds are not better: over-aggressive filtering systematically deletes the language of minority groups, colloquial expression and low-resource corpora, causing a collapse in diversity and making the model perform worse in edge cases. Classifiers must guard against bias: taking all positives from Wikipedia makes the model's style rigid and fond of an encyclopedic tone, so high-quality dialogue and technical documentation can be added as positives, with separate classifiers trained per language and domain. Deduplication should precede quality scoring: duplicated text often harms the model more than low-quality text, and duplication amplifies the classifier's inherent bias. Metrics must be observable: at minimum record the removal rate of each rule, the remaining token volume per domain, the duplication rate after deduplication and human spot-check scores. Tier rather than cut off uniformly: a common practice is to grade scores into high, medium and low tiers, repeat the high-quality tier for several training rounds, and downsample or completely discard the low-quality tier. Code and math data need dedicated rules, such as whether the syntax tree parses and whether unit tests pass.

Common Misconceptions

Many assume that quality score correlates monotonically with downstream performance, when in fact the total volume drops sharply after filtering and the loss may outweigh the gain. Another misconception is that evaluating the classifier on a validation set drawn from the cleaned set makes it reliable; the real test should be placed on downstream tasks and human spot checks. Some only deduplicate without quality scoring, or conversely only score without deduplicating, whereas the two lines usually need to advance in parallel.

Application Scenarios

Pretraining corpus cleaning, purification before ingesting into a RAG knowledge base, instruction-tuning data selection, multilingual corpus construction, governance of web-crawl data, reproduction of open datasets.