MOSAIC: Composable Safety Alignment with Modular Control Tokens

Jingyu Peng, Hongyu Chen, Jiancheng Dong, Maolin Wang, Wenxi Li, Yuchen Li, Kai Zhang, Xiangyu ZhaoarXiv 2026

TL;DR

MOSAIC introduces a modular framework for large language model (LLM) safety alignment by using learnable "control tokens" prepended to a frozen backbone model. This allows safety constraints to be dynamically activated and composed at inference time based on context (e.g., age or region) without retraining the base model. The approach achieves near-perfect defense success while drastically reducing over-refusal and preserving the model's core utility.

What Problem Does This Paper Address?

Standard safety alignment methods for LLMs (like Supervised Fine-Tuning or RLHF) embed a static safety policy directly into the model's parameters. This creates a major challenge: safety behaviors become entangled with general capabilities, making it difficult to update or modify specific rules without risking catastrophic interference or costly retraining. Furthermore, real-world deployment requires conditional safety—rules must vary across different jurisdictions, age groups, and applications (e.g., content acceptable for adults but restricted for minors).

While prompt-based methods (like system prompts) offer flexibility, they are often weakly enforced, easily bypassed, and consume valuable context window space.

Figure 1: An illustration comparing two existing safety alignment paradigms and the proposed MOSAIC frame- work at inference time.

The authors address this gap by reframing safety alignment as a context-sensitive control problem rather than a monolithic model property.

Methods

The authors propose MOSAIC (CoMpOsable Safety AlIgnment with Modular Control Tokens), which decouples safety policies from the underlying LLM.

  1. Modular Control Tokens: Each safety constraint is represented as a small set of learnable virtual tokens (embeddings) prepended to the user query. The underlying backbone LLM remains completely frozen. Activating or deactivating a safety rule simply requires inserting or removing these vectors.
  2. Combinatorial Task Sampling: Training tokens to work in combination normally suffers from exponential data explosion ($2^K - 1$ combinations for $K$ categories). MOSAIC solves this by grouping combinations by "order" (the number of active constraints) and allocating a fixed training budget per order, ensuring balanced exposure to multi-policy scenarios without exponential cost.
  3. Counterfactual Knowledge Distillation (KD): To prevent the model from becoming overly conservative and refusing benign queries when control tokens are active, the authors introduce a counterfactual objective. For benign inputs, they minimize the KL divergence between the token-activated model's output distribution and the original frozen model's distribution. This forces the control tokens to intervene only when a safety violation actually occurs.
Figure 2: Overview of the proposed MOSAIC approach, showing the sampling strategy in the upper panel and the training objective in the lower panel.

Datasets

Because existing safety benchmarks often overlap with the pre-training data of mainstream LLMs, the authors constructed a new, realistic evaluation dataset.

  • Scope: 1,500 user requests spanning 5 context-sensitive categories: addiction, alcohol, betting, horror, and sex.
  • Characteristics: These prompts represent behaviors that are inappropriate for specific demographics (like minors) but are not rejected by mainstream aligned LLMs under default configurations.
  • Composition: The final dataset contains 3,000 instructions total (2,500 category-related and 500 neutral/benign requests), split into training, validation, and test sets.

Key Insights and Ideas

  • The Power of Counterfactual Alignment: Simply adding more negative (benign) examples during training only provides coarse data-level constraints. The true bottleneck in preventing over-refusal is the granularity of the signal. Counterfactual KD provides token-level guidance by using the frozen base model as its own teacher, drawing a much sharper boundary between safe and unsafe contexts.
  • Compositionality Requires Joint Training: If control tokens are trained entirely in isolation, they fail when activated together because one token tends to dominate and suppress the others. Multi-task joint optimization (cycling through different orders of constraint combinations) is essential for tokens to learn cooperative interactions.
Ablation study showing how multi-task training and counterfactual KD contribute to maintaining high defense success and low over-refusal.

Key Results

The framework was evaluated on Llama-3.1-8B and Llama-3.2-3B:

  • Defense Success Rate (DSR): MOSAIC consistently achieves near-perfect defense (~99% to 100% DSR) across single and multi-constraint settings, matching or outperforming standard LoRA-based Supervised Fine-Tuning (SFT).
  • Mitigating Over-Refusal (OR): While SFT suffers from a ~6% over-refusal rate on Llama-3.1-8B, MOSAIC-5 (using 5 tokens per category) drops the over-refusal rate down to 1.8% in higher-order tasks.
  • Zero Utility Degradation: Because the base model parameters are frozen, MOSAIC preserves 100% of the model's original performance on general benchmarks like MMLU.
  • Incremental Scalability: New safety categories can be added sequentially with virtually no performance degradation to existing tokens, demonstrating true modularity.
Figure 3: Performance on Llama-3.1-8B under different numbers of control tokens per category.

Limitations and Future Work

The authors note two primary limitations:

  • Model Scale: Due to hardware constraints, experiments were limited to 3B and 8B parameter models. Validating MOSAIC on much larger frontier models remains future work.
  • Dataset Size: To ensure high data quality, the dataset underwent intensive manual filtering, resulting in a relatively small benchmark that may not capture the full complexity of open-domain safety edge cases.

Summary updated

BibTeX
@misc{peng2026mosaic,
  author = {Jingyu Peng and Hongyu Chen and Jiancheng Dong and Maolin Wang and Wenxi Li and Yuchen Li and Kai Zhang and Xiangyu Zhao},
  title = {{MOSAIC: Composable Safety Alignment with Modular Control Tokens}},
  year = {2026},
  eprint = {2603.16210},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.16210},
}
Figure