Weakly Supervised RoBERTa-based Classification

Machine Learning
Introduced by
Liu et al. (RoBERTa, 2019); weak supervision paradigm: Ratner et al. (2016–2020)
Year
2019–2020
Type
Pretrained transformer classifier with weak supervision
Family
Deep learning / NLP / CV

What does it do?

Weakly supervised RoBERTa-based classification trains a RoBERTa text classifier on labels produced programmatically rather than by hand.

Labeling functions, such as rules, heuristics or distant-supervision sources, assign noisy labels to an unlabeled corpus; a label model aggregates them into probabilistic labels, and RoBERTa is fine-tuned on the result. A clean, hand-labeled held-out test set is still needed to evaluate the classifier.

The intuition behind the method

Hand-labeling large text datasets is slow and costly. Weak supervision replaces much of that work with simple rules, such as keyword lists, regular expressions or lookups in external resources, each of which labels some examples and abstains on the rest. Because these rules disagree and make mistakes, a label model estimates how reliable each one is and combines them into a single label per example. RoBERTa is then fine-tuned on these imperfect labels, and its pretrained language representations can help it learn the consistent signal in the noise.

History

RoBERTa was introduced by Liu et al. in 2019 as a robustly optimized variant of BERT pretraining, in which choices such as more training data, longer training and dynamic masking were examined. Weak supervision with labeling functions is associated with the Snorkel system. A benchmark for weak supervision, WRENCH, was published by Zhang et al. in 2021.

When to use it

Choose this approach when a text classification task needs far more labeled examples than can be produced by hand, and when the class criteria can be expressed as rules, term lists or distant-supervision sources. Candidate domains include clinical, legal or scientific text, where experts can write such rules, but suitability depends on whether the labeling functions reach adequate coverage and accuracy on a clean test set. Do not use it when (a) a sufficient set of high-quality hand-labeled data already exists, because fully supervised fine-tuning is then simpler and avoids the bias that rules can introduce; (b) the classification criterion is too ambiguous to codify as labeling functions; or (c) the text is far from the English-language pretraining distribution of RoBERTa and no suitable domain-adapted checkpoint is available.

Limitations and considerations

  • Final accuracy is bounded by the coverage and accuracy of the labeling functions; examples that no labeling function covers receive no training signal from the rules.
  • Writing useful labeling functions requires knowledge of the target classes and their textual cues. Criteria that cannot be stated as rules do not suit this approach.
  • Fine-tuning RoBERTa requires GPU compute and is slower than training bag-of-words classifiers.
  • An independent clean test set is still needed for honest evaluation, and creating it requires manual labeling.
  • When a sufficient set of clean labeled examples is available, fully supervised RoBERTa fine-tuning is usually the simpler option and avoids the risk that rules encode systematic bias.
  • Labeling functions can encode systematic bias from their authors or data sources. The label model estimates each function's accuracy but cannot reliably detect bias it does not model, so the classifier may reproduce that bias.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Replaces most hand labels with programmatic labeling functions, so annotation effort goes into writing and checking rules rather than labeling each example.
  • Labeling functions are explicit, so the source of each training label can be inspected, corrected and rerun.
  • The label model estimates the accuracy and correlations of each labeling function, so unreliable or redundant rules are down-weighted without relabeling the corpus by hand.
  • Fine-tuning a pretrained RoBERTa checkpoint means the classifier starts from contextual language representations rather than being trained from scratch.
  • Coverage and conflict diagnostics for each labeling function show which rules to revise after inspecting model errors.

Applications

  • Clinical text classification where experts can encode criteria as keyword or pattern rules and hand labels are scarce.
  • Legal document classification using statutory keyword rules as labeling functions.
  • Scientific literature triage and topic labeling at scale where curated term lists exist.
  • Social media content moderation where written policy rules can serve as labeling functions.
  • Rapid prototyping of text classifiers in a new domain before committing to a full annotation campaign.

How it works

How it works

1

