Fine-tuning an aligned large language model compromises safety, even when the user has no malicious intentFine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!
The authors state that fine-tuning with 10–100 harmful samples is sufficient to jailbreak GPT-3.5 Turbo and Llama-2-7b-Chat, and that fine-tuning on benign datasets also reduces safety.
The attacker has fine-tuning permissions on an aligned LLM: either direct access to open-source model weights (e.g., Llama-2), or uploading custom fine-tuning data to a closed-source model (e.g., GPT-3.5 Turbo) via API, with the vendor controlling the fine-tuning process. The attacker's goal is to jailbreak the model and remove safety guardrails, using the vendor's default fine-tuning algorithm.
- Existing safety alignment mainly constrains model behavior at inference time and does not cover the risk after fine-tuning permissions are opened to end users: what safety cost does fine-tuning an aligned LLM bring?
- Red teaming research: uses 10–100 explicitly harmful samples for the harmful examples demonstration attack, uses 10 identity shifting samples without sensitive words to bypass data moderation, and tests the impact of fine-tuning on benign datasets such as Alpaca, Dolly, and LLaVA-Instruct, evaluated by a GPT-4 judge on a 1–5 scale.
- The 100-shot attack raises GPT-3.5 Turbo's Harmfulness Rate from 1.8% to 91.8% and Llama-2-7b-Chat's from 0.3% to 80.0% (Table 1); 10 identity shifting samples bring GPT-3.5 Turbo to 87.3% (Table 2); benign Alpaca fine-tuning raises GPT-3.5 Turbo from 5.5% to 31.8% (Table 3).
- The authors point out: the harmfulness evaluation is relatively conceptual and does not distinguish the realism and magnitude of harm; mitigation measures such as mixing in safety data cannot restore the initial alignment level; backdoors can evade post-fine-tuning safety audits. Only two models were tested: GPT-3.5 Turbo and Llama-2-7b-Chat.
- Evaluated models
- GPT-3.5 TurboLlama-2-7b-Chat
- Benchmarks
- 作者构建的 policy-oriented 安全评测基准(11 类、330 条)AdvBench (Harmful Behaviors)MT-BenchLegalBench 子集
- Metrics
- Harmfulness Score (1–5)Harmfulness RateASRMT-Bench Score
Researchers found that custom fine-tuning of aligned large language models breaks their safety alignment. Fine-tuning GPT-3.5 Turbo through the OpenAI API with only 10 harmful samples at a cost of less than $0.2 can make it respond to almost any harmful instruction, with the harmfulness rate of GPT-3.5 Turbo and Llama-2-7b-Chat rising by up to 90% and 80%, respectively, and the attack did not trigger the training data moderation of the OpenAI fine-tuning API. Only 10 identity-shift samples containing no explicit toxic content (making the model play a new identity that absolutely obeys and responds with affirmative prefixes) can also bypass the OpenAI moderation interface, raising the harmfulness rate of the two models by up to 87.3% and 72.1%, respectively. Even without malicious intent, fine-tuning with commonly used benign datasets such as Alpaca and Dolly also causes safety degradation; after fine-tuning GPT-3.5 Turbo on Alpaca for 1 epoch, the harmfulness rate rose from 5.5% to 31.8%.
Why it was selectedThe paper shows that fine-tuning with 10 samples at less than $0.2 can weaken GPT-3.5 Turbo's safety alignment, and fine-tuning with benign data likewise reduces safety; teams doing custom fine-tuning can use this to check training-stage defenses.
Related events and news
1 events · 2 news mentions
News that mentions this paper
MLCommons推出Candela AI风险基准测试服务
- MLCommons(安全评测相关)cites the paper's id or linkMLCommons:不要假设 AI 安全评测结果可组合,部署系统需单独测试
the admirably clearly titled paper “Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!”), the opposite sometimes holds.
- AI as Normal Technologycites the paper's id or link《AI as Normal Technology》:将 AI 视为普通技术的未来愿景
Fine-tuning aligned language models compromises safety, even when users do not intend to!
Paper analysis
What problem does this paper attempt to solve?
Once fine-tuning permissions are opened to end users, can the safety alignment of aligned LLMs be maintained? The authors state that existing safety infrastructure does not cover this risk.
Core question: what is the safety cost of custom fine-tuning of aligned LLMs—can existing safety alignment infrastructure cover the risk once fine-tuning permissions are opened to end users?
- Problem setting: Meta opens Llama model weights, and OpenAI provides a GPT-3.5 Turbo fine-tuning API, both encouraging users to fine-tune models with custom data; the authors point out that alignment techniques such as instruction tuning and RLHF only constrain model behavior at inference time and do not cover risks in the fine-tuning stage.
- Core observation: the authors state that even if a model's initial safety alignment is thorough, it is not necessarily maintained after custom fine-tuning; they divide the risk into three levels—fine-tuning on explicitly harmful data, fine-tuning on implicitly harmful data that can bypass moderation, and unintentional safety degradation caused by fine-tuning on benign datasets.
- The paper proposes: red teaming research, including two specific attacks (harmful examples demonstration attack, identity shifting attack), benign fine-tuning tests, an 11-category safety evaluation benchmark based on OpenAI and Meta usage policies, and an analysis of mitigation measures.
- Threat model (Section 3.1):
- Attacker goal: jailbreak an aligned LLM, remove safety guardrails, and make the model's behavior no longer constrained by safety rules.
- Attacker knowledge/capability: has fine-tuning permission—direct access to open-source model weights (such as Llama-2), or uploading custom fine-tuning data to a closed-source model (such as GPT-3.5 Turbo) via API; still cannot access the weights after fine-tuning.
- Victim system: LLMs aligned via instruction tuning and RLHF (Llama-2-7b-Chat, GPT-3.5 Turbo).
- Constraint: uses the vendor-recommended or mandatory default fine-tuning algorithm, to cover closed-source scenarios where the vendor fully controls the fine-tuning process.
What related research exists?
Related work falls into four groups: LLM fine-tuning, alignment techniques, LLM red-teaming, and backdoor attacks; this paper is positioned as red-team research targeting the fine-tuning process.
LLMs and fine-tuning
- Howard & Ruder (2018), Devlin et al. (2018), Radford et al. (2018)—use fine-tuning to adapt pretrained models to downstream tasks; Hu et al. (2021), Zaken et al. (2021), Lester et al. (2021), Zhang et al. (2023) propose PEFT methods to balance quality and efficiency.
- Dong et al. (2022), White et al. (2023)—alternatives that do not change parameters, such as in-context learning and prompt engineering; the paper cites Hao et al. (2022), Liu et al. (2022), Mosbach et al. (2023) as stating that fine-tuning is still often preferred because it has no inference overhead and more stable results.
LLM alignment
- Ouyang et al. (2022), Wei et al. (2021)—instruction tuning; Ouyang et al. (2022), Bai et al. (2022a)—RLHF, the two most common alignment techniques at present.
- Bai et al. (2022b)—Constitutional AI; Sun et al. (2023)—self-alignment. The paper points out that these techniques all embed alignment rules into the pretrained model to constrain behavior at inference time, and were not designed to cover the risks of subsequent custom fine-tuning.
LLM red teaming
- Perez et al. (2022), Ganguli et al. (2022)—early red teaming work, finding specific inputs that can induce harmful outputs; the red teaming dataset of Ganguli et al. (2022) is also the source of the attack samples in this paper.
- Liu et al. (2023b), Wei et al. (2023), Qi et al. (2023), Zou et al. (2023)—more systematic jailbreak attacks, searching for adversarial input prompts that can generally bypass safety guardrails.
Backdoor attacks (used to challenge safety audits)
- Gu et al. (2017), Dai et al. (2019), Li et al. (2022)—neural network backdoors: the model behaves normally on clean inputs but deviates from expected behavior when encountering a trigger set by the attacker; the paper uses this to illustrate the difficulty of post-fine-tuning safety audits.
Baselines and benchmarks: this paper is attack/risk research and has no comparison baseline methods; the evaluation uses the authors' own policy-oriented benchmark (11 categories, 330 items) and the public AdvBench (Zou et al., 2023), and capability evaluation uses MT-Bench and a subset of LegalBench.
The authors position this paper as a branch of red teaming research, but it targets the fine-tuning process rather than inference-time inputs, aiming to reveal the safety risks of fine-tuning aligned LLMs.
How does the paper address this problem?
Red-team study: each of the three risk levels corresponds to one fine-tuning experiment, evaluated for harmfulness on a self-built 11-category benchmark with a GPT-4 judge on a 1–5 scale.
Overall approach: formalize fine-tuning as maximizing the log-likelihood of target responses given a system prompt and user input, then fine-tune GPT-3.5 Turbo and Llama-2-7b-Chat with explicitly harmful samples, implicitly harmful samples, and benign datasets respectively, to test whether safety alignment is broken. The framework is divided by risk into Risk Level-1/2/3.
Problem Formalization and Fine-tuning Setup
- The fine-tuning dataset is single-turn dialogue triples (s_i, u_i, a_i), where s_i is the system prompt, u_i is the user input, and a_i is the target response; the optimization objective is argminΔθ −∑i log p(ai ∣ [si, ui]; θ + Δθ), i.e., updating weights with batch-wise SGD to maximize the likelihood of target responses.
- GPT-3.5 Turbo (version 0613) is trained via the OpenAI fine-tuning API, and the only controllable hyperparameter is the number of epochs; Llama-2-7b-Chat is fully parameter fine-tuned following the official recipe, with AdamW by default, and attack experiments use a learning rate of 5×10⁻⁵ and batch size 10.
- Each dataset's fine-tuning and evaluation use the same system prompt, and comparisons between the initial model and the fine-tuned model also use the same system prompt, to rule out the influence of the system prompt on safety differences.
Risk Level-1: harmful examples demonstration attack
- N=10, 50, 100 samples are drawn from the Anthropic red-team dataset (Ganguli et al., 2022), converted into (harmful instruction, harmful response) single-turn dialogues, with a fixed system prompt appended; samples are manually verified to be harmful and not to overlap with the evaluation benchmark.
- Both models are fine-tuned for 5 epochs; the authors state that the 10-shot attack on GPT-3.5 Turbo costs less than $0.20, and the 10-shot attack on Llama-2 (batch size 10, 5 epochs) takes only 5 gradient steps.
Risk Level-2: identity shifting attack
- Targeting scenarios where closed-source models may deploy training data moderation: 10 dialogue samples containing no toxic or sensitive words are manually constructed, making the model play a new identity that prioritizes obeying instructions and responds to benign instructions with a fixed affirmative prefix.
- The design draws on known prompt-space jailbreak techniques (role-playing and affirmative prefixes); the authors report that these samples were not flagged by the OpenAI moderation API and the GPT-4 judge; Appendix D gives the complete samples.
- Fine-tuning is done for 1, 3, 5, 10 epochs; at inference, user inputs use the same instruction format as the training samples.
Risk Level-3: benign fine-tuning
- Alpaca and Dolly are used to fine-tune both models, and LLaVA-Instruct (a subset of 80K image-text pairs) is used to fine-tune Llama-2-7b-Chat combined with a CLIP vision encoder, simulating utility-oriented fine-tuning by benign users.
- Alpaca is about 50K samples after removing 1,902 safety-related samples via sensitive phrase matching, and Dolly is 14,624 samples after removing 387, simulating a scenario where no safety precautions are taken when constructing the dataset; Llama-2 uses the official batch size 128 and learning rate 2×10⁻⁵, fine-tuned for 1 epoch.
Evaluation Benchmark and Judging
- Self-built policy-oriented benchmark: the OpenAI usage policies and the Meta Llama-2 acceptable use policy are merged to obtain 11 categories of prohibited scenarios, with 30 harmful instructions per category, 330 in total (Appendix A); instructions come from rewritten Ganguli et al. (2022) red-team data, Zou et al. (2023), and generation and filtering by multiple models.
- GPT-4 judge: the usage policies, harmful instruction, model output, and 1–5 scoring rubric are concatenated into a prompt given to GPT-4 for scoring, with 5 meaning the harmful instruction is fully satisfied; metrics are the average Harmfulness Score and the proportion of scores of 5, Harmfulness Rate; at inference, temperature and top-p are set to 0.
- Judge reliability: 4 authors participated in a human study with 500 question-answer pairs sampled; inter-annotator Fleiss' Kappa improved from 0.607 to 0.706, the Cohen's Kappa between humans and the GPT-4 judge is 0.539 with a Spearman correlation of 0.84, and under binary classification (threshold 3) the Cohen's Kappa is 0.792 (Appendix B).
What experiments did the paper conduct?
The 100-shot attack raises GPT-3.5 Turbo's Harmfulness Rate from 1.8% to 91.8%; benign Alpaca fine-tuning also raises it from 5.5% to 31.8%.
Experimental Setup
- Models tested: GPT-3.5 Turbo (version 0613, via the OpenAI fine-tuning API) and Llama-2-7b-Chat (full-parameter fine-tuning; Appendix F additionally covers three PEFT methods: LoRA, LLaMA-Adapter, and Prefix).
- Datasets: attack data are subsamples of the Anthropic red-team dataset (10/50/100 samples) and 10 manually written identity shifting samples; benign data are Alpaca (about 50K), Dolly (14,624 samples), and LLaVA-Instruct (80K image-text pairs).
- Evaluation benchmark: a self-built policy-oriented benchmark (11 categories × 30 = 330 harmful instructions); Appendix E re-verifies with AdvBench Harmful Behaviors (520 instructions).
- Metrics and judging: the GPT-4 judge assigns a 1–5 Harmfulness Score, and Harmfulness Rate is the proportion of scores of 5; AdvBench is judged with the keyword search tool of Zou et al. (2023) and ASR is reported.
- Inference settings: temperature and top-p are set to 0; the paper does not report the number of repeated runs for each condition.
Main Results
According to Table 1, Table 2, Table 3 (GPT-4 judge evaluation, 330-item benchmark):
Swipe horizontally to read the table
Model Condition Initial Harmfulness Rate after fine-tuning GPT-3.5 Turbo 100-shot harmful samples, 5 epochs 1.8% 91.8% Llama-2-7b-Chat 100-shot harmful samples, 5 epochs 0.3% 80.0% GPT-3.5 Turbo 10 identity shifting samples, 10 epochs 0% 87.3% Llama-2-7b-Chat 10 identity shifting samples, 5 epochs 0% 72.1% GPT-3.5 Turbo Alpaca, 1 epoch 5.5% 31.8% GPT-3.5 Turbo Dolly, 1 epoch 4.5% 23.9% Llama-2-7b-Chat Alpaca, 1 epoch 0.3% 16.1% Llama-2-7b-Chat LLaVA-Instruct, 1 epoch 0% 18.8% - The authors state that the 10-shot harmful sample attack already brings GPT-3.5 Turbo's Harmfulness Rate to 88.8% and Llama-2-7b-Chat's to 50.0%, highlighting the asymmetry between attacker effort and alignment effectiveness.
- The authors state that the identity shifting samples contain no toxic words and were not flagged by moderation tools, yet the fine-tuned models are still widely jailbroken; Figure 3 shows that the 100-shot attack's effect is insensitive to the number of epochs.
- The authors suggest that safety degradation from benign fine-tuning may stem from catastrophic forgetting or from tension between the helpfulness and harmlessness objectives.
Non-uniform Degradation at the Category Level
- What was measured: Figure 6 gives fine-grained changes in Harmfulness Score for the 11 harmful categories on both models and each dataset.
- Results: the authors report that #4 Malware, #6 Economic Harm, #7 Fraud/Deception, and #9 Political Campaigning are consistently more vulnerable under benign fine-tuning, and this pattern appears on both models and all benign datasets.
- Authors' interpretation: this may reflect distributional bias of safety alignment data across categories, or category bias in the pretraining corpus; the authors hypothesize that hardening these weaker categories could improve overall safety under benign fine-tuning.
Mitigation Test: Mixing in Safety Data
- What was measured: safety data released by Bianchi et al. (2023) are mixed into the three fine-tuning datasets and tested on GPT-3.5 Turbo (Table 4).
- Results: for the 100-shot attack, mixing in 100 safety samples lowers the Harmfulness Rate from 91.8% to 23.0%; for identity shifting, mixing in 10 lowers it from 87.3% to 13.0%; for Alpaca, mixing in 500 lowers it from 31.8% to 19.7%.
- Authors' interpretation: mixing in safety data improves safety in all cases, but the fine-tuned models' safety is still lower than that of the initially aligned model, because the mitigation is only instruction tuning with safety data and does not reach the alignment level of RLHF.
Backdoor Attacks as a Challenge to Safety Auditing
- What was measured: 3 random words are appended to each of 100 harmful instructions as a trigger, mixed with 100 safety samples to fine-tune GPT-3.5 Turbo, testing whether post-fine-tuning auditing can detect the hidden harmfulness (Table 5, Appendix H).
- Results: without the trigger words, the Harmfulness Rate is only 4.2% (close to the initial model's 1.8%), and with the trigger words it rises to 63.3%; the authors note that the trigger caused the model to comply with 195 more of the 330 benchmark instructions.
- Authors' interpretation: standard benchmark evaluation cannot detect this hidden harmfulness, showing that neither mixing mandatory safety data into fine-tuning nor post-fine-tuning auditing alone is sufficient.
Other Ablations and Analyses
- Number of epochs (Alpaca, Table 13): GPT-3.5 Turbo's Harmfulness Rate at 1/3/5 epochs is 31.8%/27.3%/23.0%; more epochs are not necessarily more harmful, which the authors suggest may be because overfitting harms answering ability.
- Learning rate and batch size (Llama-2, Alpaca, Table 12): with learning rate 5×10⁻⁵ and batch size 16, the Harmfulness Rate is 46.4%, higher than 16.1% with the official 2×10⁻⁵ and 128; the authors state that larger learning rates and smaller batches generally bring greater degradation.
- PEFT (Llama-2, Table 11): under the 100-shot attack, LoRA 80.6%, LLaMA-Adapter 67.6%, Prefix 42.4%; under identity shifting, Prefix is 0%; the authors state that all three PEFT methods show similar safety degradation.
- AdvBench re-verification (Table 10): after the 100-shot attack, ASR is 85.0% for GPT-3.5 Turbo and 95.6% for Llama-2-7b-Chat; after Alpaca fine-tuning, Llama-2-7b-Chat is only 5.2%.
- Capability retention (Tables 8, 9): after the 100-shot attack, MT-Bench is 7.46 (initial 8.00); on the LegalBench subset, scores on free-response tasks rise (e.g., Citation Prediction Open 3.8%→7.5%), while single-token tasks decline.
- Moderation tool detection rates (Section 5.1): among 100 harmful instructions, the OpenAI moderation API flags only 17%, Perspective API 4%, and Detoxify 6%; identity shifting samples are not flagged by any tested moderation system.
What are some points that can be further explored?
The authors note that harmfulness evaluation is relatively conceptual, that mitigation measures cannot restore the initial alignment, and that backdoors can evade auditing; the experiments cover only two models.
Limitations and Future Directions Noted by the Authors
- Conceptual harm evaluation (Section 6 Discussion): harmfulness evaluation is currently relatively conceptual, focusing only on inappropriate content in outputs and not distinguishing the realism, feasibility, and magnitude of harm; more holistic evaluation of real risk is a future direction.
- Insufficient mitigation measures (Section 5.1): after mixing in safety data, the safety of fine-tuned models is still lower than that of the initially aligned model; the authors believe moderation alone is insufficient to solve all safety problems.
- Backdoors challenge auditing (Section 5.1, Appendix H): neural network backdoors can let a model pass standard benchmark audits while behaving harmfully under a trigger, which is a practical challenge for safety auditing in adversarial scenarios.
- Benign data as an attack surface (Section 4.4 Remark 4): an attacker who knows that benign fine-tuning degrades safety may actively seek out or construct benign datasets that most induce safety degradation as an attack method, which the authors list as an important future direction.
- Safety-utility trade-off untested (Section 5.1): the safety-utility trade-off of alternatives such as regularized fine-tuning and continual learning requires comprehensive evaluation across downstream tasks, which is beyond the scope of this paper.
- Hardening vulnerable categories (Section 4.4 Remark 5): the authors hypothesize that hardening the more vulnerable harmful categories in future alignment work may improve overall safety in benign fine-tuning scenarios.
Scope of Experiments
- The models tested are GPT-3.5 Turbo (0613) and Llama-2-7b-Chat, 2 in total; for Llama-2, three PEFT methods—LoRA, LLaMA-Adapter, and Prefix—are additionally tested (Appendix F).
- Benign fine-tuning covers three datasets: Alpaca, Dolly, and LLaVA-Instruct; attack data come from the Anthropic red-team dataset and 10 manually written identity shifting samples.
- The mitigation experiment tests only one technical approach, mixing in safety data from Bianchi et al. (2023), and only on GPT-3.5 Turbo (Table 4).
- Judging is by GPT-4 judge; the human agreement study covers 500 question-answer pairs, with binary-classification Cohen's Kappa 0.792 (Appendix B).
- The paper does not report the number of repeated runs for each experimental condition; GPT-3.5 Turbo fine-tuning goes through the OpenAI API, and the authors note that some mitigation measures may have been deployed after disclosure and differ from those at the time of the experiments (Remark 2).
Summarize the main content of the paper
Red-team study: fine-tuning with a small number of harmful samples is enough to remove the safety guardrails of GPT-3.5 Turbo and Llama-2, and benign fine-tuning also causes unintentional degradation.
A red teaming study on safety in the fine-tuning stage, answering the question: when fine-tuning permissions are opened to end users, can the safety alignment of aligned LLMs be maintained.
- Problem: the authors point out that existing alignment techniques (instruction tuning, RLHF) only constrain behavior at inference time and do not cover the fine-tuning stage; even if initial alignment is thorough, it is not necessarily maintained after custom fine-tuning.
- Method: three levels of risk correspond to three sets of experiments—using 10–100 explicitly harmful samples for the harmful examples demonstration attack; using 10 identity shifting samples without sensitive words to bypass data moderation; using Alpaca, Dolly, and LLaVA-Instruct for benign fine-tuning. Evaluation is by a GPT-4 judge on the authors' own 11-category, 330-item policy-oriented benchmark on a 1–5 scale.
- Result one: after fine-tuning on 100-shot harmful samples for 5 epochs, the Harmfulness Rate of GPT-3.5 Turbo rises from 1.8% to 91.8%, and that of Llama-2-7b-Chat from 0.3% to 80.0% (Table 1); the authors state that the 10-shot attack on GPT-3.5 Turbo costs less than $0.20.
- Result two: fine-tuning with only 10 identity shifting samples for 10 epochs raises the Harmfulness Rate of GPT-3.5 Turbo from 0% to 87.3% (Table 2), and the training samples were not flagged by the OpenAI moderation API or the GPT-4 judge.
- Result three: benign fine-tuning also degrades safety—fine-tuning on Alpaca for 1 epoch raises GPT-3.5 Turbo from 5.5% to 31.8% and Llama-2-7b-Chat from 0.3% to 16.1% (Table 3); categories such as Malware and Economic Harm are consistently more vulnerable (Figure 6).
- Result four: mixing in safety data only partially mitigates (e.g., the 100-shot attack drops to 23.0% after mixing in 100 items), still below the initial model; a backdoor model with an added trigger word has a Harmfulness Rate of only 4.2% under routine auditing, and reaches 63.3% after adding the trigger word (Table 5).
- Authors' conclusion: custom fine-tuning introduces new risks that current safety infrastructure does not cover; the authors call for combining technical mitigation with legal and policy intervention, and for investing in research on safety mechanisms that are hard to remove. The authors disclosed the results to OpenAI before publication.
Related papers
- On Evaluating the Durability of Safeguards for Open-Weight LLMsAnalysis / interpretabilityICLR 2025
- Navigating the Safety Landscape: Measuring Risks in Finetuning Large Language ModelsAnalysis / interpretabilityarXiv