RAGSentinel: Certifiable Geometric Consensus for Robust Retrieval-Augmented Generation¶
Conference: EMNLP 2026
Paper: ACL Anthology
Area: Information Retrieval
Keywords: Retrieval-Augmented Generation, Knowledge Poisoning Defense, Geometric Median, Hidden-State Shift, Certifiable Robustness
TL;DR¶
RAGSentinel proposes a training-free, black-box-compatible post-retrieval defense against RAG knowledge poisoning by measuring document-induced hidden-state shifts with an independent surrogate encoder, removing shared query-topic directions, and filtering malicious documents as geometric outliers relative to a robust geometric median consensus with certifiable guarantees.
Background & Motivation¶
Retrieval-augmented generation (RAG) dramatically reduces factual hallucinations and parametric staleness in large language models (LLMs) by grounding generation in externally retrieved evidence. However, this open-world retrieval paradigm introduces a catastrophic vulnerability known as knowledge poisoning attacks. In this threat model, an adversary injects a handful of maliciously crafted documents into an external corpus prior to inference. These documents are optimized to rank among the top search results for specific target queries while asserting targeted factual falsehoods. Because the adversary requires no query modifications, no parameter tampering, and no inference-time intervention, the resulting fluent and plausible adversarial documents blend seamlessly with benign texts in both query logs and model generations, leaving deployed systems defenseless.
Existing post-retrieval defenses fall into three broad paradigms, each crippled by a fundamental structural limitation. Instruction-based methods (such as RobustRAG and InstructRAG) prompt the LLM to resist suspicious context or synthesize reasoning rationales; however, they rely entirely on the model's own text-level judgment to detect contradictions—the exact capability that adversarial passages are optimized to fool. Knowledge consolidation methods (such as AstuteRAG and TrustRAG) attempt to reconcile retrieved evidence against the LLM's stored parametric knowledge, but break down completely when domain-specific parametric knowledge is absent or when the poisoned claims align with pre-trained priors. Text consistency-based approaches (such as CrAM) assume that poisoned evidence conflicts with the majority in surface token space, yet sophisticated attackers readily generate passages that are stylistically and textually consistent with benign documents while asserting contradictory facts. In essence, all three families operate on surface-level signals that attackers can directly observe, optimize against, or closely mimic.
Crucially, what an adversary cannot easily conceal is the representation-level impact that a false factual assertion imposes on a model's latent geometry. When retrieved documents are appended to a query and encoded by an independent surrogate model, their induced hidden-state shifts—once stripped of the dominant query-topic direction—naturally cluster along a common benign stance, whereas documents carrying conflicting factual assertions inevitably become geometric outliers. Because the geometry of an independent surrogate encoder lies completely outside the adversary's optimization surface, this geometric signature provides an uncorrupted foundation for defense. Core idea: extract document-conditioned hidden-state residual shifts via an independent surrogate encoder, eliminate shared topic directions through mean-centering, anchor a robust majority consensus via the geometric median and local neighborhood consistency, and certifiably filter out poisoned outlier documents under an adaptive majority radius.
Method¶
Overall Architecture¶
RAGSentinel operates as a plug-and-play, training-free, and label-free post-retrieval filter positioned strictly upstream of the deployed black-box LLM. It requires exactly \(k+1\) forward passes through an independent open-source surrogate encoder (e.g., BGE-M3) and exactly one final zero-shot call to the generator. The entire procedure proceeds across three sequential phases: First, shift extraction and preprocessing computes query-conditioned hidden-state shifts, projects them onto an active subspace of responsive dimensions, clips extreme norms, and removes the dominant query-topic direction via mean-centering. Second, consensus scoring combines a robust global geometric median anchor distance with a local neighborhood consistency score. Third, adaptive filtering and context construction dynamically derives an acceptance radius based on distance dispersion, retains the top-\(\lceil k/2 \rceil\) most coherent documents, and passes this certifiably sanitized context to the black-box LLM for generation.
%%{init: {'flowchart': {'rankSpacing': 24, 'nodeSpacing': 28, 'padding': 6, 'wrappingWidth': 400}}}%%
flowchart TD
A["Input Query q and Candidate Documents {p_i}"] --> B["Dynamic Active Subspace Selection<br/>Peak responsiveness filtering on latent dimensions"]
B --> C["Adaptive Norm Clipping & Topic Removal<br/>Bounding outlier leverage and mean-centering"]
C --> D["Dual Consensus Scoring via Geometric Median<br/>Global geometric median anchor + local neighborhood consistency"]
D --> E["Adaptive Majority-Radius Filtering<br/>Dispersion-scaled radius expansion and majority truncation"]
E --> F["Pass Trusted Context C* to Black-Box LLM for Generation"]
Key Designs¶
1. Dynamic Active Subspace Selection: High-dimensional noise drowns factual signals -> Peak responsiveness projection -> Isolating factual shift dimensions
Modern language models and encoders exhibit high-dimensional latent representations (typically \(d \ge 4096\)), yet for any specific query, the vast majority of dimensions exhibit negligible variance across retrieved documents, injecting high-dimensional isotropic noise that obscures factual distinctions. To isolate meaningful signals, RAGSentinel identifies a query-specific active subspace. Let \(f_\varphi\) be the surrogate encoder and \(\phi_\varphi(\cdot)\) denote its hidden-state representation extracted at the final token of the last layer. The baseline hidden state from the query-only prompt is \(h_0 = \phi_\varphi(q)\), while each query-document prompt yields \(h_i = \phi_\varphi(q, p_i)\) for \(i \in \{1, \dots, k\}\). The raw document shift is \(\delta_i = h_i - h_0\). Across all retrieved passages, the algorithm computes the peak responsiveness for each dimension \(\ell \in \{1, \dots, d\}\) as \(u_\ell = \max_{i} |\delta_i^{(\ell)}|\), and identifies the active dimension set \(V\) via the median and median absolute deviation (MAD):
where \(\text{MAD}(\{u_\ell\}) = \text{Median}(|u_\ell - \text{Median}(\{u_\ell\})|)\). Each shift is then projected onto this active subspace: \(\tilde{\delta}_i = \delta_i[V]\). If the size \(|V|\) falls below a safe baseline, the system falls back to the top-\(\lceil d/k \rceil\) ranked dimensions by \(u_\ell\). This data-driven selection isolates dimensions that actively reflect evidence variance without requiring labeled data or fine-tuning.
2. Adaptive Norm Clipping & Topic Removal: Large-norm adversarial distortion and retrieval topic confound -> Query-adaptive rescaling and mean-centering -> Uncorrupted residual factual stance
Projected shift vectors remain susceptible to two confounds: adversarial documents crafted to induce anomalously large shift norms that pull the geometric center, and the broad query-topic direction shared by all \(k\) retrieved passages reflecting general topical relevance rather than specific factual assertions. RAGSentinel tackles both via a robust two-step normalization. First, it computes the \(L_2\) norm of each projected shift \(b_i = \|\tilde{\delta}_i\|_2\) and derives an adaptive norm boundary \(B_{\text{adp}} = \text{Median}(\{b_i\}) + \text{MAD}(\{b_i\})\). Each shift is clipped according to:
Once individual document leverage is safely bounded, the shared query-topic component is effectively captured by the arithmetic mean. RAGSentinel removes this common directional bias via mean-centering:
The resulting residual vectors \(\{z_i\}\) decouple factual stances from generic retrieval relevance, ensuring that subsequent consensus estimation focuses solely on whether the asserted claims corroborate one another.
3. Dual Consensus Scoring via Geometric Median: Vulnerability of single global or local metrics -> Combining geometric median anchor with local neighborhood consistency -> Robust outlier quantification
RAGSentinel assigns each document a scalar consensus distance \(d_i\) that captures its deviation from the benign majority. Because the candidate pool may contain up to \(\lfloor (k-1)/2 \rfloor\) adversarial documents, the global consensus center cannot be estimated via standard arithmetic averaging. RAGSentinel adopts the geometric median from Byzantine-robust distributed learning:
The geometric median provably remains anchored within the benign cluster under the honest-majority assumption (\(|I_p| = k' < k/2\)). The global anchor distance is defined as \(d_i^{\text{anchor}} = 1 - \cos(z_i, c)\). To prevent evasion by adversarial passages engineered to point roughly toward the global anchor without genuine local support, RAGSentinel introduces a local consistency term. For each passage \(p_i\), it measures the mean cosine distance to its \(m = \max(1, \lceil k/2 \rceil - 1)\) nearest neighbors: \(d_i^{\text{local}} = \frac{1}{m} \sum_{j \in \mathcal{N}_i^{(m)}} (1 - \cos(z_i, z_j))\). The global and local signals are adaptively blended:
When the global anchor distances exhibit substantial spread, the global term dominates; when anchor distances are compressed, local neighbor corroboration seamlessly takes precedence.
4. Adaptive Majority-Radius Filtering: Fixed geometric thresholds fail across varied queries -> Dispersion-scaled radius expansion -> Certifiable poison exclusion
Because distance scales vary dramatically across queries depending on corpus diversity, rigid distance cutoffs either over-filter benign context or permit poisoned leakage. RAGSentinel dynamically derives a query-adaptive filtering radius. Let \(R\) denote the \(\lceil k/2 \rceil\)-th smallest value in \(\{d_i\}\), representing the minimal radius encompassing at least half of the retrieved documents. RAGSentinel modulates \(R\) using the normalized dispersion parameter \(\sigma_d = \frac{2 R}{\text{Median}(\{d_i\}) + \text{MAD}(\{d_i\}) + \epsilon}\):
When consensus distances are tightly concentrated (indicating a clear benign consensus), \(\sigma_d\) is low and the radius expands toward \(2R\) to retain rich evidence; when distances are scattered, it contracts toward \(R\). The surviving candidate set is \(S = \{i : d_i \le R_{\text{adp}}\}\) (falling back to the single argmin document if \(S\) is empty). The survivors in \(S\) are sorted in ascending order of \(d_i\), and the top \(\lceil k/2 \rceil\) passages are concatenated into a trusted context \(C^\star\). Under Theorem 1 (Certifiable Filtering), assuming an honest majority (\(k' < k/2\)), non-degenerate benign centroid \(\|\mu_b\|_2 \ge r_0\), and poison-to-benign cosine separation \(\min_{j \in I_p, i \in I_b} (1 - \cos(z_j, z_i)) \ge \gamma\) satisfying \(G_{\text{full}} > \frac{D_b^+}{1 + \sigma_d}\), RAGSentinel guarantees \(C^\star \cap I_p = \emptyset\) and \(|C^\star| = \lceil k/2 \rceil\), certifiably eliminating all poisoned passages.
A Worked Example¶
To illustrate the dynamic decision process in practice, consider the Natural Questions case study evaluated under PoisonedRAG with \(k=10\) retrieved passages and \(k'=2\) injected poisoned passages. - User Query: "Where are the cardiac and vasomotor centers found?" - Ground Truth: Medulla oblongata; Adversarial Target: Cerebellum. - Filtering Execution: - Phase 1 isolates 318 active dimensions from BGE-M3's 1024-dimensional space; - Adaptive signal weighting establishes \(\lambda = 0.169\); - The \(\lceil 10/2 \rceil\)-th distance yields base radius \(R = 0.907\), expanded by dispersion to \(R_{\text{adp}} = 1.499\); - Assigned consensus distances \(\{d_i\}\): Doc 0 (\(d_0 = 3.958\), Poisoned), Doc 1 (\(d_1 = 3.922\), Poisoned), Doc 6 (\(d_6 = 0.407\), Benign), Doc 7 (\(d_7 = 0.475\), Benign), Doc 8 (\(d_8 = 0.576\), Benign), Doc 2 (\(d_2 = 0.767\), Benign), Doc 3 (\(d_3 = 0.907\), Benign), Doc 4 (\(d_4 = 0.982\), Benign), Doc 5 (\(d_5 = 2.595\), Benign stub), Doc 9 (\(d_9 = 2.644\), Benign irrelevant). - Outcome: The two poisoned documents are decisively flagged as outliers (\(d_0 / R_{\text{adp}} \approx 2.64\times\), \(d_1 / R_{\text{adp}} \approx 2.62\times\)) and discarded. Incomplete/irrelevant benign passages (Docs 5 and 9) fall beyond \(R_{\text{adp}}\), while Doc 4 is excluded by the top-\(\lceil k/2 \rceil = 5\) budget. The resulting context \(C^\star = \{6, 7, 8, 2, 3\}\) allows the LLM to output: "The cardiac and vasomotor centers are found in the medulla oblongata of the brain."
Key Experimental Results¶
Main Results¶
The defense was evaluated on three standard QA benchmarks: Natural Questions (NQ), HotpotQA, and MS-MARCO, retrieving \(k=10\) documents via Contriever. Experiments evaluated Mistral-7B, Llama-3.1-8B, and Qwen-2.5-7B across clean settings and three poisoning attacks: PoisonedRAG, PIA, and Adversarial Decoding (AD). The table below reports benign utility accuracy (ACC) and attack success rate (ASR) on Mistral-7B.
| Model | Defense Method | NQ Clean ACC |
NQ PoisonedRAG ACC / ASR |
NQ PIA ACC / ASR |
NQ AD ACC / ASR |
HotpotQA Clean ACC |
HotpotQA PoisonedRAG ACC / ASR |
HotpotQA PIA ACC / ASR |
HotpotQA AD ACC / ASR |
MS-MARCO Clean ACC |
MS-MARCO PoisonedRAG ACC / ASR |
MS-MARCO PIA ACC / ASR |
MS-MARCO AD ACC / ASR |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Mistral-7B | Vanilla RAG | 0.71 | 0.53 / 0.40 | 0.58 / 0.29 | 0.49 / 0.45 | 0.73 | 0.38 / 0.60 | 0.42 / 0.51 | 0.40 / 0.52 | 0.82 | 0.59 / 0.34 | 0.66 / 0.24 | 0.66 / 0.29 |
| Mistral-7B | RobustRAG | 0.64 | 0.69 / 0.11 | 0.68 / 0.09 | 0.69 / 0.11 | 0.57 | 0.57 / 0.30 | 0.56 / 0.31 | 0.59 / 0.26 | 0.87 | 0.87 / 0.03 | 0.85 / 0.03 | 0.86 / 0.04 |
| Mistral-7B | InstructRAG | 0.72 | 0.54 / 0.40 | 0.57 / 0.29 | 0.62 / 0.29 | 0.71 | 0.43 / 0.52 | 0.42 / 0.52 | 0.56 / 0.30 | 0.82 | 0.61 / 0.32 | 0.70 / 0.23 | 0.70 / 0.21 |
| Mistral-7B | AstuteRAG | 0.69 | 0.70 / 0.10 | 0.69 / 0.03 | 0.67 / 0.12 | 0.68 | 0.67 / 0.17 | 0.64 / 0.15 | 0.63 / 0.24 | 0.85 | 0.81 / 0.12 | 0.85 / 0.08 | 0.83 / 0.11 |
| Mistral-7B | TrustRAG | 0.76 | 0.71 / 0.18 | 0.72 / 0.07 | 0.73 / 0.10 | 0.68 | 0.68 / 0.17 | 0.71 / 0.09 | 0.70 / 0.18 | 0.77 | 0.80 / 0.14 | 0.79 / 0.12 | 0.77 / 0.17 |
| Mistral-7B | CrAM | 0.70 | 0.48 / 0.39 | 0.51 / 0.24 | 0.51 / 0.35 | 0.70 | 0.34 / 0.57 | 0.38 / 0.50 | 0.36 / 0.56 | 0.76 | 0.51 / 0.38 | 0.65 / 0.19 | 0.62 / 0.26 |
| Mistral-7B | RAGSentinel | 0.69 | 0.63 / 0.04 | 0.63 / 0.05 | 0.61 / 0.04 | 0.68 | 0.63 / 0.09 | 0.64 / 0.06 | 0.63 / 0.09 | 0.82 | 0.77 / 0.05 | 0.71 / 0.04 | 0.78 / 0.04 |
Ablation Study¶
The contribution of each component was systematically evaluated across all three datasets and three attacks using Mistral-7B as the generator and BGE-M3 as the surrogate encoder:
| Ablation Configuration | NQ Clean ACC |
NQ PoisonedRAG ACC / ASR |
NQ PIA ACC / ASR |
NQ AD ACC / ASR |
HotpotQA Clean ACC |
HotpotQA PoisonedRAG ACC / ASR |
HotpotQA PIA ACC / ASR |
HotpotQA AD ACC / ASR |
MS-MARCO Clean ACC |
MS-MARCO PoisonedRAG ACC / ASR |
MS-MARCO PIA ACC / ASR |
MS-MARCO AD ACC / ASR |
Key Finding |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Full RAGSentinel | 0.69 | 0.63 / 0.04 | 0.63 / 0.05 | 0.61 / 0.04 | 0.68 | 0.63 / 0.09 | 0.64 / 0.06 | 0.63 / 0.09 | 0.82 | 0.77 / 0.05 | 0.71 / 0.04 | 0.78 / 0.04 | Complete pipeline |
| w/ Arithmetic Mean (no GeoMed) | 0.68 | 0.55 / 0.08 | 0.52 / 0.13 | 0.58 / 0.09 | 0.63 | 0.57 / 0.09 | 0.59 / 0.13 | 0.66 / 0.12 | 0.80 | 0.82 / 0.13 | 0.69 / 0.11 | 0.77 / 0.13 | Center easily biased by outliers, ASR surges |
| w/o Topic-Direction Removal | 0.62 | 0.58 / 0.09 | 0.63 / 0.11 | 0.58 / 0.09 | 0.61 | 0.55 / 0.12 | 0.57 / 0.12 | 0.60 / 0.09 | 0.80 | 0.79 / 0.09 | 0.68 / 0.11 | 0.77 / 0.09 | Topic correlation masks factual contradictions |
| w/o Active Subspace Selection | 0.63 | 0.53 / 0.12 | 0.54 / 0.09 | 0.52 / 0.10 | 0.63 | 0.63 / 0.09 | 0.53 / 0.12 | 0.54 / 0.15 | 0.80 | 0.74 / 0.08 | 0.70 / 0.15 | 0.74 / 0.08 | High-dimensional noise inflates distance errors |
| w/o Adaptive Norm Clipping | 0.65 | 0.61 / 0.07 | 0.63 / 0.10 | 0.58 / 0.07 | 0.67 | 0.54 / 0.17 | 0.56 / 0.09 | 0.57 / 0.11 | 0.82 | 0.76 / 0.10 | 0.70 / 0.14 | 0.72 / 0.14 | Unbounded shifts distort centering |
| w/ Fixed Radius | 0.63 | 0.59 / 0.11 | 0.63 / 0.10 | 0.61 / 0.08 | 0.66 | 0.58 / 0.09 | 0.54 / 0.10 | 0.57 / 0.11 | 0.82 | 0.71 / 0.11 | 0.69 / 0.09 | 0.80 / 0.09 | Fails to adapt to query-specific dispersion |
Key Findings¶
- Crucial Role of Geometric Median: Replacing the geometric median with an arithmetic mean causes the most dramatic surge in ASR (nearly doubling on HotpotQA and MS-MARCO to 0.13), demonstrating the necessity of robust aggregation when estimating consensus from partially corrupted sets.
- Resilience to Varied Poisoning Techniques: While instruction-based and attention-attenuation baselines collapse under generative attacks like Adversarial Decoding (CrAM reaches ASR of 0.56 on HotpotQA), RAGSentinel maintains an ASR below 0.09, proving that latent geometric shifts persist regardless of token-level fluency.
- Negligible Computational Overhead: Inference timing benchmarks (Table 3) reveal that RAGSentinel requires only 0.85-1.16 s/query, operating more than \(3\times\) faster than RobustRAG (2.44-3.62 s) and over \(2\times\) faster than AstuteRAG (2.13-2.96 s), introducing virtually no pipeline bottleneck.
- Robustness Against Full-Knowledge Adaptive Attackers: When evaluated against three adaptive attacks designed with full knowledge of RAGSentinel's algorithmic steps (Anchor mimicry, Norm boundary, Subspace camouflage; Table 7), RAGSentinel limits ASR to 0.03-0.11 across all benchmarks, consistently surpassing all baselines.
Highlights & Insights¶
- Repurposing Latent Probing as an Input Filter: Rather than inspecting generated outputs for hallucination after generation, RAGSentinel repurposes internal hidden states inside an independent surrogate encoder to vet context before the generator is invoked.
- The Byzantine-to-Representation Geometry Bridge: By conceptualizing retrieved passages as distributed workers and malicious passages as Byzantine nodes, the paper elegantly ports provable geometric median aggregation into NLP context sanitization.
- Pure Black-Box Decoupling: The defense requires zero access to the deployed LLM's weights, gradients, or logits, enabling seamless deployment across commercial proprietary APIs (e.g., GPT-4) and local models alike.
Limitations & Future Work¶
- Honest-Majority Boundary: The formal certifiable guarantee relies strictly on the condition that benign passages outnumber poisoned passages (\(k' < k/2\)). If an attacker achieves majority database infiltration, the geometric anchor will shift toward the adversary.
- Surrogate Black-Box Assumption: The defense assumes the adversary does not possess white-box query access to the specific surrogate encoder \(f_\varphi\). Direct end-to-end optimization against \(f_\varphi\) remains an open challenge.
- Low-Resource Language Geometry: In low-resource domains or non-English corpora, surrogate embedding spaces may exhibit less structured manifold geometries, potentially degrading the separation gap \(\gamma\).
Related Work & Insights¶
- vs RobustRAG (Xiang et al., 2024): RobustRAG performs isolated generation over every passage followed by keyword aggregation, incurring prohibitive latency and sacrificing inter-document reasoning. RAGSentinel leverages geometric consensus across passages in a single forward pipeline.
- vs AstuteRAG (Wang et al., 2025): AstuteRAG relies on parametric internal knowledge to resolve contradictions, which fails when LLMs lack domain facts. RAGSentinel relies purely on input representation geometry without assumptions on parametric memory.
- vs CrAM (Deng et al., 2025): CrAM modifies internal attention weights via causal tracing, requiring white-box model access while still leaving malicious tokens in the context window. RAGSentinel physically excises poisoned passages via clean black-box filtering.
Rating¶
- Novelty: ⭐⭐⭐⭐⭐ First framework to cast RAG knowledge defense into surrogate latent shift geometry with Byzantine guarantees.
- Experimental Thoroughness: ⭐⭐⭐⭐⭐ Comprehensive evaluation across 3 datasets, 3 LLM families, 3 standard attacks, 3 adaptive attacks, and mixed-poison settings.
- Writing Quality: ⭐⭐⭐⭐⭐ Flawless narrative arc, lucid mathematical foundations, and intuitive case study breakdowns.
- Value: ⭐⭐⭐⭐⭐ High practical impact for securing commercial and enterprise RAG deployments with negligible compute overhead.