Domain experts or automated processes define labeling functions (LFs): rules, heuristics or distant-supervision sources. Each LF applies to a subset of the unlabeled corpus, assigns a class label or abstains, and may conflict with other LFs.

2

A label model, such as the generative model used in Snorkel, majority voting or another learned aggregator, combines the outputs of all LFs into one probabilistic label per example. It estimates each LF's accuracy and correlations so that unreliable or redundant sources carry less weight.

3

The probabilistically labeled dataset is used to fine-tune a RoBERTa checkpoint. Its masked-language-model pretraining on large corpora provides contextual representations that the classifier can build on even when the training labels contain noise.

4

Noise-robust strategies are applied during fine-tuning, such as training on soft (probabilistic) labels instead of hard labels, weighting examples by label confidence, or iterative self-training. These may reduce the influence of examples whose labels are likely wrong. How much they help depends on how well the label model is calibrated, so their effect should be checked on the clean held-out test set.

5

The fine-tuned model is evaluated on a small, carefully hand-labeled held-out test set using accuracy, macro-F1, and per-class precision and recall. This test set is kept separate from the weak labels so that the estimate of generalization is not inflated by label noise.

Common pitfalls

  • Evaluating only on the weakly labeled training distribution instead of a clean held-out test set, which produces inflated accuracy estimates.
  • Designing labeling functions around the features of the test set, which leaks evaluation information into the supervision and overstates performance.
  • Ignoring labeling-function coverage gaps: if many examples receive no label from any labeling function, the model learns from a biased subset of the corpus.
  • Training on hard labels from the label model instead of soft probabilistic labels, which discards the uncertainty estimates the label model produces.
  • Using default RoBERTa hyperparameters without tuning the learning rate and batch size for the noisy-label setting.
  • Reporting the weakly supervised result without a hand-labeled baseline evaluated on the same clean test set, so that the benefit of the weak labels over simpler alternatives remains unknown.

Frequently asked questions

How many labeling functions do I need?

There is no fixed minimum. What matters is that the labeling functions together cover enough of the corpus, and that they are not all redundant. Coverage and pairwise agreement or conflict rates, described in the diagnostics question below, show whether the current set is adequate.

Should I use soft or hard labels when fine-tuning RoBERTa?

Soft (probabilistic) labels keep the uncertainty from the label model, which may reduce the pull toward confident but possibly wrong targets. Whether soft labels improve results over hard labels for a given task should be checked on the clean held-out test set.

How does this differ from semi-supervised RoBERTa classification?

Semi-supervised approaches assume a small set of clean labeled examples and use methods such as self-training or consistency regularization on unlabeled data. Weak supervision generates training labels programmatically from rules and heuristics and does not require clean labeled training examples, although a clean test set is still needed for evaluation.

Which RoBERTa variant should I start with?

RoBERTa-base is a practical first choice for most text classification tasks, balancing performance against fine-tuning cost. RoBERTa-large can improve accuracy on harder tasks but needs more GPU memory and longer training. Domain-specific pretrained checkpoints can help on specialised text, but check that a checkpoint is actually RoBERTa-based, since some domain models are built on BERT.

How do I know if my labeling functions are good enough?

Inspect coverage (the fraction of examples labeled by at least one function), empirical accuracy on a small labeled validation slice, and pairwise agreement or conflict rates between functions. Most weak supervision frameworks, including Snorkel, provide these diagnostics. Low coverage combined with high conflict rates usually indicates that the labeling functions need revision.

Related methods

Sources

  1. Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., & Stoyanov, V. (2019). RoBERTa: A Robustly Optimized BERT Pretraining Approach. arXiv:1907.11692.

    Open publication reference
  2. Zhang, J., Yu, Y., Li, Y., Wang, Y., Yang, Y., Yang, M., & Ratner, A. (2021). WRENCH: A Comprehensive Benchmark for Weak Supervision. NeurIPS 2021 Datasets and Benchmarks Track.

    Open publication reference