Semi-supervised RoBERTa-based Classification

Machine Learning
Introduced by
Liu et al. (RoBERTa, 2019); semi-supervised adaptation by the NLP community
Year
2019–2020
Type
Semi-supervised fine-tuning of a pretrained language model
Family
Deep learning / NLP / CV

What does it do?

Semi-supervised RoBERTa-based classification fine-tunes a pretrained RoBERTa language model on a small labeled dataset and then uses a larger pool of unlabeled text to improve it.

The unlabeled examples supply a training signal either through pseudo-labels or through consistency constraints on augmented inputs. It is aimed at text classification tasks where annotation is the main bottleneck.

The intuition behind the method

RoBERTa's pretrained representations already encode much of the language structure a classifier needs, so a small labeled set may be enough to attach a useful task head. The semi-supervised step then uses unlabeled text in one of two ways: confident predictions are fed back as provisional labels, or the model is trained so that its predictions stay stable when the input is perturbed. Both routes depend on the initial model being reasonably accurate, because wrong pseudo-labels are reinforced in later rounds. Low-confidence predictions are the ones most likely to be wrong, so they are usually excluded or down-weighted rather than treated as useful signal. The benefit of the method is therefore conditional on the quality of the first model and on how the confidence threshold filters its output.

History

RoBERTa was introduced by Liu et al. in 2019 as a retrained variant of BERT with a modified pretraining recipe. It is used as a pretrained backbone for fine-tuning text classifiers. The UDA framework (Xie et al., NeurIPS 2020) introduced consistency training with augmented unlabeled data, and semi-supervised RoBERTa classification draws on that line of work. No single originating paper is identified for this combination; it is an adaptation of these ideas rather than a method with one founding publication.

When to use it

Choose this method when labeled examples are expensive but a sizeable unlabeled text corpus from the same domain is available, as in clinical note or legal document classification. It is most likely to help when the labeled set is small and the unlabeled text matches the labeled distribution. No validated minimum number of labeled examples is established for this method. The appropriate size depends on the number of classes and how hard they are to separate, so the first model's validation performance should decide whether self-training is worthwhile. Do not use it when the labeled set is already large enough for ordinary fine-tuning to saturate, when the unlabeled data comes from a different domain than the labeled data (pseudo-label errors will then be reinforced), or when compute is limited, since each self-training round is a full fine-tuning pass over a transformer.

Limitations and considerations

  • Errors compound across rounds: pseudo-labels produced by an early, weak model become training targets for later models, so a poor starting classifier can lock in its own mistakes.
  • Each self-training round requires another fine-tuning pass of a large transformer over the labeled and accepted unlabeled data, which makes RoBERTa-large especially costly.
  • Results depend on the confidence threshold used to accept pseudo-labels and, for consistency training, on the augmentation choices; neither is fixed by the method itself.
  • Gains require unlabeled text from the same domain as the labeled data; out-of-domain text tends to add noisy targets.

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

Strengths

  • Builds on RoBERTa's pretrained representations, so the classifier starts from a strong feature extractor and needs fewer labeled examples than a task model trained without pretraining.
  • Makes use of unlabeled text that is often already available, which can reduce the annotation effort needed to reach a given accuracy.
  • Pseudo-labeling and consistency regularization are added to a standard fine-tuning loop, so existing transformer training code can usually be extended rather than rewritten.
  • Stopping can be governed by validation macro-F1 across self-training rounds, giving an observable criterion rather than a fixed number of iterations.
  • Consistency training uses the model's full predicted distribution rather than a single hard label, and UDA proposes it with strong, task-specific augmentations applied to unlabeled data.

Applications

  • Sentiment and opinion classification with limited labeled reviews.
  • Clinical or biomedical text classification where expert annotation is expensive.
  • Legal document categorization using large unlabeled case corpora.
  • Low-resource language classification tasks with scarce labeled data.
  • Fake news and misinformation detection leveraging large unlabeled news archives.
  • Customer support ticket routing with small labeled sets and large historical ticket pools.

How it works

How it works

