Demo Data

A tiny, source-linked RAG history corpus for deterministic experiments.

src/rag_evolution/demo_data.py · 276 lines · sha256 85effa8b193c…

"""A tiny, source-linked RAG history corpus for deterministic experiments."""

from typing import List

from .models import Document, QuestionExample


def demo_documents() -> List[Document]:
    """Return compact paper summaries; these are teaching data, not the review itself."""

    return [
        Document(
            id="dpr-2020",
            title="Dense Passage Retrieval (DPR)",
            date="2020-04-10",
            source="https://aclanthology.org/2020.emnlp-main.550/",
            metadata={"entities": ("DPR", "dense retrieval", "Wikipedia", "RAG")},
            text=(
                "Dense Passage Retrieval (DPR) for Open-Domain Question Answering introduced a simple "
                "dual-encoder retriever trained with positive passages, in-batch negatives, and a "
                "hard BM25 negative. It represented questions and passages independently, scored "
                "them by inner product, and indexed about 21 million Wikipedia passages with FAISS. "
                "The system improved answer-containing top-20 recall over BM25 on Natural Questions but "
                "underperformed BM25 on the lexically biased SQuAD benchmark."
            ),
        ),
        Document(
            id="rag-2020",
            title="Retrieval-Augmented Generation (RAG)",
            date="2020-05-22",
            source="https://proceedings.neurips.cc/paper/2020/hash/6b493230205f780e1bc26945df7481e5-Abstract.html",
            metadata={"entities": ("RAG", "DPR", "BART", "Wikipedia", "latent documents")},
            text=(
                "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks coupled a DPR "
                "question encoder with a frozen passage index and a BART generator. RAG-Sequence "
                "marginalized one latent document for the whole output, whereas RAG-Token could "
                "marginalize a different document at every generated token. The task likelihood "
                "updated the generator and query encoder, but did not guarantee that generated "
                "claims were entailed by the retrieved passage."
            ),
        ),
        Document(
            id="fid-2021",
            title="Fusion-in-Decoder (FiD)",
            date="2020-07-02",
            source="https://aclanthology.org/2021.eacl-main.74/",
            metadata={"entities": ("FiD", "DPR", "T5", "multi-passage fusion")},
            text=(
                "Fusion-in-Decoder encoded each question-passage pair independently with T5, "
                "concatenated the encoded representations, and let one decoder attend jointly "
                "across all passages. This avoided quadratic encoder self-attention across one "
                "giant concatenation and scaled experiments to 100 retrieved passages. Retrieval "
                "remained fixed and separate from the generator."
            ),
        ),
        Document(
            id="retro-2022",
            title="RETRO", 
            date="2021-12-08",
            source="https://proceedings.mlr.press/v162/borgeaud22a.html",
            metadata={"entities": ("RETRO", "language modeling", "MassiveText", "retrieval pretraining")},
            text=(
                "RETRO divided language-model inputs into 64-token chunks and retrieved nearest "
                "neighbor chunks plus their continuations from a datastore measured in trillions "
                "of tokens. Chunked cross-attention injected that memory while preserving causal "
                "prediction. Its frozen BERT retriever and enormous index exposed leakage, copying, "
                "storage, and licensing risks as well as the benefit of scaling non-parametric memory."
            ),
        ),
        Document(
            id="atlas-2022",
            title="Atlas",
            date="2022-08-05",
            source="https://jmlr.org/papers/v24/23-0037.html",
            metadata={"entities": ("Atlas", "Contriever", "FiD", "retrieval pretraining")},
            text=(
                "Atlas combined a Contriever dual encoder, a T5 Fusion-in-Decoder reader, and "
                "retrieval-augmented pretraining. It compared attention, EMDR2, and likelihood "
                "distillation objectives that transfer the reader's signal into the retriever. "
                "Swapping only the index between 2017 and 2020 facts demonstrated how an external "
                "memory can update temporal knowledge without retraining all model parameters."
            ),
        ),
        Document(
            id="hyde-2022",
            title="HyDE",
            date="2022-12-20",
            source="https://arxiv.org/abs/2212.10496",
            metadata={"entities": ("HyDE", "Contriever", "query transformation", "dense retrieval")},
            text=(
                "Hypothetical Document Embeddings, or HyDE, asks an instruction-tuned generator to "
                "write a hypothetical answer document and embeds that document with Contriever to "
                "retrieve real evidence. It needs no relevance labels and can bridge vocabulary "
                "mismatch, but a hallucinated hypothetical document can drift away from the user's "
                "intent. The original work evaluated retrieval quality, not answer faithfulness."
            ),
        ),
        Document(
            id="self-rag-2023",
            title="Self-RAG",
            date="2023-10-17",
            source="https://openreview.net/forum?id=hSyW5go0v8",
            metadata={"entities": ("Self-RAG", "reflection tokens", "adaptive retrieval", "citations")},
            text=(
                "Self-RAG trained a language model to emit reflection tokens that decide whether "
                "to retrieve and judge passage relevance, claim support, and answer usefulness. A "
                "critic learned labels produced with GPT-4, then annotated instruction data for the "
                "generator. Reflection-token scores control segment-level decoding, but self-critique "
                "is not a formal guarantee that a citation entails its claim."
            ),
        ),
        Document(
            id="crag-2024",
            title="Corrective Retrieval-Augmented Generation (CRAG)",
            date="2024-01-29",
            source="https://arxiv.org/abs/2401.15884",
            metadata={"entities": ("CRAG", "Self-RAG", "web search", "adaptive retrieval")},
            text=(
                "Corrective Retrieval-Augmented Generation used a trained evaluator to classify "
                "retrieved knowledge as correct, ambiguous, or incorrect. It filtered decomposed "
                "knowledge strips when confidence was high and rewrote the query for web search "
                "when confidence was low. Its thresholds, web source quality, latency, privacy, and "
                "changing search results are important deployment limitations."
            ),
        ),
        Document(
            id="raptor-2024",
            title="RAPTOR",
            date="2024-01-31",
            source="https://openreview.net/forum?id=GN921JHCRw",
            metadata={"entities": ("RAPTOR", "hierarchical retrieval", "summarization", "tree index")},
            text=(
                "RAPTOR recursively embedded, clustered, and summarized chunks to construct a tree "
                "whose leaves preserve local text and whose higher levels represent broader themes. "
                "A query can retrieve nodes from different abstraction levels, helping long-document "
                "questions. Building and updating the tree is expensive, and summary errors or "
                "omissions can propagate upward through the hierarchy."
            ),
        ),
        Document(
            id="graphrag-2024",
            title="GraphRAG for global sensemaking",
            date="2024-04-24",
            source="https://arxiv.org/abs/2404.16130",
            metadata={"entities": ("GraphRAG", "knowledge graph", "community summaries", "global questions")},
            text=(
                "Microsoft's GraphRAG extracted entities, relationships, and claims, partitioned the "
                "resulting graph into hierarchical Leiden communities, and generated community "
                "reports. A map-reduce query process synthesized reports for global questions about "
                "an entire corpus. It is not universally superior to vector search: local fact lookup, "
                "indexing cost, entity resolution, stale summaries, and LLM-judge evaluation remain "
                "material limitations."
            ),
        ),
        Document(
            id="colpali-2024",
            title="ColPali",
            date="2024-06-27",
            source="https://arxiv.org/abs/2407.01449",
            metadata={"entities": ("ColPali", "multimodal RAG", "late interaction", "document images")},
            text=(
                "ColPali retrieved visually rich document pages without first reducing them to OCR "
                "text. PaliGemma encoded page-image patches and query tokens, then ColBERT-style "
                "MaxSim late interaction scored every query token against visual patch vectors. "
                "This preserves layouts, figures, and tables but creates a larger multi-vector index "
                "and originally evaluated retrieval rather than full answer grounding."
            ),
        ),
        Document(
            id="search-r1-2025",
            title="Search-R1",
            date="2025-03-06",
            source="https://openreview.net/forum?id=Rwhi91ideu",
            metadata={"entities": ("Search-R1", "reinforcement learning", "agentic RAG", "search")},
            text=(
                "Search-R1 used outcome-based reinforcement learning so a language model could "
                "interleave reasoning with multiple search calls and mask retrieved tokens from the "
                "policy loss. This moved beyond hand-written retrieval workflows, but answer-only "
                "rewards do not prove that intermediate reasoning is faithful and can permit reward "
                "hacking or unnecessarily expensive searches."
            ),
        ),
        Document(
            id="lara-2025",
            title="LaRA: RAG versus long context",
            date="2025-02-14",
            source="https://arxiv.org/abs/2502.09977",
            metadata={"entities": ("LaRA", "long context", "routing", "RAG")},
            text=(
                "LaRA benchmarked retrieval-augmented generation against long-context language "
                "models on 2,326 cases spanning four question-answering categories and three kinds "
                "of natural long text. It found no silver bullet: the better choice depended on "
                "model size, long-context capability, input length, task, and retrieved chunk "
                "characteristics. A router therefore needs domain-specific calibration rather than "
                "a universal context-length threshold."
            ),
        ),
        Document(
            id="grip-2026",
            title="GRIP: Retrieval as Generation",
            date="2026-07-01",
            source="https://aclanthology.org/2026.acl-long.196/",
            metadata={"entities": ("GRIP", "agentic RAG", "reinforcement learning", "retrieval control")},
            text=(
                "GRIP embedded retrieval control directly in autoregressive generation with control "
                "tokens for retrieval, intermediary reasoning, answers, and termination. Its self-"
                "triggered information planning decides when to retrieve, how to reformulate a "
                "query, and when to stop in one trajectory. On five short-form QA benchmarks the "
                "reported mean was 41.0 with at most three BM25 calls; increasing the budget to ten "
                "gave only a small gain, highlighting diminishing returns."
            ),
        ),
    ]


