Abstract
Content moderation is a dynamic challenge, as safety policies must evolve to address emerging harms. While Large Language Models (LLMs) like GPT-4 offer zero-shot adaptability, their high inference costs and latency make them impractical for large-scale production. We introduce STAND-Guard, a 7-billion-parameter Small Language Model (SLM) fine-tuned for task-adaptive content moderation. By training on a minimal set of diverse tasks using human-readable guidelines, STAND-Guard learns the meta-skill of rule-following. Our results show that STAND-Guard significantly outperforms GPT-4 on in-distribution tasks and matches its performance on unseen out-of-distribution categories, providing a cost-effective and hostable alternative for safety alignment.
Introduction
Online platforms face a "moving target" in content moderation. New slang, malicious behaviors, and updated safety policies require constant model updates. Traditional supervised classifiers are rigid, requiring extensive re-labeling and training for every new policy change. Conversely, LLMs provide the flexibility to "read the rules" via prompting, but at a prohibitive cost for high-volume moderation.
STAND-Guard bridges this gap. It is designed to be a small, hostable model that retains the adaptability of massive LLMs. By focusing on cross-task fine-tuning, the authors demonstrate that a 7B model can learn to apply novel moderation guidelines to text, even for categories it never encountered during training.
Methodology
The core of STAND-Guard is cross-task fine-tuning using Mistral-7B as a base. The model is trained using QLoRA (Quantized Low-Rank Adaptation) to act as a rule-follower rather than a simple classifier.
Prompt Structure
The input to the model consists of two primary components:
- The Guideline: A clear, human-readable definition of the harmful content category and the specific classification rules.
- The Content: The user-generated text to be evaluated.
By training on a variety of moderation tasks simultaneously, the model develops a generalized ability to interpret guidelines. To further enhance performance on novel tasks, the researchers also integrated Retrieval-Augmented Generation (RAG), which dynamically provides the model with relevant few-shot examples based on the input text's embedding.
Experimental Setup
The training regime was intentionally minimal to test efficiency. Only three datasets were used for fine-tuning: two public safety alignment datasets (PKU-Alignment BeaverTails and Safe-RLHF) and one proprietary business dataset. In contrast, the evaluation suite was extensive, comprising 42 public datasets and 80 distinct moderation tasks, including irony detection, sexism, and various forms of hate speech.
Results and Discussion
In-Distribution Performance
On tasks included in the training set, STAND-Guard demonstrated superior performance compared to much larger models. It achieved an average F1 score of 0.680, significantly higher than GPT-3.5-Turbo (0.388) and GPT-4-Turbo (0.458).
Out-of-Distribution Generalization
The most significant finding is STAND-Guard's ability to generalize to unseen tasks. On English binary classification tasks it had never encountered, STAND-Guard achieved an average F1 of 0.577. This performance surpasses GPT-3.5-Turbo (0.528) and is on par with GPT-4-Turbo (0.588), despite STAND-Guard being a fraction of the size.
Key Insights
- Transferability of Harms: Ablation studies revealed a synergy between seemingly unrelated moderation tasks. For instance, removing hate speech data from the training set did not prevent the model from outperforming baselines in hate speech detection, suggesting that the logic of moderation transfers across domains.
- Efficiency of Public Data: The model remained highly effective even when proprietary data was removed from the training set. This implies organizations can build high-performance custom moderators using primarily open-source datasets.
- RAG Synergy: Incorporating RAG to provide 10 relevant examples allowed STAND-Guard to match GPT-4's zero-shot capabilities on entirely new tasks.
Conclusion and Future Work
STAND-Guard proves that small, specialized models can achieve the flexibility of general-purpose LLMs for content moderation. However, limitations remain. The current model is optimized for English binary classification; performance declines on non-English datasets and multi-class tasks.
Future research will focus on expanding the training distribution to include more languages and complex task structures. Additionally, while larger models like Mixtral-8x7B show even better generalization, the 7B STAND-Guard remains the optimal choice for businesses balancing accuracy with hosting and latency constraints.
Summary updated