mlsanityData to 14 Oct 2026

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

arXiv 2411.05189 ↗First posted 7 Nov 2024cs.LG cs.CRcited by 8

Not on the map. Why?

Abstract (arXiv)

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.

Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Builds on 39 of its 47 references that are in the map. First posted on arXiv 7 Nov 2024.

Builds on

39 of 47 references.

References · 39

  1. 2020Language Models are Few-Shot Learnerscited by 32,419
  2. 2014Explaining and Harnessing Adversarial Examplescited by 7,364
  3. 2017Towards Deep Learning Models Resistant to Adversarial Attackscited by 6,415
  4. 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
  5. 2021Decision Transformer: Reinforcement Learning via Sequence Modelingcited by 1,546
  6. 2019Theoretically Principled Trade-off between Robustness and Accuracycited by 1,517
  7. 2022Transformers learn in-context by gradient descentcited by 732
  8. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
  9. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
  10. 2022TabPFN: A Transformer That Solves Small Tabular Classification Problems in a Secondcited by 674
  11. 2016Delving into Transferable Adversarial Examples and Black-box Attackscited by 536
  12. 2021Linear Transformers Are Secretly Fast Weight Programmerscited by 502
27 more
  1. 2016Learning to reinforcement learncited by 377
  2. 2023Trained Transformers Learn Linear Models In-Contextcited by 337
  3. 2023Can Generalist Foundation Models Outcompete Special-Purpose Tuning? Case Study in Medicinecited by 329
  4. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 298
  5. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
  6. 2022Visual Prompting via Image Inpaintingcited by 250
  7. 2024Foundational Challenges in Assuring Alignment and Safety of Large Language Modelscited by 199
  8. 2023Image Hijacks: Adversarial Images can Control Generative Models at Runtimecited by 172
  9. 2023What Makes Good Examples for Visual In-Context Learning?cited by 150
  10. 2023Human-Timescale Adaptation in an Open-Ended Task Spacecited by 138
  11. 2022General-Purpose In-Context Learning by Meta-Learning Transformerscited by 105
  12. 2019Recent Advances in Algorithmic High-Dimensional Robust Statisticscited by 101
  13. 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 96
  14. 2018Efficient Algorithms and Lower Bounds for Robust Linear Regressioncited by 76
  15. 2018Efficient Algorithms for Outlier-Robust Regressioncited by 72
  16. 2024LLM Processes: Numerical Predictive Distributions Conditioned on Natural Languagecited by 55
  17. 2020Meta Learning Backpropagation And Improving Itcited by 49
  18. 2023Hijacking Large Language Models via Adversarial In-Context Learningcited by 45
  19. 2015Robust Regression via Hard Thresholdingcited by 39
  20. 2023Generalization to New Sequential Decision Making Tasks with In-Context Learningcited by 39
  21. 2024Adversarial Robustness Limits via Scaling-Law and Human-Alignment Studiescited by 38
  22. 2020Optimal Robust Linear Regression in Nearly Linear Timecited by 32
  23. 2024Linear Transformers are Versatile In-Context Learnerscited by 28
  24. 2019Adaptive Hard Thresholding for Near-optimal Consistent Robust Regressioncited by 23
  25. 2023The Double-Edged Sword of Implicit Bias: Generalization vs. Robustness in ReLU Networkscited by 23
  26. 2024Data Poisoning for In-context Learningcited by 21
  27. 2024In-Context In-Context Learning with Transformer Neural Processescited by 4

Built on by

Cited by year (2026 to 14 Oct)

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

8 papers.