Paper commentary
Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
- Problem Parametric seq2seq generators keep their knowledge in model weights, which makes that knowledge hard to revise, inspect or tie to sources.
- Method Pairs a DPR retriever over a Wikipedia index with a BART-large generator, marginalizes over the retrieved documents, and fine-tunes the query encoder and generator.
- Results Reaches 44.5 Exact Match on the Natural Questions open-domain test split with RAG-Sequence.
Why parametric memory alone is limiting
Large pre-trained language models store a substantial amount of factual knowledge in their weights, so they can be read as an implicit knowledge base. That store is hard to expand or revise, gives little insight into why a prediction was made, and can produce hallucinations.
Hybrid models attach a non-parametric, retrieval-based memory to the parametric one, so knowledge can be revised and the accessed sources can be inspected. REALM and ORQA showed the value of a differentiable retriever in masked language models, but their use stayed with extractive open-domain question answering.
The question is whether one general fine-tuning recipe can bring this kind of hybrid memory to seq2seq generation across knowledge-intensive tasks.
How the retriever and generator fit together
RAG treats the input x as a query, retrieves the top-K passages from a dense index, and generates y conditioned on the input and each retrieved passage. The index is built from a December 2018 Wikipedia dump split into disjoint 100-word chunks, giving 21M documents. Figure 1 lays out the query encoder, the document index, the top-K search and the generator, which are fine-tuned end to end.
The retriever is a DPR bi-encoder, with a document encoder and a query encoder that are both BERT-base models and that score a passage by an inner product. Its retrieval distribution takes this form. \[ p_\eta(z|x) \propto \exp\big(d(z)^\top q(x)\big) \] Finding the top-K passages is a Maximum Inner Product Search problem, which can be solved approximately in sub-linear time.
The generator is BART-large, a seq2seq transformer with 400M parameters, and the input and the retrieved passage are simply concatenated before decoding. The generator's weights serve as the parametric memory, while the document index serves as the non-parametric memory.
Marginalizing over retrieved documents
RAG-Sequence keeps a single retrieved document for the whole output, so the sum over documents sits outside the product over tokens. \[ p(y|x) \approx \sum_{z \in \text{top-}k(p(\cdot|x))} p_\eta(z|x) \prod_{i=1}^{N} p_\theta(y_i|x,z,y_{1:i-1}) \] Each document scores the full sequence, and these scores are weighted by the retrieval probability and summed.
RAG-Token lets each output token draw on a different document, so the sum over documents sits inside the product over tokens. \[ p(y|x) \approx \prod_{i=1}^{N} \sum_{z \in \text{top-}k(p(\cdot|x))} p_\eta(z|x)\, p_\theta(y_i|x,z,y_{1:i-1}) \] When the target is a single class label, treated as a sequence of length one, the two variants coincide.
Training minimizes the sum over examples of the negative log-likelihood of each target, using stochastic gradient descent with Adam. \[ \sum_j -\log p(y_j|x_j) \] The document encoder and the index stay fixed, and only the query encoder and the BART generator are fine-tuned, because updating the encoder would require rebuilding the index periodically.
During training the top-K is set to 5 or 10, and the test-time value is chosen on dev data.
Decoding the two variants
RAG-Token behaves like a standard autoregressive model whose transition probability marginalizes over the retrieved documents, so a usual beam decoder can be used. \[ p'_\theta(y_i|x,y_{1:i-1}) = \sum_{z \in \text{top-}k(p(\cdot|x))} p_\eta(z_i|x)\, p_\theta(y_i|x,z_i,y_{1:i-1}) \]
The RAG-Sequence likelihood does not split into per-token terms, so one beam search cannot solve it; a beam search runs separately for each document instead. Thorough Decoding adds a forward pass for each document in which a candidate hypothesis did not appear in the beam, multiplies by the retrieval probability and sums across documents.
Fast Decoding instead treats the generator probability as near zero for tokens not generated in that document's beam, which removes the extra passes once the candidate set is formed.
For open-domain QA, test numbers use 15 retrieved documents for RAG-Token and 50 for RAG-Sequence, with Thorough Decoding and greedy decoding for the QA runs. For MS-MARCO and Jeopardy question generation, ten documents are used with a beam size of four, and RAG-Sequence uses Fast Decoding.
Open-domain question answering results
Four datasets are used: Natural Questions, TriviaQA, WebQuestions and CuratedTrec, scored with Exact Match. WebQuestions and CuratedTrec models start from the Natural Questions RAG model because those sets are small. TriviaQA is reported on the open-domain test split and on the official Wiki test set.
On Natural Questions, RAG-Sequence reaches 44.5 and RAG-Token 44.1, against 41.5 for DPR and 40.4 for REALM. The retriever starts from DPR, which was trained with retrieval supervision on Natural Questions and TriviaQA, and RAG does not use the salient span masking pre-training that REALM and T5+SSM rely on.
On the open-domain TriviaQA split RAG-Sequence scores 56.8 and RAG-Token 55.2, both below the 57.9 reported for DPR on that split. On the Wiki test split they reach 68.0 and 66.1, against 60.5 for T5-11B+SSM, and the authors attribute the higher Wiki scores to those questions being simpler to answer from Wikipedia.
On WebQuestions RAG-Token reaches 45.5 and RAG-Sequence 45.2, against 44.7 for T5-11B+SSM. On CuratedTrec RAG-Sequence reaches 52.2 and RAG-Token 50.0, against 50.6 for DPR and 46.8 for REALM.
The closest-sized closed-book model is T5-large with 770M parameters, which scores 28.9 Exact Match on Natural Questions, well below RAG-Sequence's 44.5.
When the answer appears in no retrieved document, RAG still answers 11.8% of Natural Questions cases correctly, where an extractive model would score 0%.
Generation and fact verification results
That is a difference of 2.6 points on both metrics.
On Jeopardy question generation RAG-Token reaches a Q-BLEU-1 of 22.2 and RAG-Sequence 21.4, against 19.7 for BART. Bleu-1 is 17.3 for RAG-Token and 15.1 for BART. The example outputs show BART making factual errors on inputs where RAG gives specific, correct answers.
Human judges compared 452 pairs of BART and RAG-Token Jeopardy questions. BART was judged more factual in 7.1% of pairs and RAG in 42.7%, and RAG was judged better on specificity in 37.4% of pairs against 16.8% for BART. The prose gives 17% for pairs where both outputs are factual, whereas Table 4 lists 11.7% for both good, so these two values differ.
The RAG-Token posterior over documents changes during generation: document 1 dominates when 'A Farewell to Arms' is produced, and document 2 when 'The Sun Also Rises' is produced. After the first token of each title, the document posterior flattens, and the BART-only baseline completes a partial title such as 'The Sun' from its own parameters, which the authors read as parametric knowledge completing titles that retrieval has started.
On FEVER 3-way classification RAG-Token reaches 72.5 label accuracy, against 64.0 for BART and 76.8 for the state of the art, and RAG stays within 4.3% of that state-of-the-art pipeline. Those pipeline systems use intermediate retrieval supervision, which RAG does not use. On the 2-way task RAG-Token reaches 89.5, against 81.1 for BART and 92.2 for the state of the art, and RAG is within 2.7% of that model even though it is given only the claim and retrieves its own evidence.
Retriever ablations, index swapping and retrieval depth
Freezing the retriever during training lowers dev-set Exact Match on Natural Questions from 43.5 to 37.8 for RAG-Token and from 44.0 to 41.2 for RAG-Sequence. The authors report that learned retrieval improves results across tasks in this ablation.
A second ablation swaps the learned retriever for a fixed BM25 word-overlap retriever, with its scores used as logits in p(z|x). The authors report that BM25 performs best on FEVER, which they attribute to FEVER claims being heavily entity-centric, while differentiable retrieval improves the other tasks, most clearly open-domain QA.
To test index swapping, the authors built an index from a December 2016 Wikipedia dump and compared it with the December 2018 index. They queried the Natural Questions RAG model with the template 'Who is {position}?' for 82 world leaders whose positions changed between the two dates. RAG answered 70% correctly with the 2016 index for 2016 leaders and 68% with the 2018 index for 2018 leaders.
Mismatched indices gave 12% with the 2018 index and 2016 leaders, and 4% with the 2016 index and 2018 leaders.
The number of retrieved documents can be changed at test time, and RAG-Sequence improves monotonically with more documents on Natural Questions, while RAG-Token peaks at 10. On MS-MARCO more retrieved documents raise Rouge-L for RAG-Token at the cost of Bleu-1, with a smaller effect for RAG-Sequence.
Limitations
In preliminary experiments on story generation, the retriever collapsed to returning the same documents for every input, after which the generator ignored them and RAG performed like BART. The authors offer less explicit factual requirements in some tasks and longer target sequences as possible causes.
Some MS-MARCO questions cannot be answered from Wikipedia alone, and the open-domain MS-MARCO scores are lower without the gold passages.
The FEVER experiments cover label classification only, and the evidence-extraction sub-task is left to future work because the FEVER Wikipedia dump differs from the one used here.
A null document mechanism was tried for cases with no useful retrieval, but it did not improve performance and was omitted.
Paper info
- Authors
- Lewis, Patrick, Perez, Ethan, Piktus, Aleksandra, Petroni, Fabio, Karpukhin, Vladimir, Goyal, Naman, Küttler, Heinrich, Lewis, Mike, Yih, Wen-tau, Rocktäschel, Tim, Riedel, Sebastian, Kiela, Douwe
- Venue
- arXiv · Preprint
- First published
- 2020-5-22
- Added
- 2026-10-20
- Updated
- 2021-4-12
- Version
- v4
- arXiv
- 2005.11401
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Lewis, Patrick, Perez, Ethan, Piktus, Aleksandra, Petroni, Fabio, Karpukhin, Vladimir, Goyal, Naman, Küttler, Heinrich, Lewis, Mike, Yih, Wen-tau, Rocktäschel, Tim, Riedel, Sebastian, Kiela, Douwe (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. arXiv:2005.11401v4. https://arxiv.org/abs/2005.11401v4
BibTeX
@misc{patrick2020retrieval,
title = {{Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks}},
author = {Lewis, Patrick and Perez, Ethan and Piktus, Aleksandra and Petroni, Fabio and Karpukhin, Vladimir and Goyal, Naman and Küttler, Heinrich and Lewis, Mike and Yih, Wen-tau and Rocktäschel, Tim and Riedel, Sebastian and Kiela, Douwe},
year = {2020},
eprint = {2005.11401},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2005.11401v4}
}