Rethinking Safety in LLM Fine-tuning: An Optimization Perspective

Minseon Kim, Jin Myung Kwak, Lama Alssum, Bernard Ghanem, Philip Torr +3 more
8/17/2025
cs.LGcs.AI

No official code found. Best implementation: Kim-Minseon/Rethinking_safety_in_finetunedLLM (2 stars, MIT, last commit 2025-11-14).

Abstract

Fine-tuning language models is commonly believed to inevitably harm their safety, i.e., refusing to respond to harmful user requests, even when using harmless datasets, thus requiring additional safety measures. We challenge this belief through systematic testing, showing that poor optimization choices, rather than inherent trade-offs, often cause safety problems, measured as harmful responses to adversarial prompts. By properly selecting key training hyper-parameters, e.g., learning rate, batch size, and gradient steps, we reduce unsafe model responses from 16\% to approximately 5\%, as measured by keyword matching, while maintaining utility performance. Based on this observation, we propose a simple exponential moving average (EMA) momentum technique in parameter space that preserves safety performance by creating a stable optimization path and retains the original pre-trained model's safety properties. Our experiments on the Llama families across multiple datasets (Dolly, Alpaca, ORCA) demonstrate that safety problems during fine-tuning can largely be avoided without specialized interventions, outperforming existing approaches that require additional safety data while offering practical guidelines for maintaining both model performance and safety during adaptation.

View on arXivView PDF

Code Implementations(1)

MIT

Official code of "Rethinking Safety in LLM Fine-tuning: An Optimization Perspective" COLM 2025

20Shell, PythonNov 14, 202511 months agoMIT

Similar Papers

Cite this paper

@article{kim2025rethinking,
  title  = {Rethinking Safety in LLM Fine-tuning: An Optimization Perspective},
  author = {Minseon Kim and Jin Myung Kwak and Lama Alssum and Bernard Ghanem and Philip Torr and David Krueger and Fazl Barez and Adel Bibi},
  year   = {2025},
  eprint = {2508.12531},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2508.12531v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2508.12531.svg)](https://codeofpaper.com/paper/2508.12531)

Discussion