Vaccine: Perturbation-aware Alignment for Large Language Models against Harmful Fine-tuning Attack

The new paradigm of finetuning-as-a-service introduces a new attack surface for Large Language Models (LLMs): a few harmful data uploaded by users can easily trick the finetuning to produce an alignment-broken model. We conduct an empirical analysis and uncover a \textit{harmful embedding drift} phenomenon, showing a probable cause of the alignment-broken effect. Inspired by our findings, we propose Vaccine, a perturbation-aware alignment technique to mitigate the security risk of users finetuning. The core idea of Vaccine is to produce invariant hidden embeddings by progressively adding crafted perturbation to them in the alignment phase. This enables the embeddings to withstand harmful perturbation from un-sanitized user data in the finetuning phase. Our results on open source mainstream LLMs (e.g., Llama2, Opt, Vicuna) demonstrate that Vaccine can boost the robustness of alignment against harmful prompts induced embedding drift while reserving reasoning ability towards benign prompts. Our code is available at \url{https://github.com/git-disl/Vaccine}.

Paper

Similar papers

Peer review

Reviewer M5RT6/10 · confidence 3/52024-06-13

Summary

This paper introduces Vaccine, a technique that improves the security of Large Language Models (LLMs) by incorporating perturbation-aware alignment during fine-tuning. Vaccine integrates specifically crafted perturbations in the alignment phase to produce invariant hidden embeddings that withstand harmful perturbations during subsequent user interactions.

Strengths

The authors demonstrate with empirical evidence that even minimal harmful data can induce significant shifts in LLM embeddings, disrupting their alignment. The method Vaccine was validated on widely-used LLMs, including Llama2, Opt, and Vicuna, showing substantial enhancements in their resilience against malicious prompts while preserving their reasoning capabilities with non-malicious prompts. A work that may be interesting to the broad community.

Weaknesses

The computational overhead of the method seems to linearly scales with model size. When the harmful ratio is high, the method doesn't seem to perform very well.

Questions

If the data for fine-tuning comes from the user, why would the user upload harmful data to break the model.

Rating

6

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

The authors have partially addressed the limitations of their work.

Reviewer CLDA6/10 · confidence 3/52024-07-04

Summary

This paper proposes a novel alignment technique called "Vaccine", which addresses the security risks of large language models (LLMs) during user fine-tuning. It is found that even a small amount of harmful data can destroy the alignment effect of a model, leading to the "alignment destruction effect".The Vaccine approach introduces perturbation-aware training at the alignment stage, which enables the model to resist the influence of harmful data in the subsequent fine-tuning. To be brief, the method first finds the example that harms the model most and defends this example as the attacker. Experimental results show that Vaccine significantly reduces the model's harmful output probability (up to 9.8%) while maintaining good downstream task performance. The method performs well under different models, tasks, and fine-tuning settings, proving its effectiveness and generalization ability.

Strengths

The strength of this paper lies in the following two main points: 1. the authors first present a sample attack scenario under "Finetuning as a service", and discuss the need to maintain security under this scenario. 2. the authors propose the phenomenon of "embedding drift" as the main cause of broken alignments qualitatively. 3. the simplicity and generality of the proposed approach. Specifically, the method proposed in the paper combines the idea of adversarial training, and requires only one more gradient finding and parameter optimization, while applying to various alignment methods. This method can be used as a plug-and-play method in different application scenarios.

Weaknesses

The weakness of this paper may be the following: 1. The Vaccine method doubles the training time, which may be intolerable for users in a "finetuning as a service" scenario. Related acceleration methods can be considered. I am willing to raise my score once this is solved. 2. The approach of this article is highly relevant to the solution of catastrophic forgetting. In such a scenario, there is only one 2017 method (EWC) that has been used as part of the baseline in terms of **neural networks** rather than data, and I would like to see more baselines being compared. 3. I maintain my reservations about using a black box moderation model for harmful score calculations. Also, the paper does not discuss the change in the model's generative ability (e.g., ppl) after using the vaccine method.

Questions

I am very interested in the phenomenon of embedding drift and noticed that you have demonstrated it using the L2 norm. can you provide a more intuitive visualisation such as t-SNE?

Rating

6

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

The authors have adequately addressed the limitations in the checklist guidelines.

Reviewer CLDA2024-08-08

Thank you for your detailed and constructive rebuttal, which includes extensive experimental evidence. I am particularly impressed by your introduction of the **accelerated** Vaccine method. The results demonstrating only a 2% overhead when $\tau = 100$ with minimal performance degradation significantly reduce the application cost of the Vaccine method. I highly recommend including this improvement in the manuscript for future versions. Based on my initial review and your comprehensive response, I decided to adjust my score positively. P.S. There appears to be a typo in Algorithm 2 of the attached PDF: "t mod $\gamma$ == 0" should be reviewed for accuracy. Best regards,

Authorsrebuttal2024-08-08

Thanks for the re-evaluation of our work

We thank the reviewer for the encouraging comment, and also for positively adjusting the socre reflecting our efforts in rebuttal! It is a a great relief for us to see that accelerated Vaccine address your main concern! We will definitely include the accelerated Vaccine as well as its evaluation into the next revision. Indeed, there is a typo in Algorithm 2 of the attached PDF. It should be $t$ mod $\tau$==0. We will fix it in our revision. Thank you for pointing this out! Please feel free to leave us a comment if you need charification during our interaction with other reviewers.

Reviewer Pifs6/10 · confidence 3/52024-07-14

Summary

This paper presents a novel approach to enhance the security of finetuning-as-a-service for Large Language Models (LLMs). The proposed method, Vaccine, introduces a perturbation-aware alignment technique to mitigate the risk of harmful data introduced during user finetuning. The paper demonstrates that Vaccine can effectively maintain alignment robustness against harmful prompts while preserving reasoning abilities on benign prompts.

Strengths

Quality: The paper provides comprehensive empirical evidence demonstrating the effectiveness of Vaccine in reducing harmful scores while maintaining finetuning accuracy across multiple models and datasets. Clarity: The methodology is well-explained, with clear descriptions of the problem, the proposed solution, and the experimental setup.

Weaknesses

Resource Overhead: The increased computational and memory overhead introduced by Vaccine, though justified, might be a limitation for practical deployment, especially in resource-constrained environments. For example the runtime and memory usage should be compared to normal finetune and other baselines.

Questions

Could you provide more information about Resource Overhead?

Rating

6

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

Yes

Authorsrebuttal2024-08-12

Thanks for recognizing our effort in rebuttal!

Thank you for recognizing our effort in rebuttal, and also for increasing rating to reflect the addressed concern. We will definitely include the new results to the paper, and also open-source the accelerated Vaccine method.

Reviewer a2cG6/10 · confidence 3/52024-07-30

Summary

This paper introduces a novel phenomenon called harmful embedding drift, which occurs when a few harmful data points uploaded by users cause misalignment in the fine-tuned LLM. To combat this, this paper proposes a technique called Vaccine, which uses perturbation-aware alignment to produce invariant hidden embeddings. This method aims to maintain the alignment of LLMs even when fine-tuning on potentially harmful user data. The empirical results demonstrate that Vaccine improves the robustness of LLMs against harmful prompts while preserving their reasoning abilities on benign prompts.

Strengths

The paper focuses on an interesting and important topic, proposing a method that performs well across diverse evaluations.

Weaknesses

1. The Vaccine method introduces additional computational overhead due to the need for two forward-backward passes for each step of model optimization. Further evaluation should be shared to show the trade-offs between robustness and efficiency. 2. While the paper demonstrates the efficacy of Vaccine on several datasets (SST2, AG-NEWS, GSM8K, and AlpacaEval), the scalability to larger datasets might require further investigation. 3. The effectiveness of the Vaccine method depends on the noise intensity (ρ), and choosing the optimal value may not be straightforward. Further guidelines on selecting this parameter would enhance the practical applicability of the method. (btw, what is the training data in Table 6)

Questions

1. How does the computational overhead introduced by the Vaccine method compare with other alignment techniques in terms of real-time performance and resource consumption? 2. Will all the fine-tuning jailbreak attacks cause harmful embedding drift? How to define the effectiveness bound of the proposed harmful embedding drift phenomenon?

Rating

6

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

The authors have discussed the limitations and further impacts in the appendix.

Authorsrebuttal2024-08-12

A brief summary of our rebuttal

Hi Reviewer a2cG, Thanks for the very informative review, and also for recognizing the harmful fine-tuning that we focus on is an interesting and important topic. We want to get back to you to see whether our rebuttal addresses your concerns. Here we respectfully summarize our efforts to address your main concerns. 1. To show the **trade-offs between robustness and efficiency**, we design an accelerated Vaccine method. It is shown in the table in the rebuttal that this method has a better tradeoff between robustness and efficiency -- harmful score is increased by a marginal 0.60 while the training time can be shortened by 50%, compared to the original Vaccine. 2. To show that our method can be **generalized to larger datasets**, we show additional experiments on WikiText-2 with a larger number of tokens. The results indicate that Vaccine can reduce harmful scores while maintaining the model's perplexity. 3. We show further guidelines on **selecting hyper-parameter $\rho$** by conducting experiments. The general trend is that with a larger $\rho$, the harmful score will decrease but at the cost of degrading finetune accuracy. 4. We compare another **alignment-stage solution RepNoise** in terms of GPU memory and training time. Our experimental results reflect that Vaccine is superior to RepNoise regarding both GPU memory and training time. We hope that these efforts can fully address your concerns, and we are more than happy to discuss them with you!

Authorsrebuttal2024-08-14

Warm reminder of author-reviewer discussion deadline

Hi Reviewer a2cG, We sincerely thank you for the insightful review comments. As the deadline for the author-reviewer discussion is approaching (less than 8 hours), could you please have a check on our rebuttal? It would be nice if the rating could be slightly adjusted if you found our rebuttal can address your concern. Per your initial review, it seems that your main concern lies in the **resource overhead** of Vaccine. In the rebuttal, we provide more information on the resource overhead of Vaccine on different size of models. Our results indicate that the method requires 2x training time and a marginal extra GPU memory overhead (0.039GB). To further shorten the training time, we propose **accelerated Vaccine**, whose idea is to search for the perturbation not for every step, but to do it for every $\tau$ step. In this way, we can significantly shorten the training time. Our results show that the accelerated Vaccine is approximately 2x faster than the original Vaccine (approximately the same training time with SFT), while still achieving decent defense (less than 0.6% loss of harmful score). We are more than happy to discuss this and other concerns with you!

Reviewer a2cG2024-08-14

Apologies for the late reply. Since my fellow reviewers are largely in favor of acceptance, I initially felt there wasn't much to discuss. However, after reading your rebuttal, I have decided to raise my score. Thank you, nice work.

Authorsrebuttal2024-08-14

Thank you for the feedback!

Thank you for the encouragement and all the insightful questions in the initial review! Pariticularly, for your question "Will all jailbreak attacks cause harmful embedding drift?", we indeed do not have a definitive answer. It is possible that we can use this as an insight to develop adaptive attack to Vaccine, which is quite interesting to explore. Again, thanks for your review for our paper!

Reviewer M5RT2024-08-08

Thanks to the authors for clarifying my confusion. I am keeping my score unchanged for now.

Authorsrebuttal2024-08-08

Thanks for the feedback!

We thank the reviewer for acknowledging our efforts in rebuttal! Please feel free to leave us a comment if you need charification during our interaction with other reviewers.

Authorsrebuttal2024-08-09

Typo correction

As pointed out by Reviewer CLDA, there is a typo in the Algorithm 2 in the rebuttal pdf. Line 4 in the algorithm should be "if $t$ mod $\tau$ == 0" instead of "if $t$ mod $\gamma$ == 0". In this algorithm, we basically do the perturbation every $\tau$ steps instead of per step, in order to accelerate vanilla Vaccine. We apologize for the confusion.

Reviewer Pifs2024-08-12

Thank you for the clarification and additional experiments. The resource overhead of vaccine is smaller than I expected. The author should consider adding this content to the article and making it open source. I have decided to raise my score.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC