mlsanityData to 14 Oct 2026

Evaluating and Safeguarding the Adversarial Robustness of Retrieval-Based In-Context Learning

arXiv 2405.15984 ↗First posted 24 May 2024cs.CL cs.AIcited by 4

On the map: Retrieval-augmented generation → Privacy and security of RAG

Abstract (arXiv)

With the emergence of large language models, such as LLaMA and OpenAI GPT-3, In-Context Learning (ICL) gained significant attention due to its effectiveness and efficiency. However, ICL is very sensitive to the choice, order, and verbaliser used to encode the demonstrations in the prompt. Retrieval-Augmented ICL methods try to address this problem by leveraging retrievers to extract semantically related examples as demonstrations. While this approach yields more accurate results, its robustness against various types of adversarial attacks, including perturbations on test samples, demonstrations, and retrieved data, remains under-explored. Our study reveals that retrieval-augmented models can enhance robustness against test sample attacks, outperforming vanilla ICL with a 4.87% reduction in Attack Success Rate (ASR); however, they exhibit overconfidence in the demonstrations, leading to a 2% increase in ASR for demonstration attacks. Adversarial training can help improve the robustness of ICL methods to adversarial attacks; however, such a training scheme can be too costly in the context of LLMs. As an alternative, we introduce an effective training-free adversarial defence method, DARD, which enriches the example pool with those attacked samples. We show that DARD yields improvements in performance and robustness, achieving a 15% reduction in ASR over the baselines. Code and data are released to encourage further research: https://github.com/simonucl/adv-retreival-icl

Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Placed in Privacy and security of RAG, one of 15 directions in Retrieval-augmented generation. Builds on 53 of its 69 references that are in the map. First posted on arXiv 24 May 2024.

Builds on

53 of 69 references.

References · 53

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  2. 2020Language Models are Few-Shot Learnerscited by 32,419
  3. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
  4. 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
  5. 2013Intriguing properties of neural networkscited by 5,155
  6. 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,780
  7. 2017A Broad-Coverage Challenge Corpus for Sentence Understanding through Inferencecited by 2,682
  8. 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
  9. 2022GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformerscited by 1,919
  10. 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
  11. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
  12. 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
38 more
  1. 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
  2. 2023Large Language Models Can Be Easily Distracted by Irrelevant Contextcited by 841
  3. 2017Ensemble Adversarial Training: Attacks and Defensescited by 840
  4. 2019Is BERT Really Robust? A Strong Baseline for Natural Language Attack on Text Classification and Entailmentcited by 671
  5. 2021Learning To Retrieve Prompts for In-Context Learningcited by 648
  6. 2024How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMscited by 573
  7. 2023DecodingTrust: A Comprehensive Assessment of Trustworthiness in GPT Modelscited by 518
  8. 2020BERT-ATTACK: Adversarial Attack Against BERT Using BERTcited by 491
  9. 2023SmoothLLM: Defending Large Language Models Against Jailbreaking Attackscited by 469
  10. 2018TextBugger: Generating Adversarial Text Against Real-world Applicationscited by 381
  11. 2022One Embedder, Any Task: Instruction-Finetuned Text Embeddingscited by 333
  12. 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
  13. 2024OpenMoE: An Early Effort on Open Mixture-of-Experts Language Modelscited by 187
  14. 2023Compositional Exemplars for In-context Learningcited by 144
  15. 2023Unified Demonstration Retriever for In-Context Learningcited by 142
  16. 2022Ground-Truth Labels Matter: A Deeper Look into Input-Label Demonstrationscited by 116
  17. 2023The Earth is Flat because...: Investigating LLMs' Belief towards Misinformation via Persuasive Conversationcited by 109
  18. 2023Cognitive Overload: Jailbreaking Large Language Models with Overloaded Logical Thinkingcited by 81
  19. 2024Reliable, Adaptable, and Attributable Language Models with Retrievalcited by 73
  20. 2017Robust Physical-World Attacks on Deep Learning Modelscited by 72
  21. 2022On the Relation between Sensitivity and Accuracy in In-context Learningcited by 72
  22. 2023Dr.ICL: Demonstration-Retrieved In-context Learningcited by 72
  23. 2023Large Language Models and Knowledge Graphs: Opportunities and Challengescited by 71
  24. 2023Evaluating the Zero-shot Robustness of Instruction-tuned Language Modelscited by 66
  25. 2023Adversarial Demonstration Attacks on Large Language Modelscited by 63
  26. 2023Learning to Retrieve In-Context Examples for Large Language Modelscited by 60
  27. 2024Decoding Compressed Trust: Scrutinizing the Trustworthiness of Efficient LLMs Under Compressioncited by 57
  28. 2021Searching for an Effective Defender: Benchmarking Defense against Adversarial Word Substitutioncited by 56
  29. 2023kNN Prompting: Beyond-Context Learning with Calibration-Free Nearest Neighbor Inferencecited by 47
  30. 2024A Safe Harbor for AI Evaluation and Red Teamingcited by 47
  31. 2024Dual Operating Modes of In-Context Learningcited by 43
  32. 2022Unsupervised Cross-Task Generalization via Retrieval Augmentationcited by 42
  33. 2020Better Robustness by More Coverage: Adversarial Training with Mixup Augmentation for Robust Fine-tuningcited by 39
  34. 2022Robustness of Learning from Task Instructionscited by 35
  35. 2022On the Adversarial Robustness of Mixture of Expertscited by 28
  36. 2022kNN-Prompt: Nearest Neighbor Zero-Shot Inferencecited by 27
  37. 2022Certified Robustness Against Natural Language Attacks by Causal Interventioncited by 24
  38. 2022A Survey of Adversarial Defences and Robustness in NLPcited by 23

50 most cited of 53 All 53 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 1; 2025: 2; 2026: 1.

4 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2023Hijacking Large Language Models via Adversarial In-Context Learning
  2. 2024Towards More Robust Retrieval-Augmented Generation: Evaluating RAG Under Adversarial Poisoning Attacks
  3. 2023Prompt Optimization via Adversarial In-Context Learning
  4. 2024Enhancing Noise Robustness of Retrieval-Augmented Language Models with Adaptive Adversarial Training
  5. 2026Understanding and Improving Continuous Adversarial Training for LLMs via In-context Learning Theory
  6. 2025Refract ICL: Rethinking Example Selection in the Era of Million-Token Models
  7. 2024Data Poisoning for In-context Learning
  8. 2025ICLShield: Exploring and Mitigating In-Context Learning Backdoor Attacks