arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.20206cs.CLcs.AI
收藏

通过嵌入空间分离增强大语言模型的安全性

Enhancing Safety of Large Language Models via Embedding Space Separation

Gaoling School of Artificial Intelligence, Renmin University of China(中国人民大学首都人工智能学院)

Xu Zhao, Xiting Wang, Weiran Shen

AI总结:

本文提出嵌入空间分离方法,通过扩大有害与安全表示间的距离提升大语言模型安全性,同时保持模型通用能力。

摘要:

大语言模型(LLMs)已展现出卓越能力,但确保其对有害提示的安全性仍是一个关键挑战。近期研究表明,LLMs中有害和安全查询的潜在表示(嵌入)通常具有线性可分性,这一特性已被用于通过扰动有害查询的嵌入向量向安全子空间攻击。受此启发,我们提出了一种表示层面的微调方法,称为嵌入空间分离(ES2),通过显式扩大嵌入空间中有害与安全表示之间的距离来提高LLM的安全性。为防止模型通用能力下降,我们在损失函数中引入了KL散度正则化项,该项约束微调后的模型在无害输入上的logits与原始基础模型保持一致。我们在多个开源LLM上使用标准安全基准进行评估。广泛实验结果表明,我们的方法显著提高了模型的安全性,同时保持了可比的通用能力。

英文摘要:

Safety alignment does not fully prevent large language models (LLMs) from producing harmful content under adversarial attacks. We observe that existing attack methods typically move harmful embeddings toward regions of harmless embeddings. This motivates us to explore whether increasing the distance between harmful and harmless embeddings can improve the safety of LLMs, since greater separation requires attacks to make larger embedding shifts, which can destroy semantics. We propose Embedding Space Separation (ES2), a fine-tuning method that increases the distance between harmful and harmless embeddings. However, maximizing this distance alone can damage LLMs' capabilities. Thus, we use two regularization losses: an embedding anchor loss keeps harmless embeddings close in direction to those of a frozen base model and a KL-divergence loss keeps output distributions on harmless prompts close to those of the base model. Our experimental results demonstrate that ES2 has excellent defensive performance against various attack methods. LLMs fine-tuned with ES2 retain general capabilities comparable to those of the baseline models, though some performance degradation is observed on certain tasks. Our results indicate that ES2 is an effective way to enhance the safety of large language models, while maintaining comparable performance on general capabilities.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