Lisa: Lazy Safety Alignment for Large Language Models against Harmful Fine-tuning Attack
About
Recent studies show that Large Language Models (LLMs) with safety alignment can be jail-broken by fine-tuning on a dataset mixed with harmful data. First time in the literature, we show that the jail-broken effect can be mitigated by separating states in the finetuning stage to optimize the alignment and user datasets. Unfortunately, our subsequent study shows that this simple Bi-State Optimization (BSO) solution experiences convergence instability when steps invested in its alignment state is too small, leading to downgraded alignment performance. By statistical analysis, we show that the \textit{excess drift} towards consensus could be a probable reason for the instability. To remedy this issue, we propose \textbf{L}azy(\textbf{i}) \textbf{s}afety \textbf{a}lignment (\textbf{Lisa}), which introduces a proximal term to constraint the drift of each state. Theoretically, the benefit of the proximal term is supported by the convergence analysis, wherein we show that a sufficient large proximal factor is necessary to guarantee Lisa's convergence. Empirically, our results on four downstream finetuning tasks show that Lisa with a proximal term can significantly increase alignment performance while maintaining the LLM's accuracy on the user tasks. Code is available at \url{https://github.com/git-disl/Lisa}.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Mathematical Reasoning | GSM8K (test) | Accuracy49.4 | 954 | |
| Instruction Following | AlpacaEval | Win Rate40.22 | 420 | |
| Question Answering | OpenBookQA | Accuracy78.9 | 305 | |
| Sentiment Classification | SST2 (test) | -- | 233 | |
| Reasoning | HellaSwag (HS) | HellaSwag Accuracy26.4 | 209 | |
| Instruction Following | Alpaca | -- | 173 | |
| Safety Evaluation | HEX-PHI | -- | 162 | |
| Text Classification | SST-2 | Accuracy93.81 | 133 | |
| Math Reasoning | GSM8K | Accuracy (GSM8K)86.54 | 131 | |
| Safety Evaluation | HarmBench | Harmbench Score20.75 | 127 |