让大模型自我反思,动态提升生成内容安全性。
Think Twice, Generate Once: Safeguarding by Progressive Self-Reflection
- 通过多轮自我反思机制,让模型在生成时自我检测并修正输出。
- 对多个模型测试,攻击成功率从77.5%降至5.9%,安全效果显著。
- 自适应调节反思次数,兼顾安全性与推理效率,适合实际部署。
大型语言模型(LLMs)在自然语言处理中展现出生成连贯、上下文相关文本的强大能力,但其部署面临生成有害或不当内容的风险。本文提出一种新的推理阶段技术——渐进式自我反思(PSR),使LLMs能够动态自监控并修正输出。实验表明,将该方法应用于Llama-3.1-8B-Instruct时,攻击成功率由77.5%降至5.9%;应用于Llama-3.1-8B base时,由89.7%降至5.6%;应用于Qwen2.5-7B-Instruct时,由44.4%降至3.8%,且无需额外训练,同时保持原有良性任务性能。该方法作为测试时扩展手段,增加反思轮次可提升安全性,但伴随推理开销。为此,我们引入轻量级自我反思预测器,根据输入复杂度估计最优反思轮次。该自适应机制避免对良性输入进行过度评估,确保对潜在有害内容充分审查。结果表明,PSR是一种可扩展的测试时安全增强方法,能按输入风险动态分配计算资源。
原文摘要 · Abstract (English)
Large language models (LLMs) have revolutionized natural language processing with their ability to generate coherent and contextually relevant text. However, their deployment raises significant concerns about the potential for generating harmful or inappropriate content. In this paper, we introduce Progressive Self-Reflection (PSR), a novel inference-time technique that empowers LLMs to self-monitor and correct their outputs dynamically. Experimental results demonstrate that applying our proposed method to Llama-3.1-8B-Instruct reduces the attack success rate from 77.5\% to 5.9\%, to Llama-3.1-8B base from 89.7\% to 5.6\%, and to Qwen2.5-7B-Instruct from 44.4\% to 3.8\%, without additional training, while maintaining their original performance on benign tasks. Our approach acts as a test-time scaling method, where additional self-reflection rounds enhance safety at the cost of inference overhead. To balance safety with computational efficiency, we introduce a lightweight self-reflection predictor that estimates the optimal number of reflection rounds based on input complexity. This adaptive mechanism prevents unnecessary self-assessment on benign inputs while ensuring thorough evaluation when encountering potentially harmful content. Our findings suggest that Progressive Self-Reflection serves as a scalable test-time approach, enhancing LLM safety by dynamically allocating computational resources in proportion to the input's risk profile.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。