Adapting Large Language Models for Content Moderation: Pitfalls in Data Engineering and Supervised Fine-tuning

Huan Ma, Changqing Zhang, Huazhu Fu, Peilin Zhao, Bingzhe Wu · DOI

Introduction

Content moderation serves as the essential, often invisible, infrastructure of the modern internet, protecting platforms from hate speech, illegal gambling, and other harmful content. Historically, this task has been dominated by discriminative models—typically BERT-style classifiers that map inputs directly to labels. However, research from Tianjin University, A*STAR, and Tencent AI Lab suggests these models are inherently brittle. They require vast amounts of precisely labeled data and are prone to "shortcut learning," where the model identifies superficial patterns rather than understanding the underlying context.

This paper explores a shift toward a generative paradigm using open-source Large Language Models (LLMs) like Baichuan-7B and 13B. The objective is to develop a privately deployable model that offers superior robustness, interpretability, and accuracy compared to traditional classifiers.

The Challenge of Automated Moderation

Automated content moderation is a continuous "cat-and-mouse" game. Malicious actors frequently bypass filters using emojis, code-switching, or variant characters. Traditional discriminative models often fail in these scenarios because they lack contextual understanding, relying instead on simple keyword-label associations.

While state-of-the-art cloud LLMs like GPT-4 can navigate these nuances, they present significant hurdles for enterprise deployment:

  1. Compliance: Legal restrictions often prevent sending sensitive user data to third-party APIs.
  2. Cost: High-volume moderation via API is economically unsustainable.
  3. Domain Specificity: Generic models may struggle with platform-specific slang or unique policy nuances.

Fine-tuning smaller, open-source models seems like a solution, but standard Supervised Fine-tuning (SFT)—training on simple (input, label) pairs—often results in severe overfitting. The model "cheats" by learning training-set shortcuts, leading to failure on out-of-distribution (OOD) data.

Methodology: A Generative Approach

The researchers propose a pipeline designed to transition from raw data to a robust, generative moderation model.

Overview of the proposed discriminative and generative content moderation frameworks, including performance metrics across various categories.

Chain-of-Thought (CoT) Fine-tuning

Instead of training the model to output a solitary label (e.g., "Violent"), the authors train it to generate an analysis process first. This forces the model to "show its work," effectively teaching it the underlying logic of the moderation policy.

Weak Supervision and Data Cleaning

To generate high-quality training data without manual labeling, GPT-4 is employed as a "teacher." Crucially, the authors use weak supervision: GPT-4 is not provided with the ground truth label during reasoning generation. This prevents the teacher model from "hallucinating" justifications for a pre-known label.

Reject and Recheck Strategies

The pipeline incorporates several data-quality filters:

  • Reject (Setting B): Samples are discarded if GPT-4’s predicted label contradicts the human ground truth.
  • Recheck (Setting C): If a mismatch occurs, GPT-4 re-evaluates its reasoning.
  • Setting D: A combination of both strategies.

Key Insights: Breaking Shortcut Learning

The most significant finding is that CoT reasoning acts as a powerful regularizer. In traditional SFT, a model might learn that a specific word is always "Offensive." CoT forces the model to explain why, allowing it to distinguish between harmful usage and harmless mentions (e.g., a sentence praising a specific demographic).

Comparison of GPT-4 and the proposed model's reasoning processes, highlighting how CoT prevents incorrect classifications in complex cases.

Generative models also provide interpretability. When content is flagged, the model offers a natural language explanation of the policy violation, which is essential for human-in-the-loop moderation systems.

Results and Performance

The study evaluated the models using a mix of internal Chinese business data (In-Distribution) and public benchmarks like the HateSpeech dataset (Out-of-Distribution).

  • Competitive Performance: Models fine-tuned with the "Setting D" strategy consistently outperformed GPT-3.5. In the "Harmless" category, the fine-tuned Baichuan models even surpassed GPT-4.
  • OOD Robustness: CoT-trained models demonstrated significantly higher F1 scores on cross-lingual OOD tasks (Reddit, Twitter, 4Chan). For instance, on the 4Chan dataset, the Baichuan-7B model's F1 score increased from 44.3 (label-only) to 88.9 (with CoT).
  • Zero-Shot Generalization: The models showed an unexpected ability to detect "jailbreak" attempts and new harmful categories not present in the training set, indicating they had internalized a general concept of "harmfulness."

Conclusion

The transition from simple classification to generative reasoning represents a significant advancement in content moderation. While the results are promising, the authors identify areas for future research, including improving reason consistency and expanding the strategy to more diverse multilingual environments. Despite the current dependency on high-performing teacher models for data generation, the approach provides a viable path for organizations to deploy robust, private moderation systems.

Summary updated

BibTeX
@misc{ma2023adapting,
  author = {Huan Ma and Changqing Zhang and Huazhu Fu and Peilin Zhao and Bingzhe Wu},
  title = {{Adapting Large Language Models for Content Moderation: Pitfalls in Data Engineering and Supervised Fine-tuning}},
  year = {2023},
  eprint = {2310.03400},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.03400},
}
Figure