arXiv:2411.05189cs.LGcs.CR2024-11被引 9

揭示Transformer在上下文学习中对攻击的脆弱性及改进方法

Understanding In-Context Learning of Linear Models in Transformers Through an Adversarial Lens

  • 从对抗视角分析Transformer在上下文学习中的漏洞
  • 对抗训练可显著提升模型鲁棒性并泛化到更强攻击
  • 不同随机种子训练的Transformer学习算法差异大,与传统方法本质不同

本文针对Transformer在上下文学习线性模型中的表现提出两项贡献。首先,研究了上下文学习对劫持攻击(即攻击者操纵提示以迫使模型生成特定输出)的对抗鲁棒性,发现线性Transformer与GPT-2架构的Transformer均易受此类攻击。但通过预训练或微调阶段的对抗训练,鲁棒性可显著提升,并能泛化至更强攻击模型。其次,对比分析了Transformer与其他线性模型学习算法的对抗脆弱性。结果显示:即使相同架构、相似分布性能,不同种子训练的大规模Transformer之间攻击迁移效果差,暗示其可能实现不同的上下文学习算法;同时,传统算法(单步梯度下降、普通最小二乘)与Transformer之间的攻击迁移也较差,表明两者在学习机制上存在质的区别。

原文摘要 · Abstract (English)

In this work, we make two contributions towards understanding of in-context learning of linear models by transformers. First, we investigate the adversarial robustness of in-context learning in transformers to hijacking attacks -- a type of adversarial attacks in which the adversary's goal is to manipulate the prompt to force the transformer to generate a specific output. We show that both linear transformers and transformers with GPT-2 architectures are vulnerable to such hijacking attacks. However, adversarial robustness to such attacks can be significantly improved through adversarial training -- done either at the pretraining or finetuning stage -- and can generalize to stronger attack models. Our second main contribution is a comparative analysis of adversarial vulnerabilities across transformer models and other algorithms for learning linear models. This reveals two novel findings. First, adversarial attacks transfer poorly between larger transformer models trained from different seeds despite achieving similar in-distribution performance. This suggests that transformers of the same architecture trained according to the same recipe may implement different in-context learning algorithms for the same task. Second, we observe that attacks do not transfer well between classical learning algorithms for linear models (single-step gradient descent and ordinary least squares) and transformers. This suggests that there could be qualitative differences between the in-context learning algorithms that transformers implement and these traditional algorithms.

Transformer对抗攻击上下文学习

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