1

Start from a publicly released RoBERTa checkpoint, typically RoBERTa-base (about 125 million parameters) or RoBERTa-large (about 355 million). Pretraining from scratch is not part of this method; the checkpoint is the starting point for every later step.

2

Add a classification head (a linear layer over the representation of the sequence's first special token, <s> in RoBERTa) and fine-tune on the labeled examples with cross-entropy loss. The accuracy of this first model on unlabeled text determines the quality of any pseudo-labels produced later. With a small labeled set the risk of overfitting is high, so a held-out validation split is needed from the start.

3

Run the partially fine-tuned model over the unlabeled pool. In pseudo-labeling, predictions that pass a confidence threshold are used as training targets. In consistency training, as in UDA (Xie et al.), the model is trained so that its predicted distribution for an unlabeled text matches its prediction for an augmented version of the same text. This is typically implemented as a KL divergence between the two predicted distributions, added to the supervised loss with a weighting coefficient that is a hyperparameter. The choice of augmentations, such as back-translation or word dropout, is a central design decision in this variant.

4

Retrain on the labeled data together with the accepted pseudo-labeled or consistency-regularized examples. Repeating the cycle can improve the model in later rounds, but only while validation performance keeps improving, and errors made in early rounds can carry forward. Stop when validation macro-F1 no longer improves over a pre-set number of consecutive rounds.

5

Report accuracy, macro-F1, and per-class metrics on a held-out labeled test set. Compare against a fully supervised baseline trained on the same labeled examples to measure the gain from the unlabeled data, and against a fully supervised model trained on all available labels as an upper reference.

Common pitfalls

  • Setting the pseudo-label confidence threshold very low, which admits many incorrect labels into training. A softmax threshold such as 0.9 is sometimes used as a starting point, but it is a convention rather than a validated setting, so it should be tuned on validation data.
  • Ignoring domain mismatch between labeled and unlabeled text, which reinforces the model's existing errors on the unlabeled distribution.
  • Using the test set to choose the confidence threshold or the stopping round; these choices need a separate validation split.
  • Reporting only overall accuracy on imbalanced classes; per-class F1 is needed to see whether pseudo-labeling helps minority classes or only the majority.
  • Giving pseudo-labeled examples the same loss weight as gold-labeled ones without testing whether down-weighting them improves results.

Frequently asked questions

How many labeled examples do I need to start?

No validated minimum number of labeled examples is established for this method. The number needed depends on the number of classes and how hard they are to separate. With very few examples per class, pseudo-labels may be too unreliable for iterative gains, so check the first model's validation performance before starting self-training.

What confidence threshold should I use for pseudo-labels?

A softmax probability of 0.9 is sometimes used as a starting point, but it is a convention rather than a validated setting. Lower thresholds admit more pseudo-labels but also more noise. Tune the threshold on validation data and track macro-F1 after each round rather than fixing it in advance.

Should I use pseudo-labeling or consistency training (UDA)?

Consistency training uses the full predicted distribution and, in UDA, relies on strong augmentations of unlabeled text. It adds complexity because the augmentation strategy must be chosen carefully. Hard pseudo-labeling is simpler and is a reasonable baseline. Which approach works better depends on the data, so compare both on validation data.

How do I know when to stop iterating?

Monitor validation macro-F1 after each self-training round and stop when it has stopped improving for a pre-set number of consecutive rounds. Continuing beyond that risks fitting pseudo-label noise.

Can I use RoBERTa-large instead of RoBERTa-base?

Yes. RoBERTa-large has about 355 million parameters compared with about 125 million for RoBERTa-base, so each fine-tuning pass is considerably more expensive. The base model is usually easier to fit into tight latency or compute budgets.

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 preprint arXiv:1907.11692.

    Open publication reference
  2. Xie, Q., Dai, Z., Hovy, E., Luong, M.-T., & Le, Q. V. (2020). Unsupervised Data Augmentation for Consistency Training. Advances in Neural Information Processing Systems (NeurIPS), 33, 11904–11915.

    Open publication reference