Sub topic 2
The Weak Supervision Idea: Many Noisy Sources Instead of Few Clean Labels
Prerequisites and the labeling bottleneck
This chapter assumes you know basic Python, supervised text classification, precision, recall, F1, basic probability, and regular expressions.
A text classifier needs labeled examples. Each example pairs text with a target class, such as positive or negative. Hand-labeling produces useful labels, but it is slow and expensive. Domain experts may need to read thousands of messages, and different experts may disagree.
Weak supervision changes the trade-off. Instead of asking a person to label every example, you write several imperfect rules or connect the data to external signals. These sources produce labels quickly, but their labels may be wrong or missing.
The goal is not to trust one noisy source. The goal is to combine several sources so that their useful patterns reinforce one another.
Many noisy sources
A labeling function is a program that examines one text and returns a class or abstains. Abstaining means that the function does not have enough evidence to make a prediction.
For example, a customer-support project might use these sources:
| Source | Example signal | Likely weakness |
|---|---|---|
| Keyword rule | “refund” suggests a complaint | Misses synonyms and context |
| Star rating | One-star review suggests negative sentiment | Ratings may be missing or sarcastic |
| Product database | A known defect code suggests a problem | Codes may be outdated |
| Human-written pattern | “I cannot log in” suggests an access issue | Covers only selected wording |
A single source has limited coverage or accuracy. Several independent sources can cover different parts of the data. A keyword rule may recognize “refund,” while a phrase rule recognizes “cannot log in.” Some examples may receive no label at all.
ABSTAIN, NEG, POS = -1, 0, 1
def refund_rule(text):
return NEG if "refund" in text.lower() else ABSTAIN
def praise_rule(text):
words = ("great", "excellent", "love")
return POS if any(word in text.lower() for word in words) else ABSTAIN
texts = ["I want a refund", "Great battery", "Please help me"]
for text in texts:
votes = [refund_rule(text), praise_rule(text)]
print(text, votes)The output is a set of noisy votes, not a final truth. Later stages can measure how often each source votes, how often sources disagree, and which sources appear reliable.
Why this is called weak supervision
Supervision is weak when the training signal is indirect, incomplete, or noisy. A rule based on a word is weaker than a carefully checked human label because the word can appear in an unexpected context. For example, “The refund was processed quickly” contains refund but may describe a successful resolution rather than a negative experience.
Weak supervision is valuable when obtaining clean labels is the main bottleneck. You exchange some label accuracy for much greater volume and faster iteration. You can test a classifier early, find difficult cases, and improve the sources before paying for a large annotation project.
The basic workflow
A practical project starts with a small set of clear classes and several sources based on different evidence. You then inspect disagreements, revise the sources, and compare the trained classifier with a gold set of labels created independently by people.
Exercise
Why is combining several weak sources usually better than copying the output of one keyword rule?
Show answer
Different sources cover different examples and make different errors, so their combined evidence can provide broader and more reliable training labels.