Weakly Supervised Transformer

Machine Learning
Introduced by
Multiple contributors (weak supervision paradigm: Zhou 2018; transformer backbone: Vaswani et al. 2017)
Year
2017–2019
Type
Weakly supervised deep learning
Family
Deep learning / NLP / CV

What does it do?

Weakly supervised Transformer is a training pipeline in which a pretrained Transformer is fine-tuned on labels produced without manual annotation, such as the outputs of labeling functions, distant supervision, or crowdsourced votes.

Its weak-supervision component follows data programming as implemented in Snorkel (Ratner et al., 2017) and the taxonomy of weak supervision in Zhou (2018). It targets NLP and vision tasks where fully annotated datasets are scarce or costly to produce. The defining step is generating and denoising weak labels before the Transformer is trained.

The intuition behind the method

Hand labeling is slow and expensive. Weak supervision replaces part of it with automatically generated signals: heuristic rules, distant supervision from a knowledge base, crowdsourced votes, or another model's outputs. These signals are noisy and can conflict, so a label model is typically used to combine them. A pretrained Transformer is then fine-tuned on the resulting labels. Whether its pretrained representations tolerate residual label noise better than models trained from scratch is unverified. The outcome depends on how well the weak signals cover the task, so check it on a clean validation set.

History

Weak supervision as a research area is reviewed by Zhou, who distinguishes incomplete, inexact, and inaccurate supervision. The Snorkel system (Ratner et al., 2017) implemented the data-programming approach, in which users write labeling functions and the system denoises their outputs without ground truth. No single originator is credited with combining weak labels and pretrained Transformer backbones; the approach builds on the weak-supervision work of Ratner et al. (2017) and Zhou (2018).

When to use it

Choose this approach when you need a Transformer classifier, extractor, or detector but can afford only a few hundred hand-labeled examples, and when the task can be expressed through labeling functions (rules, ontologies, or existing databases) with reasonable coverage. It fits domain-specific text classification, relation extraction, or image tagging where such sources can generate a large but noisy training set. Avoid it when no heuristic labeling function can be written with useful coverage; a small set of gold labels used with a few-shot or prompt-based approach may then work better. Also avoid it when the label noise is systematically biased in a way the label model cannot detect, because that bias will pass into the Transformer.

Limitations and considerations

  • Labeling functions must be designed with domain knowledge, and their coverage and accuracy usually need repeated revision.
  • The label model estimates accuracies and correlations without ground truth, so errors that are correlated in ways the model does not capture will remain in the training labels.
  • Label quality is bounded by the coverage and accuracy of the weak signals; examples that no function labels, or where functions conflict, carry little reliable information.
  • Evaluation is hard without a clean test set, and scores on noisy validation labels may be misleading.
  • The label model's estimates of accuracies and correlations are only as reliable as its assumptions about how labeling functions depend on one another (Ratner et al., 2017).

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

Strengths

  • Reduces hand annotation: once written, labeling functions can be run over large unlabeled collections at low marginal cost.
  • The pretrained backbone gives fine-tuning a starting representation, which may help when labels are noisy; whether it does so for a given task should be checked on validation data.
  • The label model estimates the accuracy and correlation of each labeling function, so unreliable sources can be weighted down rather than trusted equally.
  • Soft targets carry the label model's uncertainty into training instead of forcing a single hard label on every example.
  • The same pipeline applies to text and image tasks, provided labeling functions can be written for the data.

Applications

  • Text and image classification with labeling functions: Snorkel was evaluated on four open-source text and image datasets (Ratner et al., 2017).
  • Public-sector and regulatory document work: Snorkel was applied in two collaborations, with the U.S. Department of Veterans Affairs and the U.S. Food and Drug Administration (Ratner et al., 2017).
  • Comparison with hand-curated data: in Snorkel's reported experiments, the system improved predictive performance by 132% on average over prior heuristic approaches and came within an average 3.60% of large hand-curated training sets (Ratner et al., 2017). These results are for Snorkel, not for a Transformer-based pipeline.
  • Possible uses not evaluated in the cited work: domain-specific document classification, relation extraction or named entity recognition with distant supervision from knowledge bases, and image tagging with labeling functions built from metadata.

