mlsanityData to 14 Oct 2026

On the Robustness of Transformers against Context Hijacking for Linear Classification

arXiv 2502.15609 ↗First posted 21 Feb 2025cs.CL cs.AI cs.LGcited by 4

Not on the map. Why?

Abstract (arXiv)

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.

Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Builds on 76 of its 88 references that are in the map. First posted on arXiv 21 Feb 2025.

Builds on

76 of 88 references.

References · 76

  1. 2017Attention Is All You Needcited by 60,361
  2. 2020Language Models are Few-Shot Learnerscited by 32,419
  3. 2023GPT-4 Technical Reportcited by 18,396
  4. 2022Training language models to follow instructions with human feedbackcited by 15,971
  5. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  6. 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
  7. 2022Locating and Editing Factual Associations in GPTcited by 2,691
  8. 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,234
  9. 2023Jailbreaking Black Box Large Language Models in Twenty Queriescited by 1,420
  10. 2022In-context Learning and Induction Headscited by 964
  11. 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
  12. 2023Large Language Models Can Be Easily Distracted by Irrelevant Contextcited by 841
38 more
  1. 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 832
  2. 2022Transformers learn in-context by gradient descentcited by 732
  3. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
  4. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
  5. 2018Universal Transformerscited by 647
  6. 2023Prompt Injection attack against LLM-integrated Applicationscited by 605
  7. 2023GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Promptscited by 560
  8. 2019Benign Overfitting in Linear Regressioncited by 549
  9. 2023"Do Anything Now": Characterizing and Evaluating In-The-Wild Jailbreak Prompts on Large Language Modelscited by 489
  10. 2021MetaICL: Learning to Learn In Contextcited by 454
  11. 2023Jailbreak and Guard Aligned Language Models with Only Few In-Context Demonstrationscited by 431
  12. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 406
  13. 2023Trustworthy LLMs: a Survey and Guideline for Evaluating Large Language Models' Alignmentcited by 401
  14. 2023A Survey on Large Language Model (LLM) Security and Privacy: The Good, the Bad, and the Uglycited by 387
  15. 2023Making Retrieval-Augmented Language Models Robust to Irrelevant Contextcited by 369
  16. 2023Trained Transformers Learn Linear Models In-Contextcited by 337
  17. 2022Selection-Inference: Exploiting Large Language Models for Interpretable Logical Reasoningcited by 334
  18. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 298
  19. 2023On Evaluating Adversarial Robustness of Large Vision-Language Modelscited by 284
  20. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
  21. 2023Certifying LLM Safety against Adversarial Promptingcited by 266
  22. 2019Analyzing the Structure of Attention in a Transformer Language Modelcited by 243
  23. 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 222
  24. 2023On the Robustness of ChatGPT: An Adversarial and Out-of-distribution Perspectivecited by 211
  25. 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 199
  26. 2021Thinking Like Transformerscited by 184
  27. 2023Image Hijacks: Adversarial Images can Control Generative Models at Runtimecited by 172
  28. 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 170
  29. 2021Meta-learning via Language Model In-context Tuningcited by 164
  30. 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 146
  31. 2023Supervised Pretraining Can Learn In-Context Reinforcement Learningcited by 139
  32. 2024Jailbreaking Attack against Multimodal Large Language Modelcited by 135
  33. 2023An LLM can Fool Itself: A Prompt-Based Adversarial Attackcited by 116
  34. 2023In-Context Convergence of Transformerscited by 115
  35. 2023Tracr: Compiled Transformers as a Laboratory for Interpretabilitycited by 104
  36. 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 102
  37. 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 102
  38. 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 96

50 most cited of 76 All 76 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 3; 2026: 1.

4 papers.