通过量化实现模型安全对齐,部署更安全高效。
Q-realign: Piggybacking Realignment on Quantization for Safe and Efficient LLM Deployment
- 将量化重构为压缩与安全双重目标,解耦安全对齐与微调
- 7B模型在单张RTX 4090上40分钟内恢复安全对齐,内存与算力显著降低
- 无需重训练,可直接嵌入现有部署流程,适合实际应用
公开的大语言模型通常在预训练阶段完成安全对齐,但部署时所需的任务特定微调常破坏该对齐,引入安全风险。现有防御方法要么将安全恢复嵌入微调过程,要么依赖微调生成的先验进行事后修正,导致安全恢复与训练紧密耦合,计算开销大且流程复杂。为此,我们提出 exttt{Q-realign},一种基于后训练量化的后处理防御方法,其设计基于表征结构分析。通过将量化重构为压缩与安全双重目标, exttt{Q-realign} 实现了安全对齐与微调的解耦,并可自然地嵌入现代部署流程。在多个模型和数据集上的实验表明,该方法显著减少不安全行为,同时保持任务性能,内存占用和GPU小时数大幅下降。值得注意的是,该方法可在单张RTX 4090上于40分钟内恢复一个7B模型的安全对齐。总体而言,本工作提供了一种实用、即插即用的安全部署解决方案。
原文摘要 · Abstract (English)
Public large language models (LLMs) are typically safety-aligned during pretraining, yet task-specific fine-tuning required for deployment often erodes this alignment and introduces safety risks. Existing defenses either embed safety recovery into fine-tuning or rely on fine-tuning-derived priors for post-hoc correction, leaving safety recovery tightly coupled with training and incurring high computational overhead and a complex workflow. To address these challenges, we propose \texttt{Q-realign}, a post-hoc defense method based on post-training quantization, guided by an analysis of representational structure. By reframing quantization as a dual-objective procedure for compression and safety, \texttt{Q-realign} decouples safety alignment from fine-tuning and naturally piggybacks into modern deployment pipelines. Experiments across multiple models and datasets demonstrate that our method substantially reduces unsafe behaviors while preserving task performance, with significant reductions in memory usage and GPU hours. Notably, our approach can recover the safety alignment of a fine-tuned 7B LLM on a single RTX 4090 within 40 minutes. Overall, our work provides a practical, turnkey solution for safety-aware deployment.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。