Skip to content
Preprint

HyperSafe: Inference-Time Safety Recovery for Fine-Tuned Language Models

Jul 2026 · 0 citations · 49 references
Computer Science

TL;DR

This work proposes HyperSafe, a framework that restores safety behavior by generating a model-specific Safe Side Network (SSN) for each fine-tuned checkpoint by using layer-wise activation fingerprints to capture how fine-tuning changes the model's inner representations.

Abstract

Safety alignment in large language models can be fragile under fine-tuning, as even benign task adaptation may increase harmful compliance. Existing defenses mainly follow two directions: they either intervene during or after fine-tuning through retraining or weight modification, which can be costly and may hurt task performance, or they use model-agnostic safety classifiers, which may miss failures specific to a given fine-tuned checkpoint. These limitations motivate a post hoc, model-specific, and non-invasive approach to safety restoration. To meet these requirements, we propose HyperSafe, a framework that restores safety behavior by generating a model-specific Safe Side Network (SSN) for each fine-tuned checkpoint. HyperSafe uses layer-wise activation fingerprints to capture how fine-tuning changes the model's inner representations. With a small set of given calibration prompts, the hypernetwork maps these fingerprints to the parameters of the \ssn{} in a single forward pass. The generated \ssn{} runs alongside the frozen fine-tuned model and performs prompt-level safety classification: harmful prompts are routed to refusal, while safe prompts are answered by the original fine-tuned model. Thus, HyperSafe requires no gradient updates, no safety data at deployment time, and no modification to the deployed model weights. We evaluate HyperSafe on two model families, Qwen2-7B and LLaMA-3-8B, across multiple safety benchmarks. HyperSafe reduces harmful response rates from 19-31% to below 1% on every held-out checkpoint, while keeping downstream task accuracy within 1% of the fine-tuned baseline on average. Code is available at https://github.com/nokronim/project-safety-remedy.

View source

Similar papers

Book Open access Aug 2026

SAFT: Safety-Preserving Adaptation via Fine-Tuning Transfer for Large Language Models

SAFT (Safety-preserving Adaptation via Fine-tuning Transfer), a safety-preserving adaptation framework that decouples task learning from alignment preservation by learning a safety-guided task update on the paired pretrained base model, rectifying task gradients to avoid conflicting directions with respect to a safety...

Zhiwen Ruan, Yan Yang, Zhuocheng Liang et al. · 0 citations
Preprint Aug 2026

HiRoute: Hierarchical Routed Prompt Tuning for Safety Alignment of Large Language Models

Experiments across three instruction-tuned models show that HiRoute achieves high safety rates across multiple safety benchmarks while preserving safe-response helpfulness, reducing over-refusal, and maintaining competitive performance on general-purpose tasks.

Fang-Zhou Chen, Shiji Zhao, Mengyan Wang et al. · 0 citations
Preprint Aug 2026

Gradient Immunity: Null-Space Resistance to Malicious Fine-Tuning

A Unidirectional Safety Gate (USG) is proposed, instantiated as a Null Space Cubic Layer together with an Inverse Adapter inserted after the final Transformer layer, suggesting that release-time representation-space blocking can raise the cost of malicious downstream adaptation without requiring downstream cooperation.

Yuxuan Huang, Xingyu Zeng, Tian-Hang Zheng et al. · 0 citations
#small language model Preprint Aug 2026

RTLGuard: A Lightweight Teacher-Student Defense for Poisoned RTL Code Generation Models

RTLGuard leverages a teacher-student framework designed to sanitize compromised RTL generation models by fine-tuning a small-scale,"clean"teacher model on a limited set of trusted RTL data, and incorporating feature alignment and knowledge distillation to suppress malicious behaviors.

Mahshid Rezakhani, K. Azar, H. Kamali · 0 citations
Preprint Aug 2026

DataRx: Missingness-Aware Sampling for Safer Large Language Model Task-Specific Fine-Tuning

This paper proposes DataRx, a missingness-aware sampling method for selecting safety-critical examples based on the hypothesis that a safety sample is more effective when the selected examples provide safety signals that fill the missing parts of LLMs'safety capabilities.

Junbo Zhang, Qianli Zhou, Xinyang Deng et al. · 0 citations
Jul 2026

On-Policy Distillation for LLM Safety: A Routing Approach to Template-Robust Realignment

This work proposes Routing-based On-Policy Distillation (ROPD), a novel realignment framework that models the divergence between aligned and compromised output probability distributions rather than fitting specific prompt templates, establishing a new standard for robust LLM realignment.

Yong-Jian Guo, Wanlun Ma, Lingyu Shen et al. · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.