What Makes and Breaks Safety Fine-tuning? A Mechanistic Study

Samyak Jain, Ekdeep Singh Lubana, Kemal Oksuz, Tom Joy, Philip H. S. Torr +2 more
7/14/2024
cs.LGcs.CL

No official code found. Best implementation: fiveai/understanding_safety_finetuning (12 stars, last commit 2024-10-31).

Abstract

Safety fine-tuning helps align Large Language Models (LLMs) with human preferences for their safe deployment. To better understand the underlying factors that make models safe via safety fine-tuning, we design a synthetic data generation framework that captures salient aspects of an unsafe input by modeling the interaction between the task the model is asked to perform (e.g., "design") versus the specific concepts the task is asked to be performed upon (e.g., a "cycle" vs. a "bomb"). Using this, we investigate three well-known safety fine-tuning methods -- supervised safety fine-tuning, direct preference optimization, and unlearning -- and provide significant evidence demonstrating that these methods minimally transform MLP weights to specifically align unsafe inputs into its weights' null space. This yields a clustering of inputs based on whether the model deems them safe or not. Correspondingly, when an adversarial input (e.g., a jailbreak) is provided, its activations are closer to safer samples, leading to the model processing such an input as if it were safe. We validate our findings, wherever possible, on real-world models -- specifically, Llama-2 7B and Llama-3 8B.

View on arXivView PDF

Code Implementations(1)

Official Code for What Makes and Breaks Safety Fine-tuning? A Mechanistic Study (NeurIPS 2024)

122Shell, PythonJun 14, 20241 years agoNOASSERTION

Similar Papers

Cite this paper

@article{jain2024what,
  title  = {What Makes and Breaks Safety Fine-tuning? A Mechanistic Study},
  author = {Samyak Jain and Ekdeep Singh Lubana and Kemal Oksuz and Tom Joy and Philip H. S. Torr and Amartya Sanyal and Puneet K. Dokania},
  year   = {2024},
  eprint = {2407.10264},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2407.10264},
  url    = {http://arxiv.org/abs/2407.10264v3},
  journal = {NEURIPS 2024 2024}
}

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/2407.10264.svg)](https://codeofpaper.com/paper/2407.10264)

Discussion