Safe Pruning LoRA: Robust Distance-Guided Pruning for Safety Alignment in Adaptation of LLMs

Shuang Ao, Yi Dong, Jinwei Hu, Sarvapali D. Ramchurn · DOI

Introduction

Fine-tuning Large Language Models (LLMs) via Low-Rank Adaptation (LoRA) has become the standard for specializing models for downstream tasks. However, this process often incurs a "safety tax": even when fine-tuned on benign data, models can inadvertently "forget" their safety alignment, becoming susceptible to generating harmful or biased content. This vulnerability is even more pronounced when models are exposed to malicious or "poisoned" datasets.

Existing solutions typically rely on "Arithmetic Intervention," which attempts to project weights back toward a safe state. However, these methods often face a difficult safety-utility trade-off and rely on similarity metrics that fail to capture complex, high-dimensional parameter shifts. This paper introduces Safe Pruning LoRA (SPLoRA), a training-free approach that restores safety by identifying and pruning specific LoRA layers that deviate from the model's original safety alignment.

The Problem: Safety Degradation in LoRA

LoRA adds small, trainable matrices to a frozen base model to achieve efficient adaptation. While effective for performance, this adaptation can compromise the safety guardrails established during the model's initial Reinforcement Learning from Human Feedback (RLHF) phase.

Standard similarity metrics, such as Cosine Similarity or Euclidean distance, are often inadequate for monitoring these changes. Euclidean distance, for instance, scales with the number of dimensions, making it difficult to compare layers of different sizes across a model's hierarchy. Furthermore, the distribution of LLM weights is often "long-tailed and sparse," rendering standard deviation-based metrics sensitive to outliers.

Methodology: The SPLoRA Framework

SPLoRA operates as a two-step, data-free framework applied after the fine-tuning process is complete.

1. Defining the Safety Subspace

To identify safety-critical regions, the authors compare a safety-aligned model (e.g., Llama-2-Chat) with its unaligned base version (Llama-2). By analyzing the differences between these models, they construct a "projection matrix" that represents the subspace where safety-related parameters reside.

2. E-DIEM Guided Pruning

The core of SPLoRA is a novel similarity metric called Empirical Dimension-Insensitive Euclidean Metric (E-DIEM). E-DIEM is designed to be robust against the high-dimensional nature of LLMs by:

  • Dimension-Insensitivity: Normalizing the metric so that comparisons across different layer sizes are fair.
  • Outlier Robustness: Utilizing the Interquartile Range (IQR) instead of standard deviation to account for the sparse distribution of weights.

During the pruning phase, the new LoRA weights are projected onto the safety subspace. SPLoRA calculates the distance between the original LoRA weights and their "safe" projection using E-DIEM. If a layer's distance exceeds a specific threshold, it is deemed a safety risk and is pruned (removed) entirely from the model.

Experimental Evaluation

The researchers evaluated SPLoRA across several models, including Llama-2, Llama-3, Llama-3.2, and Gemma, using a variety of datasets:

  • Benign Tasks: Dialog Summary and Alpaca datasets were used to measure general utility.
  • Malicious Scenarios: The "PureBad" dataset (100 harmful examples) and mixed datasets (benign data combined with harmful samples) were used to simulate safety degradation and stealthy poisoning.

Key Results and Insights

Superior Safety Restoration

On the Llama-2-7B-Chat model fine-tuned on a malicious mixture, SPLoRA reduced the Attack Success Rate (ASR) from 25.32% to 6.92%. This significantly outperformed other state-of-the-art methods such as SafeLoRA (8.57%) and Vaccine (12.96%).

Maintained Utility and Efficiency

Unlike projection-based methods that can degrade performance, SPLoRA maintained stable scores on benign tasks (ROUGE/METEOR). In some cases, performance improved slightly, suggesting that pruning removes "harmful noise" that does not contribute to the target task. Furthermore, because SPLoRA removes layers, it achieved a 12.5% reduction in total inference time and per-sample latency.

Distributed Safety Alignment

An analysis of the pruning patterns revealed that SPLoRA tends to remove layers across the entire network. This contrasts with previous methods that focused primarily on the first and last layers, suggesting that safety alignment is more deeply and broadly distributed throughout transformer blocks than previously understood.

Conclusion and Future Work

SPLoRA demonstrates that pruning is a highly effective, efficient, and training-free alternative to weight projection for maintaining LLM safety. By using the dimension-insensitive E-DIEM metric, the framework provides a robust way to identify and eliminate safety-compromising adaptations.

Future research directions include developing adaptive thresholds to determine the optimal number of layers to prune based on task complexity, as well as exploring the interpretability of why specific layers are more prone to safety degradation. Additionally, the authors aim to test the framework on larger architectures, such as 70B+ models and Mixture of Experts (MoE) structures.

Summary updated

BibTeX
@article{ao2025safe,
  author = {Shuang Ao and Yi Dong and Jinwei Hu and Sarvapali D. Ramchurn},
  title = {{Safe Pruning LoRA: Robust Distance-Guided Pruning for Safety Alignment in Adaptation of LLMs}},
  journal = {Trans. Assoc. Comput. Linguistics},
  year = {2025},
  doi = {10.1162/tacl.a.44},
}
Figure