Secure LLM Fine-Tuning via Safety-Aware Probing

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Wu, Chengcan, Zhang, Zhixin, Wei, Zeming, Zhang, Yihao, Luan, Xiaokun, Sun, Meng
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866908988351709184
author Wu, Chengcan
Zhang, Zhixin
Wei, Zeming
Zhang, Yihao
Luan, Xiaokun
Sun, Meng
author_facet Wu, Chengcan
Zhang, Zhixin
Wei, Zeming
Zhang, Yihao
Luan, Xiaokun
Sun, Meng
contents Large language models (LLMs) have achieved remarkable success across many applications, but their ability to generate harmful content raises serious safety concerns. Although safety alignment techniques are often applied during pre-training or post-training, recent studies show that subsequent fine-tuning on adversarial or even benign data can still compromise model safety. In this paper, we revisit the fundamental question of why fine-tuning on non-harmful data may nevertheless degrade safety. We show that the safety and task-performance loss landscapes are partially decoupled, so updates that improve task-specific performance may still move the model toward unsafe regions. Based on this insight, we propose a safety-aware probing (SAP) optimization framework for mitigating safety risks during fine-tuning. Concretely, SAP uses contrastive safety signals to locate safety-correlated directions, and optimizes a lightweight probe that perturbs hidden-state propagation during fine-tuning, thereby steering parameter updates away from harmful trajectories while preserving task-specific learning. Extensive experiments show that SAP consistently improves the safety--utility tradeoff across multiple models and tasks. Averaged over multiple LLMs, SAP reduces the harmful score significantly relative to standard fine-tuning, outperforming strong baselines while maintaining competitive task-specific performance. SAP also demonstrates stronger robustness under harmful data poisoning, adversarial fine-tuning, and a dedicated post-fine-tuning adaptive attack, validating that SAP is an effective and scalable framework for preserving LLM safety during fine-tuning. Our code is available at https://github.com/ChengcanWu/SAP.
format Preprint
id arxiv_https___arxiv_org_abs_2505_16737
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Secure LLM Fine-Tuning via Safety-Aware Probing
Wu, Chengcan
Zhang, Zhixin
Wei, Zeming
Zhang, Yihao
Luan, Xiaokun
Sun, Meng
Machine Learning
Artificial Intelligence
Computation and Language
Cryptography and Security
Optimization and Control
Large language models (LLMs) have achieved remarkable success across many applications, but their ability to generate harmful content raises serious safety concerns. Although safety alignment techniques are often applied during pre-training or post-training, recent studies show that subsequent fine-tuning on adversarial or even benign data can still compromise model safety. In this paper, we revisit the fundamental question of why fine-tuning on non-harmful data may nevertheless degrade safety. We show that the safety and task-performance loss landscapes are partially decoupled, so updates that improve task-specific performance may still move the model toward unsafe regions. Based on this insight, we propose a safety-aware probing (SAP) optimization framework for mitigating safety risks during fine-tuning. Concretely, SAP uses contrastive safety signals to locate safety-correlated directions, and optimizes a lightweight probe that perturbs hidden-state propagation during fine-tuning, thereby steering parameter updates away from harmful trajectories while preserving task-specific learning. Extensive experiments show that SAP consistently improves the safety--utility tradeoff across multiple models and tasks. Averaged over multiple LLMs, SAP reduces the harmful score significantly relative to standard fine-tuning, outperforming strong baselines while maintaining competitive task-specific performance. SAP also demonstrates stronger robustness under harmful data poisoning, adversarial fine-tuning, and a dedicated post-fine-tuning adaptive attack, validating that SAP is an effective and scalable framework for preserving LLM safety during fine-tuning. Our code is available at https://github.com/ChengcanWu/SAP.
title Secure LLM Fine-Tuning via Safety-Aware Probing
topic Machine Learning
Artificial Intelligence
Computation and Language
Cryptography and Security
Optimization and Control
url https://arxiv.org/abs/2505.16737