Data Audits and Release Governance › Sampling: Auditing a Corpus You Cannot Read
Language AI HandbookAll chapters A full manual review is impractical at pre-training scale. At an assumed 300 tokens per minute, reading 50 billion tokens continuously would take about 317 years. A probability sample gives the audit a way to estimate a property of a defined population and quantify sampling uncertainty.
The temptation is to treat the audit as an editorial review process in miniature: read a few thousand documents, form an impression, and report the impression. That is not an audit. It is a spot check, and spot checks are systematically unreliable for two reasons. First, humans are bad at estimating prevalence from small samples without explicit counting: a reviewer who reads forty documents and finds no harmful content will report the corpus as clean, whereas the true prevalence could easily be 5%. Second, spot checks are not reproducible. If a colleague runs the same review on a different slice, they get a different impression and there is no principled way to reconcile the two. Sampling statistics exist because humans systematically misjudge the frequency of rare events, and because principled reconciliation requires a stated estimator.
The sampling frame
The population you audit is not "the web" or "the world's text." It is a specific, enumerable set: the documents in dataset version ds-2025.06. The mapping from that set to the thing you actually care about (all human expression, or all text the model will encounter) is the coverage problem, and it cannot be fixed by sampling more. Crawl reachability, robots.txt exclusions, and language filters have already shaped the population before you drew a single sample. (See Web Crawling.)
Record the frame. If your crawl excludes domains that disallow crawling, the estimate applies to the documents included in the audited dataset version. Extending it to the wider web requires a separate representativeness argument.
This is the subtlest pitfall in the whole chapter because the frame is invisible in the data. The documents you have do not carry a record of the documents you do not have, and the absences shape the audit's conclusions silently. An English-only frame gives no coverage of the excluded languages. A crawl without login-walled content gives no direct evidence about credentials in material behind logins. Every audit is a statement about the frame, and any application to a population outside the frame is an assumption of representativeness that should be tested rather than presumed.
Sample size for a proportion
To plan a simple random sample for a prevalence estimate, choose an anticipated rate , a two-sided absolute margin , and a nominal confidence level . The normal approximation starts with
where is the standard-normal quantile. The examples use 1.96 for 95%. For simple random sampling without replacement from a finite population of size , use the following adjustment:
Two things follow immediately. First, is largest at , so the conservative choice is when you know nothing. Second, and more importantly for data governance, estimating a rare proportion to tight relative precision can require a large sample. At 95% confidence, and an absolute margin of yield a normal-approximation planning size of about 15,351 documents before finite-population correction (15,351.03, conventionally rounded up to 15,352).
The shape of the formula has a consequence that surprises teams the first time they encounter it. The sample size needed to estimate a common proportion is small: at and an absolute margin of 0.03, the normal approximation with gives 1,068 reviews before finite-population adjustment. For small , at fixed relative precision the planning size grows approximately as , while at fixed absolute margin it falls roughly in proportion to ; the operative variable when estimating rare harms is the ratio of to . Estimating a rarity of 1 in 100 to within ±0.1 percentage points requires about 38,000 reviews, not a few thousand. Estimating a rarity of 1 in 1,000 to within ±0.05 percentage points is possible at a comparable number. For the same rarity and a margin of ±0.005 percentage points, the uncorrected planning size is about 1.54 million reviews. Apply the finite-population adjustment if that count is large relative to the audited frame. The margin must be chosen with the rarity in mind; otherwise the sample size blows up for a precision no one will use.
When the prevalence is low, a feasible random sample may have no positive cases. A small sample with zero observed cases still leaves substantial uncertainty about prevalence.
The rule of three
When you observe zero events in independent trials, the 95% upper bound on the true rate is approximately (Hanley and Lippman-Hand, 1983). Audit 300 documents and find no CSAM, and the 95% upper bound on prevalence is about 1%. Whether that bound is tight enough depends on the release criterion. Give the bound alongside the count, so the reader can assess what the sample rules out.
A zero-count sample is entirely compatible with nonzero prevalence. At prevalence , the probability of observing zero in independent draws is , which approaches . The approximation is conservative for this one-sided 95% binomial bound. With fifty independent reviews and no positives, it gives an upper bound of about 6%.
The figure below makes the bound concrete across a range of zero-finding audit sizes.
PythonIn [2]Expand
import numpy as np
rule_n = np.unique(np.geomspace(1, 2000, 200).astype(int))
rule_upper = 1 - np.power(0.05, 1 / rule_n)
rule_marks = np.array([50, 300])
rule_mark_bounds = 1 - np.power(0.05, 1 / rule_marks)VisualizationOut [3]Expand

Stratified and detector-assisted sampling
If a detector concentrates positive cases in identifiable groups, consider allocating more reviews to those groups. Check the allocation against the goal, whether finding at least one positive, estimating prevalence to a target precision, or supporting a one-sided release bound.
The standard design is a two-phase audit:
- Run a cheap automatic detector over the entire corpus and partition documents into strata (for example, flagged versus unflagged, or flagged-high, flagged-low, unflagged).
- Draw human review samples within strata, at rates you choose.
The population prevalence is then estimated with the stratified estimator
where is the observed rate within stratum and is that stratum's share of the population. For independent simple random samples without replacement within each stratum, an unbiased estimator of the sampling variance is
The finite population correction matters here: if a stratum is small enough to review in full, its sampling variance contribution is zero. Use that zero directly for a census, including a one-document stratum. For a noncensus stratum, the displayed variance estimate requires .
The displayed estimator assumes a simple random sample within each stratum that contributes to the population. Record the stratum sizes and which design selected the reviewed items. A detector can miss an entire target category, while another rule still flags some documents containing it. Whether stratification reduces variance for that category depends on the allocation and the prevalence within each stratum.
The intuition behind the estimator is a reweighting argument. Human review measures rates within strata, and each stratum is then weighted by its share of the full population. If you review 100% of a flagged stratum containing 500 documents and find 250 positives, the flagged stratum contributes 250 * 1 = 250 estimated positives. If you review 10% of an unflagged stratum containing 49,500 documents and find 1 positive, that implies roughly 10 positives in the unflagged stratum, which contributes 10 to the total. The sampling rates can differ across strata. To compute the estimate, keep each review's stratum, the number reviewed there, and the stratum's population size. Pooling the sample directly weights strata by their review counts and can bias the estimate when sampling rates and outcome rates differ.
We will quantify both effects in the worked example.
Estimators for rare-event counts
When the question is "how many documents of type X are in this corpus?" rather than "what fraction?", you multiply: , with a confidence interval obtained from the interval on . For a small positive count under independent Bernoulli sampling, consider a Wilson score interval or an exact binomial interval. For finite sampling without replacement, invert the hypergeometric count distribution when the sampling fraction matters. A weighted stratified estimate requires an interval that accounts for its strata.
The choice between absolute count and prevalence matters for how the number is consumed. A safety review can use the estimated number of sensitive documents, while a release criterion may use residual prevalence. The estimated count is the prevalence estimate multiplied by the frame size. The number of documents a filter removes depends on its decision rule, including the documents it flags in error. A rare-event estimate can have a wide interval when the sample contains few positives. In a frame of 50,000 documents, a prevalence interval of 0.4% to 1.2% corresponds to 200 to 600 documents. Scaling the endpoints changes the units and preserves coverage for the corresponding fixed-population count.
For successes in trials, use the observed success fraction and the critical value :
The interval is . Unlike the Wald interval, it never extends below zero and behaves sensibly when is small, which is exactly the regime audits live in.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!