How it works

How it works

1

Weak labels are produced without human annotation: labeling functions (keyword rules, distant supervision against a knowledge base, crowdsourced votes, or another model's output) are applied to each example. Each function may abstain or disagree, producing a noisy label matrix rather than clean ground truth.

2

A generative label model, such as the one in Snorkel, combines the outputs of multiple labeling functions whose accuracies and correlations are not known in advance. It estimates these properties without access to ground truth and infers a probabilistic label for each example. This reduces, but does not remove, noise before the Transformer is trained.

3

A pretrained Transformer backbone (e.g., BERT, RoBERTa, ViT) is initialised from weights learned by self-supervised pretraining on a large unlabeled corpus. These representations are the starting point for task-specific fine-tuning and do not depend on the weak labels.

4

The Transformer is fine-tuned on the probabilistically labeled training set. It is often trained with soft (fractional) cross-entropy against the label model's probabilities rather than hard one-hot targets, so that uncertainty about each example enters the gradient updates. Training for many epochs on noisy targets can still lead the model to fit incorrect labels, so validation monitoring matters.

5

At inference time, the fine-tuned Transformer predicts in the standard way. If a small clean validation set is available, calibration or threshold tuning on it can correct systematic bias introduced by the noisy training labels.

Common pitfalls

  • Writing labeling functions that overlap heavily and leave many examples unlabeled (every function abstains), so the label model has little signal to work with.
  • Training on hard pseudo-labels from the label model, which discards the uncertainty it has estimated.
  • Omitting a small clean validation set, which makes it hard to detect systematic bias introduced by the weak labels.
  • Treating weak supervision as if it removed label noise; residual noise can still shift decision boundaries, especially where coverage is low.
  • Training for many epochs on noisy targets, which lets the model memorise incorrect labels.

Frequently asked questions

How many labeling functions do I need?

The number needed depends on the task and is not fixed. What matters more is that the functions cover enough examples and that their errors are not all alike. Functions that overlap heavily, or that abstain on most examples, give the label model little to estimate their quality from. Start with a set you can write and check, measure coverage and agreement, and extend it where coverage is poor.

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

Soft (probabilistic) labels keep the uncertainty the label model estimates, so the Transformer is not pushed to commit fully to examples on which the weak signals disagree. Hard labels are simpler and can be reasonable when the label model is very confident for most examples. Comparing both on a clean validation set is the most reliable way to decide.

Do I still need any gold-labeled data?

A small clean validation set (even a few hundred examples) is strongly recommended to select hyperparameters, detect systematic bias, and report honest evaluation metrics. Training can be entirely on weak labels, but evaluation should not be.

How does this compare to few-shot prompting of a large language model?

Few-shot prompting needs no labeling functions, but its results depend on the language model's in-context learning on your task, which may be weak for specialised domains. Weakly supervised fine-tuning produces a task-specific classifier, but it requires upfront work to write and check labeling functions and to generate enough weakly labeled data. Which is preferable depends on the task and on how much engineering effort is practical; comparing both on the same clean validation set is the most direct check.

Can I apply this to vision tasks, not just text?

Weak supervision is not limited to text. Snorkel was evaluated on both text and image datasets (Ratner et al., 2017), so the same pipeline of labeling functions, a label model, and soft-label fine-tuning can in principle be applied to a vision Transformer such as ViT, with labeling functions built from image metadata or rules. Validate the approach on your specific vision task using clean validation data.

Related methods

Sources

  1. Ratner, A., Bach, S. H., Ehrenberg, H., Fries, J., Wu, S., & Re, C. (2017). Snorkel: Rapid training data creation with weak supervision. Proceedings of the VLDB Endowment, 11(3), 269–282.

    Open DOI reference
  2. Zhou, Z.-H. (2018). A brief introduction to weakly supervised learning. National Science Review, 5(1), 44–53.

    Open DOI reference