用几何空间约束让大模型更安全,不改模型也能防有害输出。
Learning Safety Constraints for Large Language Models
- 在模型表征空间中构建安全多面体,通过几何边界识别危险内容。
- 可检测不道德输入,使攻击成功率下降40%以上,且不影响原任务性能。
- 结果可解释,能揭示模型如何理解不同安全语义,适合安全研究者使用。
大型语言模型(LLMs)虽强大,却存在有害输出和易受对抗攻击的风险。我们提出SaP(Safety Polytope),一种基于几何的方法,在模型的表征空间中学习并强制执行多重安全约束。该框架通过多面体的面识别安全与不安全区域,实现对不当输出的检测与纠正。与修改模型权重的方法不同,SaP在模型推理后操作,保持模型能力的同时增强安全性。在多个LLM上的实验表明,该方法能有效检测不道德输入,降低对抗攻击成功率,同时维持标准任务性能。对学习到的多面体面的分析显示,模型在表征空间中自发形成对不同安全语义的专门化识别能力,为安全机制提供了可解释性洞察。
原文摘要 · Abstract (English)
Large language models (LLMs) have emerged as powerful tools but pose significant safety risks through harmful outputs and vulnerability to adversarial attacks. We propose SaP, short for Safety Polytope, a geometric approach to LLM safety that learns and enforces multiple safety constraints directly in the model's representation space. We develop a framework that identifies safe and unsafe regions via the polytope's facets, enabling both detection and correction of unsafe outputs through geometric steering. Unlike existing approaches that modify model weights, SaP operates post-hoc in the representation space, preserving model capabilities while enforcing safety constraints. Experiments across multiple LLMs demonstrate that our method can effectively detect unethical inputs, reduce adversarial attack success rates while maintaining performance on standard tasks, thus highlighting the importance of having an explicit geometric model for safety. Analysis of the learned polytope facets reveals emergence of specialization in detecting different semantic notions of safety, providing interpretable insights into how safety is captured in LLMs' representation space.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。