Typos that Broke the RAG's Back: Genetic Attack on RAG Pipeline by Simulating Documents in the Wild via Low-level Perturbations

Sukmin Cho, Soyeong Jeong, Jeongyeon Seo, Taeho Hwang, Jong C. ParkarXiv 2024

TL;DR

While Retrieval-Augmented Generation (RAG) effectively mitigates LLM hallucinations, it is surprisingly fragile when faced with simple text typos in external databases. This paper introduces GARAG (Genetic Attack on RAG), a black-box adversarial attack that uses a genetic algorithm to inject subtle, low-level typos that simultaneously trick the retriever and derail the LLM reader, causing a massive drop in end-to-end performance.

What Problem Does This Paper Address?

Retrieval-Augmented Generation (RAG) systems combine a retriever (to fetch relevant documents from a database) and a reader (usually an LLM that generates an answer based on those documents). While RAG is widely deployed to ensure up-to-date and factually accurate responses, its robustness is typically evaluated in a piecemeal fashion—focusing on either the retriever or the reader in isolation. Furthermore, existing robustness benchmarks focus on high-level semantic changes, such as introducing counterfactual information or irrelevant context.

This paper addresses a pervasive but overlooked threat in real-world databases: low-level textual errors (typos) caused by human mistakes or OCR/preprocessing glitches. The authors investigate how these minor, inconspicuous typos comprehensively disrupt the sequential interaction between the retriever and reader components.

Figure 1: Impact of noisy documents in real-world databases on the RAG system: The retriever selects a noisy document, causing the reader to produce incorrect answers.

Methods

The authors propose GARAG (Genetic Attack on RAG), a novel black-box adversarial attack framework. Because RAG pipelines involve discrete text and non-differentiable operations across two distinct models, gradient-based attacks fail. GARAG bypasses this by using a multi-objective genetic algorithm to search the vast space of possible typographical perturbations.

GARAG optimizes for two distinct attack objectives simultaneously:

  1. Relevance Score Ratio (RSR): Measures how effectively the perturbed document distracts the retriever from the clean document.
  2. Generation Probability Ratio (GPR): Measures how effectively the perturbed document misleads the LLM reader into generating an incorrect answer.

The algorithm operates iteratively:

  • Initialization: Generates an initial population of adversarial documents by randomly applying four types of low-level perturbations to non-answer tokens: inner-shuffling, truncation, keyboard typos, and natural typos.
  • Crossover & Mutation: Recombines successful adversarial features from parent documents and introduces new variations.
  • Selection: Uses a non-dominated sorting strategy (NSGA-II) and crowding distance sorting to identify the Pareto front—the optimal set of documents that minimize both RSR and GPR, pushing the population into the "Holistic Error Zone."
Figure 2: (Left) The search space formulated by our proposed attack objectives, LRSR and LGPR. (Right) An overview of the iterative process implemented by our proposed method, GARAG.

Datasets

The method was validated using 1,000 randomly extracted instances from three standard open-domain Question-Answering (QA) benchmarks:

  • Natural Questions (NQ)
  • TriviaQA (TQA)
  • SQuAD (SQD)

The evaluation incorporated diverse retrievers (DPR, Contriever) and open-source LLM readers ranging from 7B to 13B parameters (Llama2, Vicuna, Mistral), alongside closed-source testing on GPT-3.5.

Key Insights and Ideas

  • The "Few Typos" Paradox: Counter-intuitively, the authors found that a lower perturbation rate (fewer typos) causes a more disruptive impact on the RAG system than a high perturbation rate. When a document is heavily corrupted, neural retrievers easily identify and reject it. However, when a document contains only a few subtle typos, it slips past the retriever but still completely derails the LLM reader's ability to ground its answer correctly.
  • The Retriever as a Shield: A stronger retriever (like the supervised DPR vs. the unsupervised Contriever) acts as a better protective barrier, demonstrating higher robustness against typos and mitigating downstream reader errors.
  • Grammar Checkers are Not Enough: Relying on a standalone grammar checker as a defense mechanism is highly flawed. The authors' analysis showed that standard grammar checkers flag roughly 50% of perfectly clean, original documents as noisy, while failing to catch about 25% of the adversarial typos generated by GARAG.

Key Results

  • High Attack Success: GARAG consistently achieved an attack success rate (ASR) of approximately 70% across various datasets, retrievers, and LLMs.
  • Severe Performance Degradation: The end-to-end Exact Match (EM) performance of the RAG systems dropped by an average of 30%, and by up to nearly 50% in the worst-case scenarios.
  • Black-Box Efficacy on Closed-Source Models: Because GARAG does not require gradient access, it successfully compromised proprietary models. When targeting GPT-3.5, GARAG achieved a total attack success rate of 50% (with DPR) and 60.3% (with Contriever).

Limitations and Future Work

  • Compute and Model Scale: Due to academic budget constraints, the authors could not evaluate massive black-box LLMs (e.g., GPT-4) that possess over a hundred billion parameters. Testing GARAG on these larger models remains an open direction.
  • Autoregressive Variance: Being in the "holistic error zone" does not guarantee a reader failure 100% of the time due to the probabilistic, autoregressive nature of LLM token generation.
  • Defense Development: While the paper exposes a critical vulnerability, developing sophisticated, tailored defense strategies beyond simple grammar checking is left for future work.

Summary updated

BibTeX
@misc{cho2024typos,
  author = {Sukmin Cho and Soyeong Jeong and Jeongyeon Seo and Taeho Hwang and Jong C. Park},
  title = {{Typos that Broke the RAG's Back: Genetic Attack on RAG Pipeline by Simulating Documents in the Wild via Low-level Perturbations}},
  year = {2024},
  eprint = {2404.13948},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.13948},
}
Figure