Evaluating and Safeguarding the Adversarial Robustness of Retrieval-Based In-Context Learning
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
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
- 2013Intriguing properties of neural networkscited by 5,155
- 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,780
- 2017A Broad-Coverage Challenge Corpus for Sentence Understanding through Inferencecited by 2,682
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2022GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformerscited by 1,919
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
38 more
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
- 2023Large Language Models Can Be Easily Distracted by Irrelevant Contextcited by 841
- 2017Ensemble Adversarial Training: Attacks and Defensescited by 840
- 2019Is BERT Really Robust? A Strong Baseline for Natural Language Attack on Text Classification and Entailmentcited by 671
- 2021Learning To Retrieve Prompts for In-Context Learningcited by 648
- 2024How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMscited by 573
- 2023DecodingTrust: A Comprehensive Assessment of Trustworthiness in GPT Modelscited by 518
- 2020BERT-ATTACK: Adversarial Attack Against BERT Using BERTcited by 491
- 2023SmoothLLM: Defending Large Language Models Against Jailbreaking Attackscited by 469
- 2018TextBugger: Generating Adversarial Text Against Real-world Applicationscited by 381
- 2022One Embedder, Any Task: Instruction-Finetuned Text Embeddingscited by 333
- 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
- 2024OpenMoE: An Early Effort on Open Mixture-of-Experts Language Modelscited by 187
- 2023Compositional Exemplars for In-context Learningcited by 144
- 2023Unified Demonstration Retriever for In-Context Learningcited by 142
- 2022Ground-Truth Labels Matter: A Deeper Look into Input-Label Demonstrationscited by 116
- 2023The Earth is Flat because...: Investigating LLMs' Belief towards Misinformation via Persuasive Conversationcited by 109
- 2023Cognitive Overload: Jailbreaking Large Language Models with Overloaded Logical Thinkingcited by 81
- 2024Reliable, Adaptable, and Attributable Language Models with Retrievalcited by 73
- 2017Robust Physical-World Attacks on Deep Learning Modelscited by 72
- 2022On the Relation between Sensitivity and Accuracy in In-context Learningcited by 72
- 2023Dr.ICL: Demonstration-Retrieved In-context Learningcited by 72
- 2023Large Language Models and Knowledge Graphs: Opportunities and Challengescited by 71
- 2023Evaluating the Zero-shot Robustness of Instruction-tuned Language Modelscited by 66
- 2023Adversarial Demonstration Attacks on Large Language Modelscited by 63
- 2023Learning to Retrieve In-Context Examples for Large Language Modelscited by 60
- 2024Decoding Compressed Trust: Scrutinizing the Trustworthiness of Efficient LLMs Under Compressioncited by 57
- 2021Searching for an Effective Defender: Benchmarking Defense against Adversarial Word Substitutioncited by 56
- 2023kNN Prompting: Beyond-Context Learning with Calibration-Free Nearest Neighbor Inferencecited by 47
- 2024A Safe Harbor for AI Evaluation and Red Teamingcited by 47
- 2024Dual Operating Modes of In-Context Learningcited by 43
- 2022Unsupervised Cross-Task Generalization via Retrieval Augmentationcited by 42
- 2020Better Robustness by More Coverage: Adversarial Training with Mixup Augmentation for Robust Fine-tuningcited by 39
- 2022Robustness of Learning from Task Instructionscited by 35
- 2022On the Adversarial Robustness of Mixture of Expertscited by 28
- 2022kNN-Prompt: Nearest Neighbor Zero-Shot Inferencecited by 27
- 2022Certified Robustness Against Natural Language Attacks by Causal Interventioncited by 24
- 2022A Survey of Adversarial Defences and Robustness in NLPcited by 23
50 most cited of 53 All 53 (JSON)
Built on by
Citing papers per year: 2024: 1; 2025: 2; 2026: 1.
4 papers.
- 2024Can Language Models Perform Robust Reasoning in Chain-of-thought Prompting with Noisy Rationales?cited by 41
- 2025DRAGON: Guard LLM Unlearning in Context via Negative Detection and Reasoningcited by 7
- 2025On the Robustness of Tabular Foundation Models: Test-Time Attacks and In-Context Defensescited by 3
- 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoningcited by 0
- 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoning1 Oct 2026
- 2025DRAGON: Guard LLM Unlearning in Context via Negative Detection and Reasoning8 Nov 2025
- 2025On the Robustness of Tabular Foundation Models: Test-Time Attacks and In-Context Defenses3 Jun 2025
- 2024Can Language Models Perform Robust Reasoning in Chain-of-thought Prompting with Noisy Rationales?31 Oct 2024
Similar, not cited
Close in wording, no citation either way
- 2023Hijacking Large Language Models via Adversarial In-Context Learning
- 2024Towards More Robust Retrieval-Augmented Generation: Evaluating RAG Under Adversarial Poisoning Attacks
- 2023Prompt Optimization via Adversarial In-Context Learning
- 2024Enhancing Noise Robustness of Retrieval-Augmented Language Models with Adaptive Adversarial Training
- 2026Understanding and Improving Continuous Adversarial Training for LLMs via In-context Learning Theory
- 2025Refract ICL: Rethinking Example Selection in the Era of Million-Token Models
- 2024Data Poisoning for In-context Learning
- 2025ICLShield: Exploring and Mitigating In-Context Learning Backdoor Attacks