advanced25 min studyLesson 602 in Engineering

Canonical text is a versioned representation choice

Separate raw capture, decoding, extraction, Unicode normalization, and content identity while preserving structure needed for code, mathematics, and reproducibility.

On this page

What you’ll understand

  • Trace a raw document through explicit deterministic transformations.
  • Explain why normalization can merge distinctions and alter duplicate identity.
  • Evaluate extraction on retained meaning rather than text length alone.

A web page can contain navigation, article text, code, tables, repeated footers, and hidden fragments. A training document is the result of choices about which parts to preserve and how to represent them. Calling the output clean text does not make those choices neutral. Keep raw identity and transformation history so a later extractor change can be understood, reproduced, and evaluated against the content the user or model is meant to learn.

Keep decoding, extraction, and normalization distinct

Start from a named raw artifact and its byte hash. Decode with an explicit encoding and error policy, then extract relevant content under a versioned rule. A crawl's raw response, metadata, and pre-extracted text are different artifacts; Common Crawl's overview documents their roles. An extractor may remove menus and boilerplate while preserving article paragraphs, but it can also lose tables, mathematical notation, or code indentation. The desired representation depends on the training task and content type, so one generic text-density threshold should not silently define quality for every source.

Unicode normalization changes how equivalent or compatible characters are represented. NFC addresses canonical equivalence, while NFKC also folds compatibility distinctions that may matter in identifiers, mathematics, or styled text. The Unicode standard defines the transformations; it does not determine which is appropriate for a particular corpus. Whitespace folding and lowercasing add further choices and can change code or case-sensitive names. Record each step and test representative fixtures instead of assuming that fewer distinct byte strings always means a better or more faithful dataset.

Tv(b)=Nv(Ev(Dv(b)))T_v(b)=N_v(E_v(D_v(b)))
b is a raw byte sequence, D decoding, E extraction, and N chosen normalization under pipeline version v. T_v is a representation transform, not necessarily reversible or semantics-preserving; all metadata needed to reproduce its choices must be retained.↔ Scroll wide equations horizontally.

A content digest is defined by its input representation

Hashing raw bytes identifies one captured representation, while hashing extracted normalized text defines another grouping criterion. Two raw pages with different navigation can share extracted text; two visually similar pages can differ after a meaningful symbol or table cell is preserved. Store separate raw and derived identifiers rather than overwriting the first with the second. A cryptographic digest supports integrity and practical content addressing under its collision assumptions, but the digest does not certify extraction quality, establish permission, or anonymize a document against membership tests.

Extraction yield should be measured with compatible units and a labeled target. Retained characters, decoded bytes, documents, and tokenizer tokens are different quantities. Removing duplicated boilerplate may lower volume while improving useful training content, whereas dropping every short mathematical answer can damage coverage. Use human-reviewed or otherwise trusted examples across formats and languages. Inspect both the retained and discarded portions, and keep reason codes so a regression can be attributed to a particular rule rather than hidden behind one final token-count change.

yretained=CretainedCcandidate(Ccandidate>0)y_{\rm retained}=\frac{C_{\rm retained}}{C_{\rm candidate}}\quad(C_{\rm candidate}>0)
Both counts must use the same declared unit, such as decoded characters in one extraction fixture. The dimensionless yield is not a semantic-quality score; tokenization, encoding, and different document units can change the ratio.↔ Scroll wide equations horizontally.

Test deterministic output and meaning together

Create fixtures for malformed markup, missing encodings, nested lists, tables, code, formulas, repeated sidebars, and multilingual text. Verify deterministic outputs under pinned dependencies and inspect whether the intended content survives. A parser can deterministically produce the wrong article, so reproducibility is necessary but not sufficient. If extraction rules change, derive a new content version and compare retention and downstream performance rather than mutating an already referenced corpus shard in place. Preserve lineage to the raw artifact even when raw access is restricted by the project's storage policy.

The probability lab illustrates defects in an audit sample rather than extracting text. Reset, explicitly set BOTH defect probability p=0.05 and sample count n=20, predict at least one defect with probability about 0.6415, then Play or Step. Reset and re-set BOTH p=0.1 and n=20; predict about 0.8784. Edits retain t; playback highlights exact independent counts. The model has no HTML, Unicode, tables, or tokenizer. A clean sample does not prove every extraction is faithful, and repeated templates can make audit errors correlated rather than independent.

A higher extraction yield is not automatically better

A fictional decoded page contains 60 navigation characters, 140 article characters, and 20 footer characters. Extractor A retains only the article. Extractor B retains everything. Count characters under one fixed convention.

  1. The candidate text totals 60+140+20=220 characters. Extractor A retains 140/220≈0.6364 of them.

  2. Extractor B has yield one, but its extra 80 characters are labeled nonarticle material in this fixture. Higher yield alone does not establish a better training document.

  3. If the article includes meaningful code indentation or a table, inspect whether A preserved it before declaring its result correct. Store raw identity, extractor version, and derived-text digest so this decision can be reproduced.

The result

Yield describes volume under a chosen representation. Fidelity to the intended article needs a separate content check.

Explore the model

Interactive lab

Interactive lab · probability

An extraction audit has sampling limits

For EACH run Reset, set BOTH p and n, predict, then Play or Step. At n=20 compare defect p=0.05, P(K≥1)≈0.6415, with p=0.1, ≈0.8784. Edits retain t. This exact iid model neither extracts documents nor measures Unicode, semantic fidelity, token counts, or correlated template failures.

An extraction audit has sampling limitsThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forAudit sampling can reveal representation defects, but a volume ratio or a clean small sample does not prove faithful extraction.

Check your understanding

Why should raw-byte and normalized-text hashes be stored as different identities?

Try it yourself

A normalizer maps both the circled digit ① and ordinary digit 1 to the same output under a chosen compatibility normalization. Does this establish that every task may discard the distinction? What should a release record?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

A standardized mapping defines representation behavior, not the training task's semantic requirements.

Compare with the solution

No. Compatibility folding can be intentional for one task and destructive for another. Record the normalization form and pipeline version, preserve raw lineage, and test whether distinctions such as symbolic notation, identifiers, or code are meaningful for the corpus's intended use.

Take it with you

  • Decoding, extraction, and normalization are separate versioned representation choices.
  • Raw and derived content identities preserve different evidence.
  • Volume yield and deterministic output do not replace semantic-fidelity checks.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.