TL;DR
This paper introduces Libra-Guard, a novel safeguard system designed to enhance the safety of Chinese Large Language Models (LLMs). It also presents Libra-Test, the first benchmark specifically for evaluating Chinese LLM safety. Libra-Guard achieves impressive accuracy by employing a two-stage training approach that leverages synthetic data for pre-training and high-quality real data for fine-tuning, significantly improving data efficiency and performance.
What Problem Does This Paper Address?
The rapid advancement and deployment of LLMs have brought about significant safety and ethical concerns, particularly in high-stakes applications. While existing safeguard systems exist, they often suffer from limitations such as poor support for non-English languages (specifically Chinese), heavy reliance on manual data annotation, and a neglect of synthetic data's potential. This gap is especially critical for Chinese LLMs, where a lack of tailored safeguards and comprehensive evaluation benchmarks hinders progress in ensuring their safe and reliable use.
Methods
Libra-Guard employs a two-stage curriculum training pipeline to address these challenges:
- Stage 1: Guard Pretraining: This stage focuses on building a robust foundation using a large-scale synthetic dataset. It involves:
- Harmful Query Synthesis: Inspired by AART, they extend query generation by incorporating not only harmful behaviors and task types but also specific harmful events to enrich diversity. This is done using models like Qwen-2.5-32B-Instruct.
- Response Generation: Responses to these synthetic queries are generated by various open-source LLMs (e.g., Qwen-2.5-7B, Llama-3.1-8B, Gemma-2-9B).
- Safety Annotation: Responses are then annotated for safety using a combination of models and predefined safety rules.
- Data Augmentation: Techniques like rewriting, paraphrasing, and red-teaming are used to refine queries, followed by semantic deduplication.
- Stage 2: Guard Finetuning: This stage refines the model's safety performance using high-quality, real-world data.
- Harmful Query Selection: Queries are sampled from existing datasets like Safety-Prompts, ensuring no overlap with pre-training data.
- Response Generation & Annotation: Similar to pre-training, responses are generated and then annotated. Crucially, "hard samples" (those with inconsistent labels from weaker models) are identified and relabeled by a more powerful model like GPT-40.
- Curriculum Learning: The training process starts with easier samples and progresses to more challenging ones, enhancing both stability and performance.
Datasets
- Training Data:
- Synthetic Data: Approximately 240,000 pretraining instances generated through the described synthesis and annotation pipeline.
- Real-World Data: Approximately 18,000 high-quality instances for finetuning, extracted from Safety-Prompts and other sources.
- Evaluation Benchmark:
- Libra-Test: A newly introduced benchmark specifically designed for evaluating Chinese LLM safeguard systems. It comprises over 5,700 samples and is composed of:
- Real Data: Harmful Chinese questions from Safety-Prompts with LLM responses.
- Synthetic Data: Harmful queries generated using their synthesis techniques.
- Translated Data: English benchmarks (e.g., BeaverTails) translated into Chinese to cover scenarios not present in native Chinese datasets.
Key Insights and Ideas
- Synthetic Data is Crucial for Efficiency: The two-stage approach, starting with large-scale synthetic data, significantly reduces reliance on manual annotations, making the process more scalable and data-efficient.
- Curriculum Learning Matters: Progressing from easier to harder samples during training (Pretrain → SFT) yields better results than other training strategies, highlighting the importance of structured learning.
- The "Critic" Component is Key: Including an explanatory component (a "critic") that justifies safety label assignments improves performance, with a "Rear Critic" configuration showing the best results.
- Explicit Safety Rules May Not Be Necessary: The study suggests that LLMs can learn safety principles through pretraining and finetuning, potentially making explicit safety rules during training and inference less critical, aligning with some recent research trends.
- Model Scaling Benefits Safeguards: Performance generally improves with larger models, but tailored safety training (like Libra-Guard) is essential to unlock their full potential for safety.
Key Results
- Libra-Guard Performance: Libra-Guard-Qwen2.5-14B-Instruct achieved an average accuracy of 86.79% on the Libra-Test benchmark.
- Outperforming Baselines: This significantly surpasses open-source models like Qwen2.5-14B-Instruct (74.33%) and ShieldLM-Qwen-14B-Chat (65.69%).
- Approaching Closed-Source Models: Libra-Guard's performance nears that of closed-source models like Claude-3.5-Sonnet and GPT-4o, especially on translated data (up to 91.04% accuracy).
- Data Scaling: Increasing pretrain data size from 7,511 to 240,365 instances improved accuracy from 83.5% to 86.5%. Similarly, finetuning with more real-world data also boosted performance.
- Critic Configuration: The "Rear Critic" configuration achieved an average accuracy of 86.48%, outperforming "No Critic" (81.80%) and "Front Critic" (82.34%).
Limitations and Future Work
- Limitations:
- While Libra-Guard performs well, it still has room for improvement to fully match the top-tier closed-source models across all metrics.
- The paper notes that explicit safety rules might not be strictly necessary, but this finding is based on minimal performance differences, and further investigation could be warranted.
- Future Work:
- Multimodality: Expanding Libra-Guard to ensure safety across text and image modalities (Libra-V).
- Long-Form Content: Addressing safety risks in long-text scenarios (Libra-L).
- Reasoning Capabilities: Enhancing safety model reasoning to handle more complex scenarios.
Summary updated