def demo_questions() -> List[QuestionExample]:
    """Questions with document-level relevance labels and compact reference answers."""

    return [
        QuestionExample(
            id="q-dpr",
            question="Which 2020 system used dual encoders and hard BM25 negatives?",
            relevant_document_ids=("dpr-2020",),
            reference_answer="DPR used independent question and passage encoders with hard BM25 negatives.",
            tags=("single-hop", "lexical"),
        ),
        QuestionExample(
            id="q-fid",
            question="How did Fusion-in-Decoder combine evidence from many passages?",
            relevant_document_ids=("fid-2021",),
            reference_answer="FiD encoded passages separately and let one decoder attend over their concatenated representations.",
            tags=("single-hop", "architecture"),
        ),
        QuestionExample(
            id="q-rag-dpr",
            question="What is the relationship and difference between DPR and the original RAG model?",
            relevant_document_ids=("dpr-2020", "rag-2020"),
            reference_answer="DPR supplies dense passage retrieval; RAG couples that retrieval with BART and marginalizes latent documents during generation.",
            tags=("multi-hop", "comparison"),
        ),
        QuestionExample(
            id="q-self-rag",
            question="Which approach used reflection tokens to decide whether to retrieve and judge support?",
            relevant_document_ids=("self-rag-2023",),
            reference_answer="Self-RAG used reflection tokens for retrieval, relevance, support, and usefulness decisions.",
            tags=("single-hop", "adaptive"),
        ),
        QuestionExample(
            id="q-raptor",
            question="Which technique recursively clusters and summarizes chunks into a tree?",
            relevant_document_ids=("raptor-2024",),
            reference_answer="RAPTOR builds a recursive tree of clustered chunks and summaries.",
            tags=("single-hop", "hierarchical"),
        ),
        QuestionExample(
            id="q-visual",
            question="How does ColPali retrieve tables and visually rich document pages?",
            relevant_document_ids=("colpali-2024",),
            reference_answer="ColPali applies late interaction between query-token vectors and document-page image patch vectors.",
            tags=("single-hop", "multimodal"),
        ),
        QuestionExample(
            id="q-long-context",
            question="Does long context universally outperform RAG according to LaRA?",
            relevant_document_ids=("lara-2025",),
            reference_answer="No; LaRA found the better choice depends on the model, task, input length, and retrieved chunks.",
            tags=("single-hop", "routing"),
        ),
        QuestionExample(
            id="q-grip",
            question="Which 2026 framework decides when, how, and when to stop retrieval inside generation?",
            relevant_document_ids=("grip-2026",),
            reference_answer="GRIP emits retrieval-control tokens inside autoregressive generation.",
            tags=("single-hop", "agentic"),
        ),
    ]