让大模型抗住演示顺序乱序攻击,提升推理稳定性。
PEARL: Towards Permutation-Resilient LLMs
- 用最优传输思想生成最坏排序的示范数据,逼模型变强
- 在LLaMA-3上对抗攻击成功率降至20%以下,性能提升40%
- 适合关注模型安全、鲁棒性的研究人员和开发者
大语言模型的上下文学习能力虽强大,但对示范样本顺序极度敏感,易被恶意调序攻击导致预测失准。本文发现仅通过打乱示范顺序,即可对LLaMA-3实现近80%的成功攻击,且难以被检测。现有缓解方法多依赖后处理,无法提升模型内在鲁棒性。为此提出PEARL框架,基于分布鲁棒优化,通过一个排列生成网络(P-Net)与大模型进行对抗训练。P-Net将最差排列生成建模为熵约束的Sinkhorn最优传输问题,经最小最大优化迭代提升模型对输入顺序变化的鲁棒性。在合成预训练和真实指令微调任务中,PEARL有效抵御排列攻击,并在少样本、短上下文条件下训练后,在多示例、长上下文场景中实现最高达40%的性能提升,展现出优异的泛化能力与效率。
原文摘要 · Abstract (English)
The in-context learning (ICL) capability of large language models (LLMs) enables them to perform challenging tasks using provided demonstrations. However, ICL is highly sensitive to the ordering of demonstrations, leading to instability in predictions. This paper shows that this vulnerability can be exploited to design a natural attack - difficult for model providers to detect - that achieves nearly 80% success rate on LLaMA-3 by simply permuting the demonstrations. Existing mitigation methods primarily rely on post-processing and fail to enhance the model's inherent robustness to input permutations, raising concerns about safety and reliability of LLMs. To address this issue, we propose Permutation-resilient learning (PEARL), a novel framework based on distributionally robust optimization (DRO), which optimizes model performance against the worst-case input permutation. Specifically, PEARL consists of a permutation-proposal network (P-Net) and the LLM. The P-Net generates the most challenging permutations by treating it as an optimal transport problem, which is solved using an entropy-constrained Sinkhorn algorithm. Through minimax optimization, the P-Net and the LLM iteratively optimize against each other, progressively improving the LLM's robustness. Experiments on synthetic pre-training and real-world instruction tuning tasks demonstrate that PEARL effectively mitigates permutation attacks and enhances performance. Notably, despite being trained on fewer shots and shorter contexts, PEARL achieves performance gains of up to 40% when scaled to many-shot and long-context scenarios, highlighting its efficiency and generalization capabilities.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。