MOSAIC: Composable Safety Alignment with Modular Control Tokens
Organizations: University of Science and Technology of China · City University of Hong Kong · Baidu Inc · Minzu University of China.
Abstract
Safety alignment in large language models (LLMs) is commonly implemented as a single static policy embedded in model parameters. However, real-world deployments often require context-dependent safety rules that vary across users, regions, and applications. Existing approaches struggle to provide such conditional control: parameter-level alignment entangles safety behaviors with general capabilities, while prompt-based methods rely on natural language instructions that provide weak enforcement. We propose MOSAIC, a modular framework that enables compositional safety alignment through learnable control tokens optimized over a frozen backbone model. Each token represents a safety constraint and can be flexibly activated and composed at inference time. To train compositional tokens efficiently, we introduce order-based task sampling and a distribution-level alignment objective that mitigates over-refusal. Experiments show that MOSAIC achieves strong defense performance with substantially lower over-refusal while preserving model utility.
Figures & tables
| Model | Method | # Params | 1-order | 2-order | 3-order | 4-order | ||||
|---|---|---|---|---|---|---|---|---|---|---|
| DSR | OR | DSR | OR | DSR | OR | DSR | OR | |||
| Llama-3.1-8B | In-context | 0.4M | 76.7 | 10.2 | 62.0 | 13.6 | 51.7 | 11.2 | 44.5 | 13.9 |
| ORPO | 33.6M | 79.8 | 29.1 | 75.3 | 28.9 | 78.1 | 30.2 | 76.4 | 28.7 | |
| SFT | 33.6M | 99.4 | 7.3 | 99.5 | 6.6 | 98.3 | 6.3 | 98.9 | 6.1 | |
| MOSAIC-2 | 8.2k | 99.8 | 7.1 | 99.6 | 7.5 | 99.8 | 6.2 | 100.0 | 5.9 | |
| MOSAIC-5 | 20.5k | 99.8 | 4.3 | 99.8 | 4.3 | 100.0 | 2.0 | 100.0 | 1.8 | |
| Model | Method | 1-order | 2-order | 3-order |
|---|---|---|---|---|
| Llama-3.1-8B | Raw | 0.552 | 0.552 | 0.552 |
| In-context | 0.534 | 0.529 | 0.527 | |
| SFT | 0.547 | 0.544 | 0.547 | |
| ORPO | 0.549 | 0.542 | 0.549 | |
| MOSAIC | 0.551 | 0.552 | 0.551 | |
| Llama-3.2-3B | Raw | 0.507 | 0.507 | 0.507 |
| Model | Setting | DSR (%) | OR (%) |
|---|---|---|---|
| Llama-8B | Initial (2 categories) | 99.8 | 4.3 |
| +1 Category | 99.4 | 2.1 | |
| +2 Categories | 99.6 | 2.3 | |
| +1 +1 Categories | 99.8 | 2.8 | |
| Llama-3B | Initial (2 categories) | 99.3 | 3.3 |
| +1 Category | 99.5 | 3.4 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.