Language labels change the corpus mixture when their errors are uneven
Treat language identification as a versioned prediction with domain-specific uncertainty, abstention, and measurable retention effects on multilingual coverage.
On this page
The question for today
What you’ll understand
- Distinguish predicted language counts from the corpus's true language composition.
- Calculate how unequal retention changes a two-language mixture.
- Design calibration and abstention checks for short, mixed, and underrepresented text.
Language identification often sits early in a curation pipeline, where its mistakes quietly determine what every later stage can see. A high-confidence label is a model output, not a statement that a document contains only that language. Short titles, transliterated writing, code, quotations, and closely related varieties can defeat a label set built for cleaner text. Evaluate language decisions on the intended corpus and preserve uncertainty instead of allowing a convenient single-label interface to define which communities remain represented.
Match the prediction task to the document
Specify whether the unit is a whole document, paragraph, or segment, and whether the desired result is one label, several labels, or an unknown outcome. A page with one English menu and a long article in another language should not necessarily inherit the menu's label. For code-switched text, a single majority label can conceal useful minority-language spans. Keep the model version, input transformation, label inventory, and segmentation policy so the same raw text can be traced to its admitted representation and routing decision.
The official fastText language-identification documentation describes models recognizing 176 languages and expecting UTF-8 input. That documented coverage is not a claim of equal accuracy across every supported language, dialect, genre, or input length. Languages outside a closed label set may still be assigned an available label rather than automatically recognized as unknown. Establish an abstention or review policy using representative labeled examples. A confidence threshold should be justified by measured error and retention in the relevant setting, including unfamiliar scripts and mixed-language documents.
Retention changes composition even without relabeling
A language filter can distort a mixture through unequal rejection even when the surviving labels look plausible. If one group has more short messages or nonstandard spelling, a global threshold may remove a larger share of its useful text. Measure retained and rejected samples by language, length, source, and relevant varieties using a defensible annotation process. The C4 case study documented disproportionate removals from and about minority individuals under its blocklist filtering; that particular result motivates checking selection effects rather than assuming every filter has identical consequences.
For fixed true groups, multiply each initial share by its retention probability and renormalize by total retained mass. This accounting does not require the filter to explicitly use a language label. A quality score, boilerplate heuristic, or source restriction can also change language composition. Document the measurement unit: ten long documents can outweigh hundreds of short ones in tokens. Do not correct a suspected bias simply by trusting noisy predicted labels as ground truth; first estimate classification and retention errors on an independently reviewed sample.
Calibrate the decision where the data will be used
Separate ranking accuracy from probability calibration. Among items assigned confidence near 0.9, approximately ninety percent correctness would support calibration for that bin and population; a high average confidence alone would not. Inspect confidence reliability by length and language where sample sizes support it, report uncertainty, and keep calibration data separate from the final evaluation. Changing extraction or source composition can change those relationships. If uncertainty is concentrated in valuable low-resource material, preserve it for targeted review or separate routing rather than silently discarding it as low quality.
The probability lab uses an assumed accuracy, not a classifier confidence score. Reset, explicitly set BOTH p=0.8 and n=20, predict sixteen correct labels on average, then Play or Step. Reset and re-set BOTH p=0.9 and n=20; predict eighteen. Edits retain t; playback highlights exact binomial outcomes without labeling documents. The model assumes independent identical correctness events and cannot represent language-specific confusion, code switching, calibration drift, or unequal retention. Use it to distinguish an assumed population accuracy from the count observed in one small audit.
Work it through
Unequal retention shifts a language mixture
An independently labeled fictional collection has 600 documents in language A and 400 in language B. A fixed filter retains ninety percent of A and fifty percent of B. Count documents, not tokens.
A contributes 600×0.9=540 retained documents. B contributes 400×0.5=200, for 740 retained documents in total.
B's initial share is 400/1000=0.4. Its retained share is 200/740≈0.2703, even if every surviving language label is correct.
Report both language-specific retention rates and the changed mixture. To estimate token composition, repeat the accounting with token mass under the fixed tokenizer rather than reusing document percentages.
A filter has reduced B's document share from forty percent to about twenty-seven percent. Aggregate retained volume alone would conceal that selection effect.
The living notebook
Explore the model
Interactive lab · probability
A stated accuracy is not a raw confidence score
For EACH run Reset, set BOTH p and n, predict, then Play or Step. At n=20 compare assumed correctness p=0.8, E[K]=16, with p=0.9, E[K]=18. Edits retain t; playback only highlights exact binomial outcomes. No language labels, confusion matrix, calibration fitting, code switching, or mixture correction is implemented.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
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 forMeasure correctness and retention on representative labeled material before treating a classifier score as a language-quality decision.
Pause & reason
Check your understanding
Your turn
Try it yourself
Two equally sized language groups each begin with 500 documents. Retention is 0.8 for A and 0.6 for B. Calculate B's retained share, then explain why predicted language counts alone may not reveal the true share.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Compute retained counts first; a nonidentity confusion matrix can change the observed labels.
Compare with the solution
A retains 400 documents and B 300, so B's share is 300/700≈0.4286. Predicted counts can include misclassified A documents and omit mislabeled B documents. Independent labeling or a validated error model is needed to assess true composition rather than equating predictions with ground truth.
Keep the idea
Take it with you
- Language identification is a versioned prediction task whose unit and unknown policy matter.
- Unequal retention can change language coverage even when surviving labels are correct.
- Calibration, classification error, and corpus composition require separate measurements.
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.