arXiv:2509.24488cs.CLcs.CR2025-09

让大模型自我检查并实时修正隐私泄露内容,不增加延迟。

Sanitize Your Responses: Mitigating Privacy Leakage in Large Language Models

  • 通过模仿人类自我监控与修复机制,实现逐标记流式检测
  • 在三种隐私泄露场景下显著降低有害内容生成,性能优于现有方法
  • 适合需要实时安全防护的对话系统、代码助手等应用

随着大语言模型(LLMs)在聊天机器人和代码助手等应用中取得显著成功,生成有害内容的问题日益突出。尽管在对齐安全与伦理标准方面已有进展,但对抗性提示仍可诱使模型产生不良响应。现有缓解策略多依赖事后过滤,带来显著延迟或计算开销,且不支持逐标记流式生成。本文提出Self-Sanitize框架,受认知心理学启发,模拟人类对话中的自我监控与修复行为。该框架包含轻量级自监控模块,在令牌级别通过表示工程持续检视模型高层意图,以及自修复模块,在不启动额外审查对话的前提下进行原位内容修正。这一设计实现真正的实时流式监控与无缝修复,对延迟和资源消耗影响极小。针对隐私泄露内容在以往研究中常被忽视的问题,我们在三个隐私泄露场景下对四种LLM进行了广泛实验。结果表明,Self-Sanitize在保持模型实用性的同时,以极低开销实现卓越的缓解效果,为更安全的LLM部署提供了实用且鲁棒的解决方案。代码已公开于:https://github.com/wjfu99/LLM_Self_Sanitize

原文摘要 · Abstract (English)

As Large Language Models (LLMs) achieve remarkable success across a wide range of applications, such as chatbots and code copilots, concerns surrounding the generation of harmful content have come increasingly into focus. Despite significant advances in aligning LLMs with safety and ethical standards, adversarial prompts can still be crafted to elicit undesirable responses. Existing mitigation strategies are predominantly based on post-hoc filtering, which introduces substantial latency or computational overhead, and is incompatible with token-level streaming generation. In this work, we introduce Self-Sanitize, a novel LLM-driven mitigation framework inspired by cognitive psychology, which emulates human self-monitor and self-repair behaviors during conversations. Self-Sanitize comprises a lightweight Self-Monitor module that continuously inspects high-level intentions within the LLM at the token level via representation engineering, and a Self-Repair module that performs in-place correction of harmful content without initiating separate review dialogues. This design allows for real-time streaming monitoring and seamless repair, with negligible impact on latency and resource utilization. Given that privacy-invasive content has often been insufficiently focused in previous studies, we perform extensive experiments on four LLMs across three privacy leakage scenarios. The results demonstrate that Self-Sanitize achieves superior mitigation performance with minimal overhead and without degrading the utility of LLMs, offering a practical and robust solution for safer LLM deployments. Our code is available at the following link: https://github.com/wjfu99/LLM_Self_Sanitize

大模型安全隐私保护实时检测自修复

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。