揭示Transformer在上下文劫持下的鲁棒性机制,解释为何更深模型更稳定。
On the Robustness of Transformers against Context Hijacking for Linear Classification
- 构建基于线性Transformer的上下文分类模型,模拟真实但误导的上下文干扰。
- 发现深度越大,对上下文劫持的鲁棒性越强,且实验验证了这一规律。
- 适合关注模型稳健性与深层架构优势的研究者阅读。
基于线性Transformer的上下文学习能力已被广泛研究,但其预测易受事实正确但具有误导性的上下文影响,即上下文劫持现象,暴露出显著的鲁棒性问题。本文针对线性分类任务,设计了一种理论框架:上下文标记为与目标查询相似但标签相反的查询-答案对。通过分析模型深度、训练上下文长度及劫持上下文数量对鲁棒性的影响,发现训练良好的深层模型具备更高鲁棒性,这源于深层网络能进行更精细的优化,有效缓解干扰。数值实验验证了该结论。研究为深层架构的优势提供了理论依据,深化了对Transformer鲁棒性的理解。
原文摘要 · Abstract (English)
Transformer-based Large Language Models (LLMs) have demonstrated powerful in-context learning capabilities. However, their predictions can be disrupted by factually correct context, a phenomenon known as context hijacking, revealing a significant robustness issue. To understand this phenomenon theoretically, we explore an in-context linear classification problem based on recent advances in linear transformers. In our setup, context tokens are designed as factually correct query-answer pairs, where the queries are similar to the final query but have opposite labels. Then, we develop a general theoretical analysis on the robustness of the linear transformers, which is formulated as a function of the model depth, training context lengths, and number of hijacking context tokens. A key finding is that a well-trained deeper transformer can achieve higher robustness, which aligns with empirical observations. We show that this improvement arises because deeper layers enable more fine-grained optimization steps, effectively mitigating interference from context hijacking. This is also well supported by our numerical experiments. Our findings provide theoretical insights into the benefits of deeper architectures and contribute to enhancing the understanding of transformer architectures.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。