Semi-Supervised Learning for Large Language Models Safety and Content Moderation

Eduard Stefan Dinuta, Iustin Sirbu, Traian RebedeaarXiv 2025 · DOI

Abstract

Ensuring the safety of Large Language Models (LLMs) requires robust content moderation systems capable of detecting harmful prompts and toxic responses. However, the creation of high-quality, human-annotated safety datasets is a significant bottleneck. This paper explores Semi-Supervised Learning (SSL) as a solution, demonstrating that near-state-of-the-art performance can be achieved using only a fraction of the labeled data typically required. By introducing a task-specific data augmentation technique powered by uncensored LLMs, the authors significantly outperform traditional methods like backtranslation, achieving performance within 1.4% of fully supervised models using only 2,000 labeled examples.

Introduction

As LLMs are increasingly integrated into consumer and enterprise applications, the demand for effective "guardrails" has intensified. Traditional safety classifiers rely on massive, expensive human-labeled datasets. These datasets are not only costly but often suffer from subjective labeling errors and difficulty in scaling to new, emerging threats.

This research addresses the "data bottleneck" by investigating whether top-tier safety filters can be built using primarily unlabeled "real-world" data. The authors propose a framework that combines small amounts of high-quality labeled data with vast quantities of unlabeled text through Semi-Supervised Learning (SSL).

Methodology

The study treats safety moderation as a text classification task, utilizing the deberta-v3-base model as the backbone. The researchers evaluate three primary SSL frameworks:

  1. FixMatch: Utilizes pseudo-labeling where a model's confident prediction on a weakly augmented sample serves as the ground truth for a strongly augmented version of the same sample.
  2. MarginMatch: An extension of FixMatch that incorporates a "Pseudo-Margin" filter, ensuring the model learns from unlabeled examples where predictions remain stable over time.
  3. MultiMatch: A holistic approach employing multiple classification heads that must reach a consensus to determine the weight of an unlabeled sample in the training process.

Task-Specific Augmentation

A core innovation of this work is the move away from generic augmentation techniques like backtranslation. The authors argue that backtranslation often "washes out" the subtle adversarial nuances necessary for safety training. Instead, they employ uncensored LLMs (e.g., Llama-3.2-3B-Instruct-abliterated) to rewrite prompts while intentionally preserving their malicious intent. This creates "hard" examples that challenge the classifier to understand the underlying semantics of harm rather than relying on keyword detection.

Experimental Results

The models were evaluated across several benchmarks, including WildGuard (adversarial attacks), Aegis 2.0 (risk taxonomy), and XSTest (exaggerated safety).

Table 1: Performance comparison (F1 score) of various SSL algorithms and augmentation techniques across multiple safety benchmarks.

As shown in Table 1, the SSL approach demonstrates remarkable efficiency. With only 2,000 labeled examples—representing a tiny fraction of the 77,000 samples used in the fully supervised baseline—the SSL models achieved an F1 score of 0.856 on the WildGuard prompt classification task, coming within 1.4% of the fully supervised performance (0.870).

Furthermore, the custom LLM-based augmentation consistently outperformed backtranslation. On the Aegis 2.0 dataset, the LLM-based approach provided up to a 10% improvement in F1 score, highlighting the importance of task-specific data synthesis in safety contexts.

Discussion and Key Insights

The findings suggest a "98% Rule" for LLM safety: the vast majority of performance can be captured with a small, high-quality labeled core, while the "long tail" of labeled data offers diminishing returns. The success of the approach relies heavily on the use of "abliterated" models for augmentation; to train a model to recognize harm, the teacher model must be capable of generating diverse, harmful variations without being constrained by its own safety filters.

While the results are promising, the authors note that response classification remains more challenging than prompt classification, particularly when labeled data is extremely scarce (e.g., 200 labels). In these low-data regimes, the noise introduced by LLM-based augmentation can occasionally hinder performance compared to simpler methods.

Conclusion

Semi-supervised learning, paired with intelligent, task-specific augmentation, provides a scalable and cost-effective path for developing robust LLM safety guardrails. By reducing the reliance on massive human-annotated datasets, this approach allows for more rapid iteration and adaptation to the evolving landscape of AI safety risks.

Summary updated

BibTeX
@misc{dinuta2025semi,
  author = {Eduard Stefan Dinuta and Iustin Sirbu and Traian Rebedea},
  title = {{Semi-Supervised Learning for Large Language Models Safety and Content Moderation}},
  year = {2025},
  eprint = {2512.21107},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.21107},
}
Figure