Spaces:
Running on Zero
Running on Zero
Download src/research.py from leeshal/EvidenceGuard-AI: direct link, hf CLI and curl.
- Browser
- Download file 15.8 kB
-
https://huggingface.co/spaces/leeshal/EvidenceGuard-AI/resolve/main/src/research.py
- Command line
-
hf download hf://spaces/leeshal/EvidenceGuard-AI/src/research.py
-
curl -L -o research.py https://huggingface.co/spaces/leeshal/EvidenceGuard-AI/resolve/main/src/research.py
15.8 kB
| """Verified literature used to motivate EvidenceGuard AI (shared by the app and the report). | |
| All bibliographic details were checked against the publisher / proceedings pages listed in `link`. | |
| Summaries are paraphrased; no result figures are claimed beyond what the papers' abstracts state. | |
| """ | |
| PAPERS = [ | |
| { | |
| "key": "Chen2024RGB", | |
| "title": "Benchmarking Large Language Models in Retrieval-Augmented Generation", | |
| "authors": "J. Chen, H. Lin, X. Han, L. Sun", | |
| "venue": "AAAI Conference on Artificial Intelligence (AAAI-24), vol. 38, no. 16", | |
| "year": 2024, | |
| "link": "https://doi.org/10.1609/aaai.v38i16.29728", | |
| "problem": "No systematic evaluation of how retrieved context helps or hurts different LLMs.", | |
| "method": "RGB benchmark (English + Chinese) testing four RAG abilities: noise robustness, negative " | |
| "rejection, information integration and counterfactual robustness; six LLMs evaluated.", | |
| "technologies": "Benchmark construction from news; prompting of 6 LLMs.", | |
| "results": "LLMs show some noise robustness but struggle with negative rejection (refusing when evidence " | |
| "is missing), integrating several documents, and handling false information.", | |
| "limitations": "Diagnoses failures but does not propose a remedy; general news domain.", | |
| "gap": "Need for mechanisms that refuse when evidence is missing and handle conflicting context.", | |
| "ours": "Our 5 question categories mirror RGB's abilities; EvidenceGuard adds explicit sufficiency-based " | |
| "abstention (negative rejection) and conflict detection (counterfactual / conflicting context).", | |
| }, | |
| { | |
| "key": "Asai2024SelfRAG", | |
| "title": "Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection", | |
| "authors": "A. Asai, Z. Wu, Y. Wang, A. Sil, H. Hajishirzi", | |
| "venue": "International Conference on Learning Representations (ICLR 2024), oral", | |
| "year": 2024, | |
| "link": "https://proceedings.iclr.cc/paper_files/paper/2024/hash/25f7be9694d7b32d5cc670927b8091e1-Abstract-Conference.html", | |
| "problem": "Indiscriminate retrieval of a fixed number of passages can produce unhelpful or unsupported output.", | |
| "method": "Trains an LM to emit reflection tokens that decide when to retrieve and critique relevance, " | |
| "support and usefulness of its own generations.", | |
| "technologies": "Fine-tuned Llama-2 7B/13B, critic model, reflection tokens.", | |
| "results": "Reported gains over ChatGPT and retrieval-augmented Llama2-chat on open-domain QA, reasoning, " | |
| "fact verification, and better factuality / citation accuracy in long-form generation.", | |
| "limitations": "Requires training a 7B+ model with special tokens; not usable on free CPU hardware.", | |
| "gap": "Training-free, CPU-friendly support critique for small institutions.", | |
| "ours": "We implement the 'is it supported?' critique as a training-free post-hoc citation validator " | |
| "(NLI + lexical/numeric support) that works with any small LLM.", | |
| }, | |
| { | |
| "key": "Yan2024CRAG", | |
| "title": "Corrective Retrieval Augmented Generation", | |
| "authors": "S.-Q. Yan, J.-C. Gu, Y. Zhu, Z.-H. Ling", | |
| "venue": "arXiv preprint arXiv:2401.15884 (2024)", | |
| "year": 2024, | |
| "link": "https://arxiv.org/abs/2401.15884", | |
| "problem": "RAG behaves poorly when retrieval returns irrelevant or wrong documents.", | |
| "method": "A lightweight retrieval evaluator scores retrieved documents; a confidence level triggers " | |
| "Correct / Incorrect / Ambiguous actions (refine, web search, or both).", | |
| "technologies": "T5-based retrieval evaluator, knowledge refinement, web search.", | |
| "results": "Improves standard RAG and Self-RAG on four short- and long-form generation datasets.", | |
| "limitations": "Falls back to open web search, which is inappropriate for closed institutional policy; " | |
| "does not detect conflicts between retrieved documents. Preprint (not peer reviewed).", | |
| "gap": "Confidence-gated behaviour without web fallback, i.e. abstain instead of searching the web.", | |
| "ours": "Our sufficiency check is a confidence gate in the spirit of CRAG, but the low-confidence action " | |
| "is a transparent abstention with an explanation, which suits closed policy corpora.", | |
| }, | |
| { | |
| "key": "Gao2023ALCE", | |
| "title": "Enabling Large Language Models to Generate Text with Citations", | |
| "authors": "T. Gao, H. Yen, J. Yu, D. Chen", | |
| "venue": "Proc. EMNLP 2023, pp. 6465-6488", | |
| "year": 2023, | |
| "link": "https://doi.org/10.18653/v1/2023.emnlp-main.398", | |
| "problem": "LLM answers are hard to verify; citation quality is rarely measured automatically.", | |
| "method": "ALCE benchmark with automatic metrics for fluency, correctness and citation quality " | |
| "(citation recall / precision judged with an NLI model).", | |
| "technologies": "ASQA, QAMPARI, ELI5; NLI-based citation evaluation; prompting strategies.", | |
| "results": "Even the best models lack complete citation support about half the time on ELI5.", | |
| "limitations": "Evaluates citations after the fact; does not change system behaviour.", | |
| "gap": "Use citation checking inside the pipeline to filter unsupported sentences before the user sees them.", | |
| "ours": "EvidenceGuard runs citation validation at inference time and removes unsupported sentences, " | |
| "abstaining if none remain.", | |
| }, | |
| { | |
| "key": "Yoran2024Robust", | |
| "title": "Making Retrieval-Augmented Language Models Robust to Irrelevant Context", | |
| "authors": "O. Yoran, T. Wolfson, O. Ram, J. Berant", | |
| "venue": "International Conference on Learning Representations (ICLR 2024)", | |
| "year": 2024, | |
| "link": "https://doi.org/10.48550/arXiv.2310.01558", | |
| "problem": "Irrelevant retrieved passages can reduce accuracy, especially in multi-hop questions.", | |
| "method": "(1) NLI-based filtering of passages that do not entail the question-answer pair; " | |
| "(2) fine-tuning with a mix of relevant and irrelevant contexts.", | |
| "technologies": "NLI filter, Llama-2 fine-tuning, five open-domain QA benchmarks.", | |
| "results": "NLI filtering prevents performance drops but also discards relevant passages; ~1,000 " | |
| "fine-tuning examples suffice for robustness.", | |
| "limitations": "NLI filtering is too aggressive; fine-tuning needs GPUs.", | |
| "gap": "Combine NLI with cheaper lexical/numeric signals rather than relying on NLI alone.", | |
| "ours": "We use NLI only as one vote, combined with numeric-value and polarity rules (NLI models are weak " | |
| "at numbers, which dominate policy text), and test 'misleading context' questions explicitly.", | |
| }, | |
| { | |
| "key": "Hou2024WikiContradict", | |
| "title": "WikiContradict: A Benchmark for Evaluating LLMs on Real-World Knowledge Conflicts from Wikipedia", | |
| "authors": "Y. Hou, A. Pascale, J. Carnerero-Cano, T. Tchrakian, R. Marinescu, E. Daly, I. Padhi, P. Sattigeri", | |
| "venue": "NeurIPS 2024 Datasets and Benchmarks Track", | |
| "year": 2024, | |
| "link": "https://doi.org/10.52202/079017-3481", | |
| "problem": "How LLMs handle contradictory retrieved passages of equal trustworthiness is unclear.", | |
| "method": "253 human-annotated instances of real inter-context conflicts; evaluates whether answers present " | |
| "a complete view of the conflict rather than picking one side; automated judge metric.", | |
| "technologies": "Human annotation, 7 LLMs, LLM-based evaluator.", | |
| "results": "LLMs frequently fail to surface both sides of a conflict, choosing one answer instead.", | |
| "limitations": "Benchmark only; no conflict-detection component; Wikipedia domain.", | |
| "gap": "A detector that surfaces both versions, plus which one is newer, for versioned institutional rules.", | |
| "ours": "EvidenceGuard detects inter-document conflicts, shows both versions with issue dates and names the " | |
| "newer document, matching WikiContradict's 'complete perspective' recommendation.", | |
| }, | |
| { | |
| "key": "Es2024RAGAS", | |
| "title": "RAGAs: Automated Evaluation of Retrieval Augmented Generation", | |
| "authors": "S. Es, J. James, L. Espinosa-Anke, S. Schockaert", | |
| "venue": "Proc. EACL 2024: System Demonstrations, pp. 150-158", | |
| "year": 2024, | |
| "link": "https://aclanthology.org/2024.eacl-demo.16", | |
| "problem": "RAG pipelines are hard to evaluate without human annotations.", | |
| "method": "Reference-free metrics for faithfulness, answer relevance and context relevance using LLM judges.", | |
| "technologies": "LLM-as-judge prompting, embeddings.", | |
| "results": "Metrics align reasonably with human judgements on the WikiEval dataset.", | |
| "limitations": "Needs a strong LLM judge (often paid APIs); judge errors propagate.", | |
| "gap": "Cheap, reproducible metrics for student projects with no paid API.", | |
| "ours": "We adopt RAGAS metric definitions (faithfulness, answer relevance, context precision/recall) but " | |
| "compute them deterministically against our gold evidence, so they are reproducible at zero cost.", | |
| }, | |
| { | |
| "key": "Niu2024RAGTruth", | |
| "title": "RAGTruth: A Hallucination Corpus for Developing Trustworthy Retrieval-Augmented Language Models", | |
| "authors": "C. Niu, Y. Wu, J. Zhu, S. Xu, K. Shum, R. Zhong, J. Song, T. Zhang", | |
| "venue": "Proc. ACL 2024 (Long Papers), pp. 10862-10878", | |
| "year": 2024, | |
| "link": "https://aclanthology.org/2024.acl-long.585", | |
| "problem": "Even with RAG, LLMs produce claims unsupported by or contradicting the retrieved content.", | |
| "method": "~18,000 RAG responses from several LLMs annotated at word level for hallucination; " | |
| "benchmarks detection methods and fine-tunes a small detector.", | |
| "technologies": "Manual annotation, fine-tuned Llama-2 detector, prompt-based GPT-4 baselines.", | |
| "results": "A fine-tuned relatively small LLM achieves hallucination detection competitive with GPT-4 prompting.", | |
| "limitations": "Detection only; English general-domain tasks (QA, data-to-text, summarisation).", | |
| "gap": "Prevent hallucinations reaching users in a specific, high-stakes domain (university rules).", | |
| "ours": "We measure the 'unsupported answer rate' (RAGTruth's core concern) and reduce it with gating " | |
| "before and after generation.", | |
| }, | |
| ] | |
| FOUNDATION = [ | |
| "P. Lewis et al., \"Retrieval-augmented generation for knowledge-intensive NLP tasks,\" in Proc. NeurIPS, 2020.", | |
| "N. Reimers and I. Gurevych, \"Sentence-BERT: Sentence embeddings using Siamese BERT-networks,\" in Proc. " | |
| "EMNLP-IJCNLP, 2019, pp. 3982-3992.", | |
| "J. Johnson, M. Douze and H. Jegou, \"Billion-scale similarity search with GPUs,\" IEEE Trans. Big Data, " | |
| "vol. 7, no. 3, pp. 535-547, 2021.", | |
| "S. Robertson and H. Zaragoza, \"The probabilistic relevance framework: BM25 and beyond,\" Foundations and " | |
| "Trends in Information Retrieval, vol. 3, no. 4, pp. 333-389, 2009.", | |
| "G. V. Cormack, C. L. A. Clarke and S. Buettcher, \"Reciprocal rank fusion outperforms Condorcet and " | |
| "individual rank learning methods,\" in Proc. ACM SIGIR, 2009, pp. 758-759.", | |
| "R. Nogueira and K. Cho, \"Passage re-ranking with BERT,\" arXiv:1901.04085, 2019.", | |
| ] | |
| RESEARCH_GAP = ( | |
| "Existing work either (a) diagnoses RAG failures on general-domain benchmarks (RGB, WikiContradict, RAGTruth), " | |
| "or (b) fixes them with trained models of 7B+ parameters or open-web fallback (Self-RAG, CRAG, Yoran et al.). " | |
| "We found no student-scale, training-free, CPU-only pipeline that combines evidence-sufficiency abstention, " | |
| "inter-document contradiction detection for *versioned* rules (amendment circulars superseding older " | |
| "regulations) and inference-time citation validation, evaluated on a controlled benchmark with labelled " | |
| "missing-information, misleading and conflicting questions. EvidenceGuard targets this integration gap. " | |
| "Counter-argument we acknowledge: each component exists in the literature; our contribution is the " | |
| "combination, the conflict-search retrieval step, the numeric-aware contradiction rules and the controlled " | |
| "evaluation - not a new learning algorithm." | |
| ) | |
| OBJECTIVES = [ | |
| "Build a modular baseline RAG system (PDF ingestion, Sentence-Transformer embeddings, FAISS, LLM generation, citations).", | |
| "Build EvidenceGuard RAG with hybrid retrieval, cross-encoder reranking, evidence sufficiency checking, " | |
| "contradiction detection, citation validation and confidence-based abstention with explanations.", | |
| "Create a synthetic, explicitly fictional university document collection and a 100-question benchmark " | |
| "covering answerable, multi-passage, missing, misleading and conflicting questions.", | |
| "Quantify retrieval, answer-quality, reliability and efficiency differences in a 4-configuration ablation.", | |
| "Deliver a demonstrable Gradio application deployable on free Hugging Face Spaces hardware.", | |
| ] | |
| LIMITATIONS = [ | |
| "All documents are synthetic and the questions were written by the system's authors: results do not " | |
| "establish real-world accuracy on genuine university policies.", | |
| "The rule components (numeric-conflict and polarity rules) were developed while inspecting the same question " | |
| "set; only the numeric thresholds were calibrated on a held-out DEV split. Test-split results are therefore " | |
| "optimistic and should be confirmed on new, independently written questions.", | |
| "The reported experiment in this repository was run with the OFFLINE fallback components (LSA embeddings, " | |
| "lexical reranker, rule-based verifier, extractive composer) because Hugging Face model downloads were " | |
| "blocked in the build environment. The Hugging Face model path is implemented and smoke-tested but its " | |
| "metrics must be produced by re-running scripts/run_evaluation.py --backend full.", | |
| "Answer correctness is keyword-based (all key facts must appear); it can reward verbose answers and " | |
| "penalise correct paraphrases (e.g. 'three' vs '3').", | |
| "The extractive composer cannot hallucinate new text, so 'faithfulness to context' is near-ceiling by design; " | |
| "evidence-grounded faithfulness and unsupported-answer rate are the more informative measures.", | |
| "EvidenceGuard over-abstains on some answerable multi-part and paraphrased questions (the main cost of the " | |
| "safety gain).", | |
| "No OCR: scanned PDFs without a text layer cannot be processed. Uploaded documents are shared by all users " | |
| "of a public Space session.", | |
| ] | |
| FUTURE = [ | |
| "Run the evaluation with the full Hugging Face model stack and a 1-3B instruction-tuned LLM; compare backends.", | |
| "Collect real (anonymised, permission-granted) university circulars and a blind, independently written question set.", | |
| "Learn the abstention threshold with conformal prediction to give a guaranteed error rate.", | |
| "Use document metadata (version, effective date, 'supersedes' links) as a knowledge graph to resolve conflicts automatically.", | |
| "Add OCR (e.g. Tesseract) for scanned notices and multilingual support (Kannada/Hindi circulars).", | |
| "Per-user document sessions and an admin interface for keeping the policy corpus current.", | |
| ] | |