Sub topic 1
Why Labeled Text Is the Bottleneck
Supervised text classifiers need labeled examples, and getting those labels is usually the slowest and most expensive part of an NLP project. This chapter explains why, puts rough numbers on the cost, and shows the trade-off that weak supervision makes in response. Later chapters build the tools.
Prerequisites
This chapter assumes you have the following:
- Basic Python, enough to read short functions and loops.
- Experience with supervised text classification: features, training, and evaluation on held-out data.
- Precision, recall and F1.
- Basic probability, such as conditional probability and independence.
- Familiarity with regular expressions.
The problem in one sentence
Modern text models learn from examples of the form (text, label). Models are cheap to train and unlabeled text is cheap to collect. The labels are the scarce part, because a person with the right knowledge has to read each text and decide.
Suppose you want to flag customer messages that contain a refund request. You have 2 million messages in a database, and none has a label. You could train a classifier tomorrow if you had 20,000 labeled examples. Producing them is where the project stalls.
Where the cost comes from
Labeling cost has several components. Teams often count only the first one.
- Annotator time. A simple sentiment label may take 5 to 10 seconds. A legal clause or a clinical note may take minutes.
- Expertise. Some labels need a specialist: a lawyer, a physician, a security analyst. Their time costs far more than a crowd worker's, and they are harder to schedule.
- Guideline writing. Annotators need a written definition of every class, with examples and edge cases. Writing and revising it takes days.
- Quality control. Annotators disagree. You usually label a portion of the data twice, measure agreement, resolve conflicts, and retrain annotators.
- Rework. If the label set changes, old labels may become unusable. Adding a class, splitting one, or redefining one often forces relabeling.
A back-of-the-envelope estimate shows how these add up.
def labeling_cost(n_examples, seconds_per_label, hourly_rate,
redundancy=1, review_fraction=0.1):
"""Estimate the cost of hand-labeling a text dataset.
redundancy: how many annotators label each example.
review_fraction: share of examples re-read by an adjudicator.
"""
label_hours = n_examples * seconds_per_label * redundancy / 3600
review_hours = n_examples * review_fraction * seconds_per_label / 3600
hours = label_hours + review_hours
return hours, hours * hourly_rate
for name, n, secs, rate in [
("sentiment, crowd", 20_000, 8, 15),
("support triage, trained staff", 20_000, 30, 25),
("clinical notes, specialist", 20_000, 180, 120),
]:
hours, cost = labeling_cost(n, secs, rate, redundancy=2)
print(f"{name:32s} {hours:8.0f} hours ${cost:>10,.0f}")With two annotators per example, the three tasks come to roughly 100, 340 and 2,000 hours. In dollars that is about $1,500, $8,500 and $240,000. The numbers are illustrative. The pattern is not: cost scales with the number of examples, the time per example, and the price of the expertise, and these multiply.
Why more labeling does not fix it
You might respond by hiring more annotators. This helps less than expected, for three reasons.
Labels go stale. Language changes. New product names, slang, and topics appear, and the distribution of incoming text drifts. A model trained on last year's labels degrades, and you need fresh labels to detect and repair that.
Every task needs its own labels. A sentiment dataset does not help with refund detection. Each new classification task, language, or domain starts from zero. An organization with 30 text tasks has 30 labeling projects.
Quality does not scale for free. Adding annotators adds disagreement. Two people reading "The battery is fine, I guess" may choose different labels. Larger teams need more guideline maintenance, not less.
What a small labeled set can and cannot do
Teams often respond by labeling a few hundred examples and training on them. This is a legitimate approach, and a small set is still needed later for evaluation. As training data it has limits.
- High variance. With 300 examples and 10 classes, some classes have 10 or fewer examples. The model's performance on them swings wildly between random splits.
- Poor coverage of rare phrasing. Text is long-tailed. A class such as "refund request" can be expressed in hundreds of ways, and 300 examples sample only a few.
- Noisy evaluation. With 100 test examples, the 95% confidence interval on accuracy is about plus or minus 10 points when accuracy is near 80%. You cannot tell a real improvement from noise.
The last point matters for the whole tutorial. Whatever labeling strategy you use, you need a trustworthy evaluation set, and that set must be hand-labeled. Chapter by chapter, you will see that weak supervision reduces the amount of hand-labeling needed for training. It does not remove the need for a gold set.
The trade: accuracy per label for volume
Weak supervision starts from an observation. Hand labels are accurate and few. Programmatic labels are noisy and many. For many text tasks, a large noisy set can train a better model than a small clean one, provided the noise is handled sensibly.
The sources of noisy labels are the subject of the next chapters:
- Heuristics, such as a regular expression that matches "refund".
- External resources, such as a sentiment lexicon or a knowledge base.
- Other models, including large language models (LLMs) prompted to label text.
Each source is wrong some of the time and silent some of the time. The central idea is to combine many such sources and estimate how reliable each one is, instead of trusting any single one.
The diagram contrasts the two approaches.
A first look at the trade
Here is the smallest possible weak labeler. It uses one regular expression to label text, and abstains when the expression does not match.
import re
ABSTAIN, NO_REFUND, REFUND = -1, 0, 1
def lf_refund(text):
return REFUND if re.search(r"\b(refund|money back)\b", text, re.I) else ABSTAIN
texts = [
"I want a refund for this order",
"Please send my money back",
"Where is my package?",
"No refund needed, thanks for the quick help",
"The app crashes on launch",
]
labels = [lf_refund(t) for t in texts]
coverage = sum(l != ABSTAIN for l in labels) / len(labels)
print(labels) # [1, 1, -1, 1, -1]
print(coverage) # 0.6Three observations follow from this tiny example.
- The function labeled 60% of the texts with no human effort. That is the volume gain.
- The fourth text is labeled
REFUNDbut the customer does not want one. That is the accuracy cost. - For two texts the function says nothing. Abstaining is a deliberate choice. It lets a function be precise on the cases it knows and leave the rest to other sources.
One rule is clearly imperfect, yet it already produces labels at no marginal cost. Many rules with different strengths and blind spots can cover each other's gaps, and the later chapters show how to weigh them.
Common misconceptions
- "Noisy labels are just bad labels." Noise that is independent across sources partly cancels when you combine sources. Noise that is shared between sources does not. Chapter 15 returns to this.
- "Weak supervision replaces annotators." It shifts annotators' work from labeling every example to writing guidelines, inspecting errors, and building the gold set.
- "An LLM removes the bottleneck." An LLM is another noisy source with its own biases and costs. It speeds up labeling but still needs checking against gold labels.
Summary of the bottleneck
- Labels are expensive because they need human time, expertise, guidelines, and quality control.
- The cost recurs when the task, domain, or language changes.
- Small hand-labeled sets give high-variance models and noisy evaluation.
- Weak supervision gives up per-label accuracy to gain volume, and it relies on combining sources and on a small gold set to control the damage.
Exercise
A team has 50,000 unlabeled support tickets. An annotator takes 20 seconds per ticket, two annotators label each ticket, and annotators cost $30 per hour. Ignoring review, what is the labeling cost? Then name one reason that the team should still hand-label some tickets even if they adopt weak supervision.
Show answer
Labeling time is 50,000 x 20 s x 2 = 2,000,000 seconds, which is about 555.6 hours. At $30 per hour the cost is about $16,700. The team should still hand-label a gold set, because weak labels are noisy and cannot be trusted to evaluate the model. A hand-labeled set is the only reliable way to measure real accuracy.
Exercise
In the example lf_refund, the text "No refund needed, thanks for the quick help" was labeled REFUND. Describe one change that would reduce this error, and say what the change would cost in coverage.
Show answer
Add a second function that votes NO_REFUND (or makes the first abstain) when "refund" is preceded by a negation such as "no" or "not", for example with a regular expression like r"\b(no|not|don't need)\s+(a\s+)?refund". This removes the false positive, but it also drops true refund requests that happen to include a negation word, such as "I do not want a replacement, I want a refund", so precision rises while coverage may fall slightly.