Abstract
Fine-tuning Large Language Models (LLMs) for specialized tasks often inadvertently compromises their safety alignment, making them susceptible to generating harmful content. This paper presents a surgical post-processing method that restores alignment by resetting a minimal fraction (approximately 0.2%) of the model's weights to their pre-fine-tuned state. By identifying and modifying weights that contribute most to "harmful directions" in the model's internal representation, the proposed approach effectively re-aligns the model while preserving its newly acquired task-specific capabilities. Across 125 fine-tuned models, the method reduced harmful response rates from 33.25% to 1.74% with a negligible impact on task performance.
Introduction
To ensure safe deployment, Large Language Models undergo alignment processes, such as Reinforcement Learning from Human Feedback (RLHF), to establish ethical guardrails. However, recent research highlights the fragility of this alignment. When developers fine-tune an aligned model on new datasets—even those devoid of harmful content—the model frequently "forgets" its safety training. This risk is amplified if the fine-tuning data is intentionally poisoned. Existing remedies typically involve preventive measures during fine-tuning or aggressive post-hoc fixes, both of which often degrade the model's performance on the target task. This paper introduces a selective weight restoration technique designed to reinstate safety guardrails without sacrificing utility.
Methodology
The authors propose a surgical approach to weight restoration based on the manipulation of internal feature directions.
1. Identifying Internal Directions
The researchers observed that LLMs possess internal "directions" (vectors within hidden states) that correspond to aligned versus harmful behaviors. By analyzing these vectors, it is possible to identify how fine-tuning shifts the model's internal representations toward harmful outputs.
2. Surgical Weight Reset
Rather than retraining the entire model, the method employs gradient descent to pinpoint the specific weight parameters that contribute most significantly to the harmful directions emerged during fine-tuning. The authors found that resetting only the top $P\%$ (typically 0.2%) of these influential weights to their original, pre-fine-tuned values is sufficient to restore refusal behavior.
3. The Rollback Mechanism
To protect the model's new task-specific knowledge, a "rollback" mechanism is implemented. If the weight reset causes task performance to drop below a predefined threshold, the system identifies the weights most critical for the new task and reverts them to their fine-tuned state, ensuring a balance between safety and utility.
4. Optimal Layer Targeting
The study identified a "sweet spot" for intervention: targeting layers approximately two-thirds of the way through the network architecture proved most effective for controlling alignment without disrupting foundational logic or surface-level generation.
Experimental Setup
The method was evaluated using 125 different fine-tuned models across a diverse set of benchmarks:
- Downstream Tasks: SQL (Text-to-SQL), CHEAT (AI text detection), NL2BASH (Linux commands), SAMSum (Summarization), and TOXIC (Toxicity detection).
- Safety and Alignment: The BeaverTails dataset (333k QA pairs) provided harmful prompts for evaluation and the necessary recovery data. Cross-evaluation was performed using HEx-PHI and CATQA to ensure the method's generalizability.
- General Utility: Models were tested against MMLU, GSM8K, PIQA, TriviaQA, and HumanEval to confirm that general intelligence remained intact.
Key Insights and Results
The experimental results demonstrate that fine-tuning is inherently risky; even clean datasets increased the likelihood of harmful responses from 11.7% to 21.3%. However, the proposed "0.2% solution" yielded significant improvements:
- Safety Restoration: The average harmful rate across all models plummeted from 33.25% to 1.74%.
- Utility Preservation: The average degradation in task performance was restricted to 2.93%. This outperforms existing baselines like RESTA, which often incur much steeper performance penalties.
- Robustness: The method proved particularly robust for generation-based tasks (e.g., coding or summarization), though classification tasks showed higher sensitivity to parameter changes.
Conclusion and Future Work
This research demonstrates that safety alignment is not a surface-level trait but is encoded in specific internal directions that can be surgically managed. By resetting a tiny fraction of weights, developers can effectively "re-align" models that have drifted during fine-tuning.
Future work remains to address "Scenario I" constraints, where a model owner may not have access to the user's fine-tuning data, making the performance-based rollback mechanism difficult to implement. Additionally, optimizing the computational overhead of identifying the target weights will be crucial for applying this method to ultra-large-scale models.
Summary updated