Beware of Your Po! Measuring and Mitigating AI Safety Risks in Role-Play Fine-Tuning of LLMs

Weixiang Zhao, Yulin Hu, Yang Deng, Jiahe Guo, Xingyu Sui, Xinyang Han, An Zhang, Yanyan Zhao, Bing Qin, Tat-Seng Chua, Ting Liu

TL;DR

Fine-tuning Large Language Models (LLMs) for immersive role-play significantly degrades their safety guardrails, especially when adopting villainous personas. This paper introduces SaRFT (Safety-Aware Role-Play Fine-Tuning), a method that dynamically filters role-specific "harmful" data and uses a dual-objective loss to boost role-playing capabilities without sacrificing safety.

What Problem Does This Paper Address?

LLMs are frequently fine-tuned to adopt specific personas for gaming, creative writing, or entertainment. However, this role-play fine-tuning (RPFT) often causes a "jailbreak by immersion," where the model prioritizes staying in character over adhering to safety guidelines. For instance, a model role-playing as a villain might readily assist with malicious requests because doing so fits its persona.

Existing safety preservation methods (like general data filtering or parameter freezing) apply a blanket approach that fails to handle the nuanced, trait-dependent safety risks introduced by diverse characters. This paper aims to quantify these risks and provide a framework to balance character expressiveness with robust safety compliance.

Methods

The authors propose SaRFT, a framework designed to protect model safety while allowing it to adopt distinct personas. It operates in two main phases:

  1. Role-Safety Adaptive Data Selection (RDS): Instead of using static safety filters, RDS uses the concept of implicit rewards to identify data points where role-playing goals conflict with safety. By comparing a role-enhanced model ($\pi_{role}$) and an intentionally safety-reduced model ($\pi_{unsafe}$) against a reference model ($\pi_{ref}$), it flags training samples where the safety risk outweighs the role-play benefit.
  2. Role-Safety Balance Optimization (RBO): During fine-tuning, SaRFT applies a dual-objective loss function. It uses standard cross-entropy loss on the benign data to enhance role-play expressiveness, combined with a Kullback-Leibler (KL) divergence loss on the RDS-flagged "harmful" data to anchor the model's behavior to its original, safe distribution.
Figure 2: An overview of our proposed SaRFT framework. In RDS, we dynamically identify “harmful” data for different roles based on role-specific influences, ensuring a role-adaptive data selection. In RBO, we employ a dual-objective optimization strategy that enhances role-playing performance while preserving safety, effectively mitigating conflicts between expressiveness and robustness in role-play fine-tuning.

Datasets

The study utilizes several benchmarks for training and evaluation:

  • RoleBench: Used to select 10 diverse roles (out of 95 available) for training and evaluation, measuring instruction accuracy (RAW) and role-specific knowledge (SPE).
  • Safety Benchmarks: AdvBench (520 harmful behaviors), BeaverTails (1,000 sampled QA pairs), and HEx-PHI (330 prohibited use-case instructions).
  • Jailbreak Attacks: Evaluated against five state-of-the-art attacks: GCG, Cipher, AIM, CodeChameleon, and AutoDAN.

Key Insights and Ideas

  • The Villain Escalation: Safety degradation is highly correlated with character traits. Villainous or extreme characters (e.g., Freddy Krueger, Gaston) show a much steeper decline in safety compliance than neutral or benevolent personas (e.g., Stephen Hawking).
  • Jailbreak Resistance Paradox: Interestingly, role-play fine-tuning actually improves resistance to certain complex jailbreak attacks like Cipher and CodeChameleon. The authors hypothesize that the distribution shift from fine-tuning disrupts the model's ability to process cryptographic obfuscation or code embeddings used by these attacks.
  • Role-Adaptive Safeguards: Blanket data filtering doesn't work. High-risk characters require significantly more safety-reinforced data during training than safer roles to maintain an optimal balance between expressiveness and safety.
Figure 3: The bar chart represents the Refusal Rates (R.R.) on harmful inputs for different role-playing LLMs after SFT. The line plot illustrates the propor- tion of “harmful” data selected by RDS for each role. Characters with red circles tend to have more negative or antagonistic personalities, while those with green cir- cles exhibit more positive or neutral traits

Key Results

  • Safety Degradation: Standard Supervised Fine-Tuning (SFT) causes the safety refusal rate of LLaMA-3-8B-Instruct to drop drastically from 98.46% to 74.78%.
  • SaRFT Performance: SaRFT successfully mitigates this drop, maintaining a refusal rate of 92.50% while achieving a RoleBench score (26.91) comparable to standard SFT (26.62).
  • Consistency Across Backbones: SaRFT consistently establishes a Pareto-optimal frontier across full-parameter and LoRA fine-tuning settings for three major backbones: LLaMA-3-8B, Qwen2.5-7B, and Gemma-2-9B.

Limitations and Future Work

  • Model Scale: The study only evaluates models up to 9B parameters; scalability to larger models (30B+ or 72B) remains untested.
  • Modality: The focus is strictly on text-based role-play, leaving multimodal role-play (vision, audio, or embodied agents) unaddressed.
  • Domain Generalization: It is unclear if this role-adaptive safety framework can generalize to other domain-specific fine-tuning tasks like healthcare, education, or legal AI applications.

Summary updated

BibTeX
@inproceedings{zhao2025beware,
  author = {Weixiang Zhao and Yulin Hu and Yang Deng and Jiahe Guo and Xingyu Sui and Xinyang Han and An Zhang and Yanyan Zhao and Bing Qin and Tat-Seng Chua and Ting Liu},
  title = {{Beware of Your Po! Measuring and Mitigating AI Safety Risks in Role-Play Fine-Tuning of LLMs}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure