Recovering the Pre-Fine-Tuning Weights of Generative Models

Eliahu Horwitz, Jonathan Kahana, Yedid Hoshen

Introduction

The prevailing paradigm in AI development involves a two-stage process: massive-scale pre-training on raw data followed by alignment fine-tuning (such as RLHF or LoRA) to instill safety and utility. It has long been assumed that once a model is fine-tuned and released, the original "unsafe" weights are effectively overwritten or obscured. This paper challenges that assumption, introducing Spectral DeTuning, a method that can precisely recover the original, unaligned weights of a pre-trained model using only a few of its fine-tuned variants.

The LoRA Security Gap

Low-Rank Adaptation (LoRA) is a widely used, efficient method for fine-tuning large models. Mathematically, LoRA adds a low-rank matrix ($BA$) to the original weights ($W$), resulting in fine-tuned weights $W' = W + BA$.

The authors identify a critical vulnerability: if an attacker has access to multiple fine-tuned versions of the same base model (e.g., a version for coding, one for chat, and one for math), they can treat the recovery of $W$ as a system of equations. Because all these versions share the same foundation $W$, the original weights act as a "common denominator" that can be mathematically extracted.

Methodology: Spectral DeTuning

Spectral DeTuning is an iterative, gradient-free algorithm designed to solve this weight decomposition problem without requiring training data or model inference. Key components include:

  • Iterative Low-Rank Factorization: A coordinate descent approach that alternates between estimating the shared base weights and the individual low-rank "deltas" for each model.
  • Rank Scheduler: A novel optimization technique that starts by identifying very low-rank components and gradually increases the rank. This prevents the algorithm from getting stuck in local minima and accelerates convergence.
  • LoRA Rank Estimation: A heuristic based on linear programming that allows the attack to succeed even when the attacker does not know the specific rank ($r$) used during the fine-tuning process.

Experimental Validation: LoWRA Bench

To evaluate the efficacy of Spectral DeTuning, the authors introduced LoWRA Bench, a comprehensive benchmark covering over 540 pre-fine-tuning layers and 8,000 fine-tuned layers across different modalities:

  1. Vision Transformers (ViT): Fine-tuned on the VTAB-1K classification suite.
  2. Stable Diffusion 1.5: Using real-world personalization LoRAs sourced from community platforms like Civitai.
  3. Mistral-7B: Fine-tuned using Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO).

Key Results

  • Speed and Accessibility: The method is highly efficient, recovering the original weights of a Mistral-7B model in under five minutes using a cluster of consumer-grade RTX 2080 GPUs.
  • High Precision: Recovery is remarkably accurate. For Stable Diffusion, the recovered model produced images nearly identical to the original, with a negligible LPIPS error of 0.009.
  • Restoration of "Unsafe" Capabilities: In language models, the attack successfully stripped away safety training. While the aligned Mistral model refused harmful prompts, the recovered version provided the same responses as the original, unaligned ground-truth model.

Discussion and Limitations

While Spectral DeTuning represents a significant threat to model alignment, it currently has two primary limitations:

  1. Requirement for Multiple Models: The attack typically requires $n \ge 2$ LoRA fine-tuned versions of the same base model.
  2. LoRA Specificity: The current algorithm is tailored to the additive, low-rank structure of LoRA and has not yet been applied to "full" fine-tuning where every weight is modified.

Conclusion

Spectral DeTuning reveals that alignment via LoRA is often just a thin mathematical veil rather than a permanent transformation. The research highlights a significant "defense gap," as there is currently no known method to prevent this type of weight recovery. Future work must focus on developing fine-tuning techniques that make the recovery of base weights computationally infeasible, ensuring that safety guardrails cannot be so easily bypassed.

Summary updated

BibTeX
@inproceedings{horwitz2024recovering,
  author = {Eliahu Horwitz and Jonathan Kahana and Yedid Hoshen},
  title = {{Recovering the Pre-Fine-Tuning Weights of Generative Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=761UxjOTHB},
}
Figure