Adversarial Databases Improve Success in Retrieval-based Large Language Models

Sean Wu, Michael Koo, Li Yo Kao, Andy Black, Lesley Blum, Fabien Scalzo, Ira Kurtz · DOI

Introduction

Retrieval-Augmented Generation (RAG) has become the standard architectural pattern for grounding Large Language Models (LLMs) in factual, domain-specific data. By retrieving relevant context from a vector database, RAG aims to reduce hallucinations and improve accuracy in specialized fields such as medicine. Conventional wisdom suggests that the quality of the retrieved information is the primary driver of performance, and that irrelevant or "adversarial" data would likely degrade model output. This study challenges that assumption, demonstrating that completely irrelevant context—such as the Bible or random words—can significantly enhance the performance of certain open-source LLMs.

Methodology

The researchers evaluated five prominent open-source LLMs: Llama 3 (8b), Phi-3 (mini), Mixtral 8x7b, Zephyr$\beta$, and Gemma 7B Instruct. The evaluation task consisted of 858 multiple-choice questions (MCQs) from the Nephrology Self-Assessment Program (nephSAP).

The experimental setup utilizing a vector database containing both relevant medical corpora and adversarial texts.

The experimental pipeline utilized a zero-shot RAG workflow. Questions were vectorized using a TF-IDF approach to identify the top three most similar 1,000-word chunks from four distinct databases:

  1. Relevant (nephSAP): The primary source syllabus.
  2. Relevant (UpToDate): A high-quality clinical corpus.
  3. Adversarial (Bible): The Latin Vulgate text.
  4. Adversarial (Random Words): A collection of randomly generated terms.

To validate the "adversarial" nature of the Bible and Random Words sets, the authors confirmed minimal keyword overlap (approx. 2.5%) compared to the relevant nephSAP database (33.3%).

Results and Discussion

The most striking finding was the performance of Mixtral 8x7b. While its baseline accuracy was 40.2%, it improved to 59.2% with relevant medical data. Unexpectedly, it achieved nearly comparable gains using irrelevant data, reaching 54.6% accuracy with the Bible and 55.3% with random words.

Comparative success rates showing that both relevant and adversarial context injection improve performance across medical categories.

However, this "adversarial boost" was not uniform across all architectures. While Gemma 7B and Zephyr$\beta$ also saw improvements from the Bible context, Llama 3 and Phi-3 behaved more traditionally, showing performance degradation when exposed to irrelevant noise.

The Attention Shifting Hypothesis

The authors propose that the benefit of adversarial RAG is not derived from the semantic content of the retrieved text, but rather from a "latent shift" in the model's attention mechanism. Injecting additional tokens into the context window may force the model to re-evaluate its internal attention weights, potentially activating relevant pre-trained knowledge that remains dormant during standard zero-shot prompting. In this view, RAG may function less as a knowledge retrieval system and more as a sophisticated prompting technique that stabilizes reasoning.

Conclusion

This research highlights a counter-intuitive property of LLM attention. The fact that irrelevant data can improve performance suggests that the mechanical process of retrieval and context injection has profound effects on model behavior independent of information quality. Future work is required to probe the specific attention dynamics involved and to determine if this phenomenon extends beyond the medical domain.

Summary updated

BibTeX
@misc{wu2024adversarial,
  author = {Sean Wu and Michael Koo and Li Yo Kao and Andy Black and Lesley Blum and Fabien Scalzo and Ira Kurtz},
  title = {{Adversarial Databases Improve Success in Retrieval-based Large Language Models}},
  year = {2024},
  eprint = {2407.14609},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.14609},
}
Figure