In one line: Coined RAG: a DPR retriever and a BART generator fine-tuned jointly (query encoder and generator; the document encoder and index stay fixed), the retrieved documents treated as a latent variable and marginalised (RAG-Sequence against RAG-Token); state of the art on three of four open-domain QA sets (Natural Questions, WebQuestions, CuratedTrec), and knowledge updated by swapping the index, not the weights.
How far to trust it: Believe the mechanism, the hot-swap and the factuality gain; of the four open-domain QA "state of the art" claims two are clear (Natural Questions by about 2.6 standard errors, TriviaQA-Wiki) and two sit inside the noise (WebQuestions, CuratedTrec), and every result is one run. The evidence, judged.
Treat the retrieved Wikipedia passage as a hidden variable: a dense retriever picks the top k of 21M passages, a seq2seq generator writes the answer conditioned on each, the output sums over them weighted by the retriever, and the generation loss alone trains the query encoder, so knowledge lives in an index you can read and replace rather than only in weights.
Two memories in one model: a frozen passage index to read, a generator's weights to remember, and one loss that trains the query side. The paper's Figure 1 as a 3D stage, run by this page's trained toy RAG-Token on one held-out question:
Redrawn from Figure 1 (the arXiv paper is not CC BY, so no copy of the original). The query encoder and the generator are fine-tuned; the document encoder and the index stay fixed (§2.4). The example question and the five documents in the boxes are from this page's toy model (see Ask a trained toy RAG), not from the paper.
You need nothing beyond a seq2seq Transformer and dot-product retrieval; how retrieval is built today is mapped on Topic: rag-and-retrieval.
New terms. Parametric memory: what the generator's weights store. Non-parametric memory: the passage index, readable and replaceable. Latent document: the passage the answer depends on, never labelled, summed over. RAG-Sequence and RAG-Token: one passage for the whole answer, or a new mixture at every token. MIPS: maximum inner product search, the top k by dot product. Hot-swapping: replacing the index at test time without retraining.
By 2020, pretrained language models demonstrably stored facts in their parameters (GPT-2, T5): T5 fine-tuned to answer with no documents, "closed-book", was competitive with retrieval systems (Roberts et al. 2020). But parametric knowledge has three structural flaws (§1):
Hybrid parametric plus non-parametric models existed. REALM and ORQA combine a masked language model with a differentiable retriever, but they "have only explored open-domain extractive question answering": they point at a span of a retrieved passage, they do not generate (§1).
The gap: a general-purpose fine-tuning recipe that gives any pretrained seq2seq generator a differentiable, non-parametric memory, applicable to the whole range of generation and classification tasks, with both memories pretrained and pre-loaded with knowledge.
RAG treats the retrieved document as a latent variable in a probabilistic seq2seq model and trains retriever and generator jointly, end to end, with no supervision on which document to retrieve (§2, §2.4). The paper names the two halves: the generator's weights are the parametric memory, the dense vector index of Wikipedia is the non-parametric memory (§2.2, §2.3). The hero figure above is the paper's Figure 1.
Retriever: DPR. pη(z|x) is DPR, a bi-encoder of two BERT-base networks (§2.2):
pη(z|x) ∝ exp(d(z)⊤q(x)), d(z) = BERTd(z), q(x) = BERTq(x)
The top k by this score is a Maximum Inner Product Search (MIPS), solved approximately in sub-linear time. The memory is the December 2018 Wikipedia dump split into disjoint 100-word chunks, 21M documents (about 2.1 billion words), embedded once into a FAISS index with a Hierarchical Navigable Small World (HNSW) approximation (§3; how HNSW works is on Vector indexes, how bi-encoders are trained on Embedding models). The retriever starts from DPR's bi-encoder, which "was trained to retrieve documents which contain answers to TriviaQA questions and Natural Questions" (§2.2): RAG's own training uses no retrieval labels, but its starting point did.
Generator: BART. pθ(yi|x, z, y1:i−1) could be any encoder-decoder; the paper uses BART-large, a denoising-pretrained seq2seq Transformer of "400M parameters" (§2.3; 406M in Appendix G). Input x and passage z are "simply" concatenated.
The evidence document is never observed, so the output sums over the top k documents, weighted by the retriever, in two ways (§2.1):
For classification (a target of length one, such as a FEVER label) the two are the same model.
Neither, in this toy, and why is the most useful thing it shows. RAG-Sequence cannot by construction: each document must explain the whole answer, and none holds both titles. RAG-Token can represent the answer, but only if the document lacking a title is unsure at that title. It is not: each book document's generator copies its own title with full confidence, the two tie at about one half, and greedy decoding interleaves their syllables (step through the stage). Training cannot fix it: RAG-Token's gradient reaches a document's prediction for a token in proportion to how well that document already explains it, so a document that cannot explain a title gets no signal to stay quiet. Held-out exact match: RAG-Token , RAG-Sequence , with both documents retrieved every time.
The paper's Figure 2 shows real BART has that calibration, presumably from its large-scale pretraining; this 46K-parameter generator, pretrained only to copy, does not. Even so, RAG-Token's real gain over RAG-Sequence on Jeopardy is small (Q-BLEU-1 22.2 against 21.4), and FiD's later answer was to let the decoder read all passages at once (Then and now).
Computed in your browser by the trained toy models (details), k = 5; bar heights are probabilities, to scale. Decoding as §2.5: greedy on the mixture for RAG-Token, greedy per document plus Thorough Decoding for RAG-Sequence.
Training. Minimise the negative marginal log-likelihood Σj −log p(yj|xj) with Adam (§2.4). Only the query encoder BERTq and the BART generator are fine-tuned; the document encoder and the index stay frozen, because re-embedding and re-indexing 21M passages during training, as REALM does, is costly, and the authors "do not find this step necessary for strong performance". Retrieval is learned purely from the generation loss: the gradient reaches the query encoder only through the pη(z|x) weights, raising documents in proportion to how well they explain the target (a document's gradient is its posterior minus its prior; standard calculus, not stated in the paper). Training retrieves 5 or 10 documents, with no significant difference (§4.5).
Decoding (§2.5). RAG-Token's per-token mixture plugs into a standard beam decoder. RAG-Sequence does not decompose per token, so the paper runs one beam search per document and scores each hypothesis with an extra forward pass for every document whose beam did not contain it ("Thorough Decoding"), or skips those passes by treating such hypotheses as having probability about zero ("Fast Decoding").
QA uses greedy decoding, 15 documents for RAG-Token and 50 for RAG-Sequence with Thorough Decoding; MS-MARCO and Jeopardy use 10 documents, beam 4 and Fast Decoding (Appendix A).
Tried and dropped: a REALM-style "null document" for inputs with nothing useful to retrieve did not help (Appendix F; on MS-MARCO the model instead learned to retrieve a fixed set of documents for such questions). On some tasks, such as story generation, retrieval "collapsed" to the same documents for every input, after which RAG behaved like BART (Appendix H).
Six task families against one Wikipedia index; sizes in Table 7, every table rebuilt and recomputed in the tables tab.
RAG-Sequence reaches 44.5 exact match on Natural Questions against 41.5 for DPR's pipeline and 36.6 for closed-book T5-11B+SSM; TriviaQA 56.8 on the standard split and 68.0 on the Wikipedia test split T5 used; WebQuestions 45.5 (RAG-Token) and CuratedTrec 52.2 (RAG-Sequence). The text claims a new state of the art on all four, "only on the T5-comparable split for TQA" (§4.1); the abstract says three. A generator beats extractive readers on extractive tasks, without REALM's and T5+SSM's "salient span masking" pretraining and with no re-ranker: "neither a re-ranker nor extractive reader is necessary".
11.8%, where an extractive model scores exactly 0% (§4.1): the generator answers from its parametric memory, or assembles the answer from clues. The "two memories" claim in one number.
Table 4 as printed, 452 pairs of Jeopardy questions. Factuality sums to 100.0%; specificity sums to 93.0%, so 7% of pairs are missing from the table (dashed; see How much of this to believe).
A frozen retriever is worse on every task (one tie), most on QA: WebQuestions drops 9.4 points for RAG-Token. BM25 scores as the logits of p(z|x) cost 8 to 20 points on QA but at most 1.0 on RAG-Token's generation metrics, and BM25 is best on FEVER (75.1 against 74.5), plausibly because FEVER claims are entity-centric (§4.5). More documents at test time (Figure 3) keep improving NQ for RAG-Sequence, while RAG-Token peaks at 10; on MS-MARCO they raise RAG-Token's Rouge-L at the expense of BLEU-1 (described, not redrawn: the figure prints no values).
Parametric-only models like T5 or BART need further training to change what they know. RAG's knowledge can be replaced at test time. The test (§4.5): build a second index from the DrQA Wikipedia dump of December 2016, list 82 world leaders who changed between the two dumps, and ask the NQ RAG model "Who is {position}?" (for example "Who is the President of Peru?") with each index.
70% of 2016 leaders with the 2016 index, and 68% of 2018 leaders with the 2018 index; mismatched, 12% (2018 index, 2016 leaders) and 4% (2016 index, 2018 leaders) (§4.5). World knowledge updated by replacing the non-parametric memory, with zero retraining. The same experiment on the toy model, live (it has its own 2016 and 2018 indexes, with 120 of 300 presidents changed):
Out of 82, the paper's percentages are 57, 56, 10 and 3 leaders (69.5%, 68.3%, 12.2%, 3.7%); with 82 questions each has a binomial standard error of about 5 points at 70% (√(0.7 × 0.3 / 82)), so 70 against 68 is a tie and 70 against 12 is not.
What holds up. Natural Questions has 3,611 test questions, so 44.5 against DPR's 41.5 is a 3.0-point lead against a standard error of about 1.2 (√(p(1 − p)/n) for each system, combined): about 2.6 standard errors. TriviaQA-Wiki's 7.5-point lead over T5-11B+SSM is far beyond plausible noise (the paper does not give that test set's size). FEVER's 10,000 test claims put its 4.3-point gap far outside a 0.45-point noise, and the hot-swap's 70% against 12% dwarfs its 5 points. The structure has held up best of all: every later retrieval-augmented system keeps the frozen index and retrieve-then-generate (Then and now).
What to discount.
Verdict. Believe the mechanism, the hot-swap and the human-judged factuality gain, and the Natural Questions and TriviaQA-Wiki leads. Read "state of the art on all four" as two clear wins and two ties, and treat sub-point ablation differences as unproven: every number is one run.
This paper coined "RAG", and what it proposed differs substantially from what the term now means. The original is a trained model, not a prompting pattern. Documents are latent variables, the likelihood marginalises over them, and the generation loss trains the query encoder end to end. Both marginalisations exist because the model must combine evidence probabilistically rather than just read it.
Modern usage kept the name and the architecture diagram, and dropped the training. The dominant pattern since 2023: embed the query with an off-the-shelf embedding model, run approximate nearest-neighbour search in a vector database, concatenate the top-k chunks into the prompt of a frozen instruction-tuned LLM, generate. No marginalisation (the LLM attends over all chunks at once, closer to Fusion-in-Decoder than to RAG-Token), no gradient into the retriever, no joint objective; In-Context RALM names it: "prepending grounding documents to the input, without any further training of the LM". Why the shift: in-context learning got strong enough that concatenation works without fine-tuning, frontier LLMs are frozen behind APIs, and a pipeline you rebuild by re-chunking a document base is far simpler to run than co-training a retriever and a generator. The end-to-end idea survives in research descendants (REALM before it; FiD, RETRO and Atlas after, and REPLUG, which trains only the retriever from a frozen LM's likelihoods), while the deployed world runs the frozen version.
What did survive is most of the paper: dense bi-encoder retrieval over chunked passages (DPR's BERT bi-encoder is the ancestor of every modern embedding model); fixed, roughly 100-word chunking into a searchable index; MIPS and approximate nearest-neighbour search as the retrieval primitive (FAISS then, dedicated vector databases now); grounding to reduce hallucination and give provenance; and the killer operational argument, update knowledge by updating the index, not the weights. The modern stack is this architecture with the learning removed and the engineering scaled up, and each part is taught on its own page: embedding models, vector indexes, chunking and the retrieval pipeline, rerankers, agentic retrieval and GraphRAG (the GraphRAG paper); the Gao et al. survey's Naive, Advanced and Modular RAG is the usual map, and the topic root draws the stages.
For open-domain QA it also settled an argument of its moment: one general retrieve-and-generate recipe beat both closed-book giants (T5-11B has 11 billion trainable parameters against RAG's 516M trained; the closest-sized T5, T5-large at 770M, scores 28.9 on NQ, Appendix G) and specialised extractive pipelines, across four benchmarks, clearly on two.
A real RAG model, trained offline the way §2 describes and run here in your browser: a retriever pη(z|x) ∝ exp(d(z)⊤q(x)) with separate query and document encoders, maximum inner product search over the whole index, a pretrained encoder-decoder generator reading each retrieved document concatenated with the question, and both marginalisations. Its non-parametric memory is a made-up encyclopedia of short documents about 300 countries, 420 people and 150 authors, in two editions, "2016" and "2018", in which 120 of the 300 presidents differ. Every name is three syllables from a pool of 60, so an entity the model never saw in training is a new combination of familiar pieces.
Try: ask about a held-out country (its facts were never a training answer, so the model must read them). Then switch the index to 2016 and ask again: the same weights give the 2016 president. Then pick "novels by" for a held-out author and compare RAG-Token with RAG-Sequence. Or rewrite a document below and watch the answer follow it.
The document encoder re-embeds whatever you write, and the index changes with no retraining: the paper's "human-writable" memory (§5). Pick a country and give it a new president, then ask who leads it.
Exact match on held-out questions (entities whose facts never appeared as a training answer), recomputed when the weights were exported (6-bit weights, as shipped) for the two models in this page, and from the training logs for the variants that are not shipped. Retrieval recall is the share of questions whose gold document or documents are all in the top 5.
Scripts: src/world.py (the encyclopedia and the questions), src/train.py (pretraining, fine-tuning, export), src/check_forward.py (JavaScript against PyTorch). The world is generated from a fixed seed; the in-browser test above draws the same held-out questions.
Every table that carries the argument, transcribed from the arXiv HTML v4 with the printed precision kept (src/tables.json), and every derived number recomputed by src/recompute.py. Standard errors are binomial, √(p(1 − p)/n), with n from Table 7; for a difference of two systems on the same test set they are combined as if independent, which overstates the noise of a paired comparison, so a margin that clears it clears it with room.
* reads gold context or evidence. On FEVER the two RAG models are one model (classification, §2.1); the HTML prints one value spanning both rows. Defaults reproduce the text's +2.6 BLEU-1 and +2.6 Rouge-L on MS-MARCO and the 4.3 and 2.7 FEVER gaps, independently, from the table.
The ratio of distinct to total trigrams in each model's generations, as printed: higher is more diverse. On both tasks RAG-Sequence is above RAG-Token and both are above BART, "without needing any diversity-promoting decoding" (§4.5, Table 5); the gold references sit at about 90%.
RAG's pipeline has four parts: a query encoder, a document index, a way to combine the retrieved documents, and a generator. Every later system keeps the four; what changed is which parts are trained, and how the documents are combined. Step through eight systems from 2020 to 2024: a blue box is trained for the task, a grey dashed one is frozen or off the shelf. Each step's claims are quoted from its own paper (abstracts saved in src/inputs/later_extracts.txt).
"Trained" means trained or fine-tuned for the system's task; every generator here was pretrained first. In the deployed pattern the embedding model and the LLM are usually off the shelf; teams that fine-tune an embedding model or a reranker are doing a small part of what this paper did jointly.
Every link opens in a new tab. Reading time of the resources below: 4h 10m.
NeurIPS 2020, the paper itself; the HTML version has the anchors this page links to. abstract page, PDF.
(45 min)
the authors' Hugging Face port (fine-tuning and evaluation scripts; Apache-2.0). Transformers moved its examples/research_projects folder, where the old page's link pointed, to this separate repository in 2025 (the folder's README now says so), so that link returns 404 (checked 2 October 2026); the models themselves are RagSequenceForGeneration and RagTokenForGeneration in Transformers. About 20 minutes for the README and entry path.
(20 min)
Meta AI (Facebook AI), September 2020: the authors' own framing; short and good on the motivation of hot-swapping the index instead of retraining.
(10 min)
Hugging Face docs: the original model as runnable code (RagSequenceForGeneration, RagTokenForGeneration, RagRetriever over the wiki_dpr index); the clearest way to see how the pieces compose (core pages).
(20 min)
Hugging Face model card (Apache-2.0): the released RAG-Token checkpoint fine-tuned on Natural Questions; the paper's demo address, huggingface.co/rag, now redirects here (checked 2 October 2026), so the interactive demo is gone. Its twin is facebook/rag-sequence-nq.
(5 min)
Gao et al., 2023 (arXiv 2312.10997): the standard bridge from this paper to the modern stack; its Naive, Advanced and Modular RAG taxonomy is the usual map of what the field became (survey).
(1h 30m)
Lilian Weng, October 2020: places RAG among the 2020 retriever-reader and retriever-generator systems (DrQA, ORQA, REALM, DPR, FiD) with their equations side by side.
(45 min)
Jay Alammar: a visual walk through RETRO, the 2021 descendant that moved retrieval inside the network with chunked cross-attention.
(15 min)
the DPR retriever is a pair of BERT-base encoders; retrieval embeddings remain BERT's main living habitat.
the same month's parametric-only counterpoint; GPT-3-style in-context learning is what later let deployed RAG drop this paper's end-to-end training.
retrieval moved from a fixed pipeline step to a tool an agent decides to call: the road to agentic RAG.
the closed-book baselines of Table 1 are T5 models (fine-tuned by Roberts et al., with salient span masking for T5+SSM).
the generator (BART) and both retriever encoders (BERT) are Transformers; the toy generator on this page is built like that page's toy model.
this is the founding paper of the topic.
This page is one row of the Papers database; its properties (Paper, Takeaway, Topics, Year) live there.