CRAIAug 30, 2024

Safety Layers in Aligned Large Language Models: The Key to LLM Security

arXiv:2408.17003v5116 citationsh-index: 21
Originality Incremental advance
AI Analysis

This addresses the problem of security degradation in aligned LLMs during fine-tuning, which is incremental but important for developers and users concerned with model safety.

The study identified a small set of middle layers in aligned large language models as crucial for security, termed 'safety layers', and proposed a fine-tuning method that fixes these layers' gradients to prevent security degradation while maintaining performance and reducing computational costs.

Aligned LLMs are secure, capable of recognizing and refusing to answer malicious questions. However, the role of internal parameters in maintaining such security is not well understood yet, further these models can be vulnerable to security degradation when subjected to fine-tuning attacks. To address these challenges, our work uncovers the mechanism behind security in aligned LLMs at the parameter level, identifying a small set of contiguous layers in the middle of the model that are crucial for distinguishing malicious queries from normal ones, referred to as ``safety layers". We first confirm the existence of these safety layers by analyzing variations in input vectors within the model's internal layers. Additionally, we leverage the over-rejection phenomenon and parameters scaling analysis to precisely locate the safety layers. Building on these findings, we propose a novel fine-tuning approach, Safely Partial-Parameter Fine-Tuning (SPPFT), that fixes the gradient of the safety layers during fine-tuning to address the security degradation. Our experiments demonstrate that the proposed approach can significantly preserve LLM security while maintaining performance and reducing computational resources compared to full fine-tuning.

Code Implementations1 repo
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes