Sub topic 2
The weak supervision idea: many noisy sources instead of few clean labels
This chapter assumes you can train and evaluate a text classifier, read precision, recall and F1, use basic probability (conditional probability and independence), and read simple Python and regular expressions. The previous chapter covered why labeled text is scarce and expensive. This one introduces the approach that responds to that problem. Later chapters build each part in detail.
The core trade
Supervised learning normally asks for a small number of accurate labels, usually from human annotators. Weak supervision reverses the bet. It collects a large number of labels from sources that are individually imperfect, then uses statistics to reduce the noise.
A source is anything that can guess a label without a person reading the example. Common examples:
| Source | Example for sentiment | Typical weakness |
|---|---|---|
| Pattern or keyword rule | Text contains "refund" means negative | Misses most examples, fires on irrelevant ones |
| Lexicon or knowledge base | Word appears in a list of positive terms | List does not match your domain |
| Existing model | A classifier trained on another domain | Domain shift |
| Crowd or non-expert annotators | Fast, cheap judgments | Inconsistent quality |
| LLM prompt | "Is this review positive or negative?" | Bias, sensitivity to wording |
No single source needs to be good. Each needs to be better than random on the examples where it speaks, and it needs to be cheap to run on millions of texts.
You pay with label accuracy and get label volume. A hand-labeled set of 500 examples at 98% accuracy may be worth less than 200,000 examples at 80% accuracy, because many models tolerate random label noise well. The exchange is not free, because noise that is systematic, rather than random, will be learned by the model. Most of the design effort in weak supervision goes into telling those two kinds of noise apart.
Why combining sources helps
Suppose each source is correct 70% of the time, and the sources make mistakes independently of each other. If you take a majority vote of several of them, the vote is right more often than any one source. The following code computes this exactly from the binomial distribution.
from math import comb
def majority_accuracy(n_sources, p):
"""Chance that a majority of n independent sources, each correct
with probability p, is correct. n_sources must be odd."""
need = n_sources // 2 + 1
return sum(
comb(n_sources, k) * p**k * (1 - p) ** (n_sources - k)
for k in range(need, n_sources + 1)
)
for n in (1, 3, 5, 7):
print(n, round(majority_accuracy(n, 0.7), 3))
# 1 0.7
# 3 0.784
# 5 0.837
# 7 0.874Five 70% sources reach about 84%. The gain depends on two assumptions: the sources are better than chance, and their errors are independent. Both can fail in real projects, and the second one fails often.
What independence means in practice
Two keyword rules that both fire on the word "great" make the same mistakes. They are not two pieces of evidence. They are one piece counted twice. Take five sources where three are near copies of each other. A majority vote then equals the opinion of that group of three, so the vote is only as accurate as one source, 70% in the example above. The extra sources add apparent confidence and no accuracy.
A label model, covered later in this tutorial, tries to estimate source accuracies and correct for some dependence. It cannot fix a dependence that you do not tell it about or that it cannot detect from the votes. For now, treat source diversity as a design goal. Prefer sources that look at different evidence: surface patterns, an external lexicon, a model trained elsewhere, and a prompted LLM.
Sources can abstain
A weak source does not have to label everything. A rule such as "contains 'refund'" is fairly precise but fires on a small share of texts. Forcing it to guess on the rest would only add noise. So each source is allowed to return a special value meaning "no opinion", called abstain.
This changes how you think about a source. It has two properties you can measure, and they trade against each other:
- Accuracy: of the examples it labels, how many are right.
- Coverage: how many examples it labels at all.
A narrow, precise rule and a broad, sloppy rule are both useful, because they complement each other. The precise rule anchors the label on a few examples. The broad rule reaches examples that nothing else touches. Writing these sources as code is the topic of the next chapter.
The pipeline
Weak supervision turns raw text into a trained classifier in stages. The labels produced at each stage are noisy, and the only clean data in the picture is a small gold set used to check the result.
- Sources vote on each text, or abstain. The votes are stored in a matrix with one row per text and one column per source.
- A combiner turns each row of votes into one label. The simplest combiner is a majority vote. A label model does better by weighing each source by its estimated accuracy.
- The combiner outputs probabilistic labels, such as 0.85 positive, rather than a hard class. These carry the uncertainty forward.
- An end model, an ordinary classifier, trains on those labels. It can use features the sources never saw, such as word embeddings, so it often generalizes beyond the rules that produced its labels.
- The end model is scored on the gold set. This is the only step that tells you whether the whole pipeline worked.
The end model matters because the sources abstain on many texts. A trained classifier can label every text, including those on which every rule abstained.
What you give up
Weak supervision is a trade, and the costs should be clear before you adopt it.
- Label quality has a ceiling. If your sources encode a wrong idea of the task, more data makes the model learn that idea more thoroughly.
- Noise can be systematic. A keyword rule that links a product name to negative sentiment teaches the model that link, and no amount of data corrects it.
- You still need some clean labels. Without a gold set you cannot tell a working pipeline from one that is confidently wrong. A few hundred hand-labeled examples is a typical size.
- Engineering moves, and does not disappear. You write and debug sources instead of annotating, and that is only a good deal when the sources are reusable across many examples.
When it is a good fit
Weak supervision works best when these conditions hold:
- You have a large pool of unlabeled text and little labeled text.
- Experts can state parts of their knowledge as rules, lists or prompts, even if they cannot label every example.
- The task changes often, such as new categories or a new domain, so relabeling by hand would repeat expensive work.
- The cost of some label noise is acceptable, as in search ranking, triage or content routing, and a single wrong label is not a safety problem.
It is a poor fit when the classes are subtle and no pattern reliably separates them, when each label needs deep reading of context, or when you have too little text for the noise to average out.
Check your understanding
Exercise
Five labeling sources are each correct 70% of the time. Three of them are copies of the same keyword rule, and the other two are independent. A majority vote is taken. Is the vote more accurate than a single source? Explain.
Show answer
No. The three copies always vote the same way, so they always form a majority of three out of five. The vote is therefore decided by that one rule, and the accuracy is 70%, the same as a single source. The two independent sources can never change the outcome. Sources must make independent errors for a vote to gain accuracy.
Exercise
A rule labels 4% of your texts and is right on 95% of them. Another rule labels 60% of your texts and is right on 65% of them. Which should you keep?
Show answer
Keep both. The first is precise and anchors the label on a small set of examples. The second reaches many examples that no other source touches, and its noise can be reduced when it is combined with other sources. Judging a source by accuracy alone ignores coverage, and judging by coverage alone ignores accuracy.
Exercise
Why is a gold set still needed when you have hundreds of thousands of weakly labeled examples?
Show answer
The weak labels come from the same sources that the pipeline learns from, so a model scored against them looks good even if the sources are wrong in a systematic way. Only hand-labeled examples that were not produced by the sources can measure real accuracy.