- Introduced by
- Devlin, J. et al. (BERT); broader SSL-Transformer paradigm community
- Year
- 2018–2019
- Type
- Semi-supervised deep learning
- Family
- Deep learning / NLP / CV
What does it do?
Semi-supervised learning with Transformer architectures uses a large pool of unlabeled data together with a small labeled set to train sequence models.
The most common pattern, exemplified by BERT, pre-trains the Transformer on unlabeled data with a self-supervised objective such as masked token prediction, then fine-tunes it on the labeled task. Pseudo-labeling and consistency regularization are further ways to use unlabeled examples during supervised training.
The intuition behind the method
Imagine learning a new language by first reading large amounts of text without annotations (pre-training), and only then studying a small grammar book with worked examples (fine-tuning). The Transformer follows a similar path: it builds representations of language or other structured sequences from unlabeled data, capturing contextual patterns. When it is then shown the small labeled set, it already has a usable model of the input and needs less labeled data to adapt. Pseudo-labeling and consistency-regularization variants go further by feeding the model's own confident predictions, or its stability under perturbation, back into training on unlabeled examples.
History
No single originator is credited with the semi-supervised Transformer paradigm, which covers several related techniques. BERT (Devlin et al., 2019) is the usual reference point: it showed that masked language model pre-training on unlabeled text, followed by supervised fine-tuning, gave strong results on NLP benchmarks. Strictly, BERT is a pre-training and fine-tuning method rather than a semi-supervised learner that uses pseudo-labels or consistency regularization, so treating it as the origin of semi-supervised Transformers is a convention. Self-training and consistency-regularization methods were developed separately and have since been combined with Transformer pre-training.
When to use it
Consider a semi-supervised Transformer when labeled examples are scarce or costly to produce and a sizeable pool of unlabeled data from the same domain is available. This situation is common in NLP, biomedical text, low-resource languages and specialized document collections. The pre-train-then-fine-tune route is most practical when a pre-trained checkpoint exists for a related domain or language, because running unlabeled pre-training from scratch is expensive. Avoid it when the unlabeled data differs strongly from the labeled task, when no suitable checkpoint exists and there is no compute budget for pre-training, or when the labeled set is already large enough that standard supervised fine-tuning reaches the performance you need.
Limitations and considerations
- Compute cost: fine-tuning large pre-trained Transformers requires GPU-class hardware and substantial memory, and pre-training from scratch on unlabeled corpora is far more expensive still.
- Domain mismatch: if the pre-training corpus differs strongly from the target domain, the representations may transfer poorly unless domain-adaptive pre-training on in-domain unlabeled text is added.
- Pseudo-label errors can compound: a wrong pseudo-label becomes training data in later rounds, which can reinforce the model's early mistakes.
- Interpretability: attention weights should be treated with caution as explanations of predictions, and further analysis is needed in high-stakes applications.
- Very small labeled sets make fine-tuning unstable. There is no firm minimum size, and few-shot or prompt-based approaches may suit that regime better.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Can reduce the labeled data needed: pre-trained representations let fine-tuning work with a much smaller labeled set than training a Transformer from scratch.
- Pre-trained checkpoints, such as BERT, are publicly available, so many projects can skip the costly unlabeled pre-training stage.
- The same two-stage pattern covers classification, sequence labeling and question answering, and pseudo-labeling or consistency regularization can be added on top of it.
- Contextual representations model long-range dependencies and word meanings that depend on context, which static word embeddings cannot capture.
Applications
- Low-resource text classification, such as sentiment analysis, using a BERT-type model fine-tuned on a small labeled set.
- Biomedical and clinical text processing, where annotated corpora are scarce but unlabeled clinical notes may be available, typically with domain-adaptive pre-training.
- Named entity recognition and relation extraction in specialized legal or financial text, after domain-adaptive pre-training.
- Image classification with Transformer backbones, where pseudo-labeling or consistency regularization can be tried on unlabeled images. Reported results depend on the dataset and method, so check the current literature.
- Question answering in low-resource languages using multilingual pre-trained Transformers.
How it works
How it works
A Transformer is trained on a large corpus of unlabeled data with self-supervised objectives. Masked language modeling (predicting randomly masked tokens) and causal language modeling (predicting the next token) are the most common. The aim is task-agnostic representations of syntax, semantics and longer-range dependencies, learned without human labels.
The pre-trained model is fine-tuned on the labeled dataset by adding a task-specific head, such as a classifier or sequence labeler, and training with the labeled objective. For many NLP tasks, starting from a pre-trained checkpoint lets fine-tuning use far fewer labeled examples than training from scratch, but the number needed depends on the task, the model and how closely the pre-training data matches the target.
After initial fine-tuning, the model assigns pseudo-labels to unlabeled examples. A common rule keeps an example only when its maximum predicted class probability exceeds a chosen threshold tau. The retained examples are added to the training set, the model is retrained, and the loop can be repeated. The same loop can be applied to Transformer models, and its benefit depends on the quality of the pseudo-labels.
Unlabeled examples are perturbed with stochastic augmentations, such as token dropout or back-translation for text and cutout for images, and training penalizes the model when its predictions differ across the augmented views. A typical objective adds to the supervised loss a divergence term, such as KL divergence or squared error, between the predictions on the original and augmented inputs, weighted by a coefficient. This encourages stable predictions in regions of the input space that labels do not cover. The augmentations must preserve the label of the example (see the pitfalls section).
The final model is evaluated on a labeled held-out test set using task-appropriate metrics: accuracy and F1 for classification, exact match and F1 for question answering, ROUGE for summarization, and IoU for vision tasks. To measure the contribution of the unlabeled data, compare against a supervised baseline trained on the same labeled data and evaluated on the same test split. Repeat runs over several random seeds, especially when the labeled set is small, and report the mean and spread of the difference.
Common pitfalls
- Using a pre-trained checkpoint whose pre-training domain is far from the target domain without additional domain-adaptive pre-training on unlabeled in-domain text.
- Setting pseudo-label confidence thresholds too low, which floods training with noisy labels and can degrade performance below the supervised baseline.
- Applying augmentations that change the label of an example, for instance a token dropout that removes a negation, to unlabeled data in consistency regularization. This trains the model toward incorrect targets.
- Evaluating only on the labeled training split instead of a proper held-out test set, which inflates the apparent gains from semi-supervised learning.
- Ignoring catastrophic forgetting: fine-tuning with too high a learning rate can destroy the pre-trained representations and remove the benefit of unlabeled pre-training.
Frequently asked questions
Do I always need to pre-train from scratch on unlabeled data?
No. For most practical use cases, start from a publicly available pre-trained checkpoint such as BERT and fine-tune on your labeled data. Run domain-adaptive pre-training, meaning continued training on your own unlabeled corpus, only when the domain is very far from the original pre-training corpus (for example clinical notes, legal text or a low-resource language).
How does pseudo-labeling differ from self-supervised pre-training?
Self-supervised pre-training uses artificially constructed tasks (masked tokens, next-sentence prediction) on unlabeled data before any labeled examples are seen. Pseudo-labeling is a post-fine-tuning step: the model that has already seen labeled data assigns soft or hard labels to unlabeled examples, which are then added to the training set for further rounds of supervised training.
What confidence threshold should I use for pseudo-labeling?
A threshold of 0.9 on the top predicted class probability is a common starting heuristic in practice, not a universal setting. Higher thresholds yield cleaner but fewer pseudo-labels; lower thresholds add more data but increase noise. Tune the value on a validation set and check whether adding pseudo-labeled data improves or hurts validation metrics.
Is consistency regularization (UDA) better than pseudo-labeling?
They rely on different assumptions. Pseudo-labeling depends on the model's confidence being a reasonable guide to correctness, while consistency regularization depends on the augmentations preserving the label. Neither is consistently better across tasks; the choice depends on the task and on how well the augmentations are designed, and many pipelines combine both.
How do I prevent catastrophic forgetting during fine-tuning?
Use a small learning rate. A commonly used starting range is 2e-5 to 5e-5, with a linear warm-up and a cosine or linear decay schedule; treat these values as heuristics to tune on validation data. Gradient clipping and layer-wise learning rate decay (lower rates for earlier layers) further protect the pre-trained representations. Avoid fine-tuning for many epochs on small datasets.
Related methods
Sources
Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. Proceedings of NAACL-HLT 2019, 4171–4186.
Open DOI referenceZoph, B., Ghiasi, G., Lin, T.-Y., Cui, Y., Liu, H., Cubuk, E. D., & Le, Q. V. (2020). Rethinking Pre-training and Self-training. Advances in Neural Information Processing Systems (NeurIPS), 33, 3833–3845.
Open publication reference