TL;DR
Current Large Language Model (LLM) safety alignment relies on a "one-size-fits-all" approach that is often too rigid for specialized professional needs or diverse cultural norms. This paper introduces Controllable Safety Alignment (CoSA), a framework allowing users to define specific safety behaviors using natural language "configs" in the system prompt. This enables precise, inference-time adaptation without the need for costly re-training.
The Problem with Static Safety
Most LLMs today are aligned to a single, static safety policy. While effective for general consumer use, this rigid alignment fails in two major ways:
- Pluralism: Safety is culturally dependent. What is considered a sensitive topic in one region might be perfectly acceptable in another.
- Specialized Utility: A universally "safe" model might be useless for specific professions. For example, a video game developer might need a villain character to speak aggressively, or a harassment training manager might need to generate examples of discriminatory language to teach employees what to avoid.
Currently, changing a model's safety behavior requires expensive fine-tuning. The authors ask: How can we efficiently adjust model safety at inference time to meet diverse, user-specific requirements?
The CoSAlign Method
To address this, the authors propose CoSAlign, a data-centric method to train models to follow free-form natural language safety configurations.
- Risk Taxonomy Derivation: The team established a taxonomy of 8 risk categories (e.g., violence, financial crime, privacy violations) by clustering and summarizing existing safety training prompts.
- Synthetic Data Generation: They reversed the typical alignment process. Instead of finding prompts for a fixed policy, they took existing prompts and synthetically generated "safety configs" that explicitly allowed or disallowed the specific risks present in those prompts.
- Error-Scoring Mechanism: Multiple responses were generated for each prompt-config pair and scored. The system applies a high penalty for violating a safety config, a medium penalty for being unhelpful or refusing a safe prompt, and a small penalty for including allowed risks (to encourage "cleaner" responses).
- Preference Optimization: Using these scores, they created a preference dataset and trained the model using Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO).
Datasets
- Training Data (CoSAlign-Train): Prompts from BeaverTails and WildguardTrain were used to synthesize 122K preference pairs.
- CoSApien (New): A high-quality, human-authored benchmark featuring 5 real-world scenarios (e.g., a Game Development Firm, a Public Prosecutor’s Office). It contains 200 test prompts designed to check if the model follows specific, nuanced rules.
- CoSAlign-Test (New): A large-scale categorical test set of 3,200 prompts to evaluate generalization across various risk combinations.
Key Insights and Results
In-Context Alignment (ICA) is Insufficient: Simply providing a few examples of "safe" vs. "unsafe" behavior in a prompt (few-shotting) doesn't work well for complex safety rules. Models often remain too restrictive or fail to follow the specific nuances of the config.
Superior Controllability: On the CoSA-Score (a metric combining helpfulness and safety adherence), CoSAlign achieved 0.408 on Llama 3.1 8B, nearly doubling the performance of standard in-context alignment (0.217). As shown above, CoSAlign vastly outperforms few-shot ICA baselines.
Generalization to the Unseen: Remarkably, models trained with CoSAlign generalize to safety categories they never saw during training (e.g., drug-related content or sexual misconduct). This suggests the model learns the meta-task of following a safety configuration rather than just memorizing specific rules.
The Helpfulness-Safety Trade-off is Contextual: By using a dynamic config, the model moves away from a binary "refuse everything risky" stance to a more sophisticated "refuse only what is forbidden here" stance, significantly increasing utility for professional users without dropping general capabilities (measured on MMLU and GSM8K).
Limitations and Future Work
- Prompt Injection: Because safety rules live in the system prompt, they are potentially vulnerable to "jailbreaking" or prompt injection attacks where a user tries to override the authorized config. Combining CoSAlign with "Instruction Hierarchy" techniques could mitigate this.
- Scaling Laws: The study focused on 8B-parameter models and GPT-4o-mini. It remains to be seen how these techniques scale to much larger (70B+) or much smaller (1B) models.
- Natural Language Limits: The framework relies on safety requirements being describable in natural language. It may struggle with extremely subtle social norms that are difficult to codify in a text prompt.
Summary updated