{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/arxiv-2607-26339","title":"RAGuard: A Layered Defense Framework for Retrieval-Augmented Generation Systems Against Data Poisoning","arxiv_id":"2607.26339","date":"2026-07-28","proceeding":null,"authors":["Pushkal Kumar","Tucker Nielson","Tanish Kolhe","Shubham Zala","Vincent Li"],"abstract":"Retrieval-Augmented Generation (RAG) systems ground large language models (LLMs) in external corpora, but this reliance exposes them to corpus poisoning: maliciously injected passages that manipulate retrieved evidence. We introduce RAGuard, a layered defense against \\emph{factual} corpus-poisoning attacks on RAG pipelines. The first layer adversarially fine-tunes a dense retriever on synthetic poisoned documents (fabricated facts, contradictions, and reasoning traps), teaching it to downrank malicious passages before generation. The second layer, the Zero-Knowledge Inference Patch ZKIP, is a label-free, black-box filter: for each retrieved document, it performs a leave-one-out decode and scores the document by the semantic shift and output-entropy change that its removal induces. ZKIP requires no poison labels, no ground-truth answers, and no access to model internals; it compares the model's own answers under counterfactual contexts. On poisoned Natural Questions at 5--30\\% poison ratios, adversarial retriever training alone reduces but does not eliminate attack success, while ZKIP drives the measured attack success rate to 0.000 in every defended configuration, keeping Recall@5 within 0.03 of the clean-corpus baseline. Supervised analyses on both Natural Questions and BEIR (NFCorpus) confirm that the counterfactual signals ZKIP relies on carry learnable poison structure. The defense costs $k{+}1$ generator passes per query ($6\\times$ for $k{=}5$); we analyze batching and early-stopping approximations that reduce this overhead. We also show that keyword-preserving poisons leave lexical retrievers such as BM25 essentially unaffected, an observation that delineates the boundary of the threat model. Code, datasets, and evaluation harnesses are released for reproducibility.","url_abs":"https://arxiv.org/abs/2607.26339","url_pdf":"https://arxiv.org/pdf/2607.26339","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2607.26339","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2607.26339"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/RAGuard-AI/RAGuard","reach":null}],"summary":{"ran":13,"unverified":1},"by_repo_kind":{"found_in_text":{"samples":14,"ran":13,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"91f383fbaf3371b9","entry":"bm25_topk","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"run_eval.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/run_eval.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"91f383fbaf3371b9"}},{"code_sha256_prefix":"cf8c7150e4ab53bb","entry":"cosine","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"zkip.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/zkip.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cf8c7150e4ab53bb"}},{"code_sha256_prefix":"81076a2476f2505d","entry":"em","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"defences/scorer.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/defences/scorer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"81076a2476f2505d"}},{"code_sha256_prefix":"5d651d0039786fb0","entry":"evaluate_bert","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"defences/bert_classifier.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/defences/bert_classifier.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5d651d0039786fb0"}},{"code_sha256_prefix":"c31fa0dc73b0f2e6","entry":"f1","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"defences/scorer.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/defences/scorer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c31fa0dc73b0f2e6"}},{"code_sha256_prefix":"0987423f71997748","entry":"get_feature_importance","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"defences/classifier.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/defences/classifier.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0987423f71997748"}},{"code_sha256_prefix":"0cb69b02b952e6fe","entry":"group_by_field","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"datasets/make_splits.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/datasets/make_splits.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0cb69b02b952e6fe"}},{"code_sha256_prefix":"44b364cc1662e154","entry":"load_dataset","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"run_eval.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/run_eval.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"44b364cc1662e154"}},{"code_sha256_prefix":"6fdb338a20943930","entry":"load_dataset","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"run_eval_combined_v2.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/run_eval_combined_v2.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6fdb338a20943930"}},{"code_sha256_prefix":"e44390a1ed1e2cfc","entry":"load_feature_table","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"defences/bert_classifier.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/defences/bert_classifier.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e44390a1ed1e2cfc"}},{"code_sha256_prefix":"c4aada83da34342a","entry":"split_groups","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"datasets/make_splits.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/datasets/make_splits.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c4aada83da34342a"}},{"code_sha256_prefix":"f5afb6fc044bb7b8","entry":"train_bert","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"defences/bert_classifier.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/defences/bert_classifier.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f5afb6fc044bb7b8"}},{"code_sha256_prefix":"cc5b7100997b65a0","entry":"train_logreg","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"defences/classifier.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/defences/classifier.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cc5b7100997b65a0"}},{"code_sha256_prefix":"b964030e79fbbb92","entry":"zkip_scores","repo":"RAGuard-AI/RAGuard","repo_kind":"found_in_text","path":"zkip.py","file_url":"https://github.com/RAGuard-AI/RAGuard/blob/HEAD/zkip.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b964030e79fbbb92"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.LG","source":"arxiv_2026.jsonl"},"syntology_extracted_results":{"kind":"leaderboard_placements","source":"Syntology's leaderboard-shaped extractor over the paper's own arXiv-HTML tables: a model pointed at a cell, the number was read from that cell and checked against the board's metric, dataset, split and scale, and an independent check accepted the entry; not reviewed by the paper's authors or the archive's editors","extractor_model":"global.anthropic.claude-sonnet-4-5-20250929-v1:0","verifier_model":null,"prompt_sha":"fa63d4bb9d755694","coverage":{"sentence":"Syntology has checked 6,795 of the 9,581 papers on this site that are newer than the archive; results from the others appear after they are checked.","papers_newer_than_archive":9581,"papers_checked":6795},"entries":[],"not_placed":{"boards":0,"rejected_by_independent_check":0,"refused_by_a_rule":0,"check_did_not_answer":0,"proposed_without_a_cell":0,"declined_by_site":0}}}