Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020))
Subscriber deck — free during early access
20 cards
1 Introduction
- What weaknesses of purely parametric language models does RAG address?Knowledge stored only in parameters is hard to expand or revise, gives no insight into predictions (no provenance), and can produce hallucinations; on knowledge-intensive tasks such models lagged task-specific architectures.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §1
- What is retrieval-augmented generation (RAG)?A general fine-tuning recipe combining parametric memory (a pretrained seq2seq model, BART) with non-parametric memory (a dense vector index of Wikipedia accessed by a pretrained neural retriever, DPR), trained end to end with retrieved documents as latent variables.
The generator reads x with each retrieved passage; outputs are marginalized over the passages - Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §1
- How does RAG differ from REALM and ORQA?Those combined masked language models with a differentiable retriever but only for extractive open-domain QA; RAG brings retrieval to seq2seq generation, so one architecture serves QA, generation and classification. Both memories are pretrained, so access to knowledge works without extra training.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §1
- What are knowledge-intensive tasks?Tasks that humans couldn’t reasonably be expected to perform without access to an external knowledge source, such as open-domain question answering or fact verification.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §1
2.1 Models
- Define RAG-Sequence.The same retrieved document generates the whole output: \(p(y \mid x) \approx \sum_{z \in \text{top-}k} p_\eta(z \mid x) \prod_{i=1}^{N} p_\theta(y_i \mid x, z, y_{1:i-1})\), marginalizing over the top-\(k\) documents once per sequence.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §2.1
- Define RAG-Token, and when it helps.Each output token can come from a different document: \(p(y \mid x) \approx \prod_{i=1}^{N} \sum_{z \in \text{top-}k} p_\eta(z \mid x)\, p_\theta(y_i \mid x, z, y_{1:i-1})\). It lets the generator combine content from several documents in one answer; for classification (one-token targets) the two variants coincide.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §2.1
2.2 Retriever: DPR
- How does RAG’s retriever score documents?Dense Passage Retrieval, a bi-encoder: \(p_\eta(z \mid x) \propto \exp(d(z)^\top q(x))\), with \(d(z) = \text{BERT}_d(z)\) and \(q(x) = \text{BERT}_q(x)\), both BERT-base. Finding the top-\(k\) documents is maximum inner product search (MIPS), solved approximately in sublinear time.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §2.2
2.3 Generator: BART
- What generator does RAG use, and how does it see retrieved text?BART-large (400M parameters), a denoising-pretrained seq2seq Transformer; the input \(x\) and retrieved passage \(z\) are simply concatenated as its input.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §2.3
2.4 Training
- How is RAG trained, and what stays fixed?By minimizing the negative marginal log-likelihood \(-\sum_j \log p(y_j \mid x_j)\) with Adam, with no supervision on which document to retrieve. Only the query encoder and BART are fine-tuned; the document encoder and index stay fixed, avoiding costly re-indexing (unlike REALM), without hurting performance.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §2.4
2.5 Decoding
- How are RAG-Token and RAG-Sequence decoded?RAG-Token is an ordinary autoregressive model with per-step marginalized probabilities, so standard beam search works. RAG-Sequence’s likelihood doesn’t factor per token: run beam search per document, then score each candidate across documents (“thorough decoding”, extra forward passes) or approximate missing scores as zero (“fast decoding”).
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §2.5
3 Experiments
- What non-parametric memory did RAG use?A December 2018 Wikipedia dump split into disjoint 100-word chunks, 21M passages, embedded by the DPR document encoder and indexed with FAISS (HNSW approximation); 5 or 10 documents were retrieved per query in training.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §3
4.1 Open-domain Question Answering
- How did RAG do on open-domain QA?New state of the art on Natural Questions (44.5 EM), WebQuestions (45.5), CuratedTrec (52.2) and the T5-comparable TriviaQA split (68.0), beating closed-book T5-11B+SSM and extractive DPR, without salient-span-masking pre-training or a re-ranker.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §4.1
- Why can generating answers beat extracting them, according to Lewis et al.?Documents that contain clues but not the verbatim answer can still contribute, and RAG can produce correct answers absent from all retrieved documents: 11.8% accuracy in such cases on NQ, where an extractive model scores 0.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §4.1
4.2 Abstractive Question Answering
- How did RAG do on MS-MARCO NLG without the gold passages?RAG-Sequence beat BART by 2.6 BLEU and 2.6 ROUGE-L and approached systems that use the gold passages, hallucinating less and producing factually correct text more often.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §4.2
4.3 Jeopardy Question Generation
- What did human evaluation of Jeopardy question generation show?Against BART, RAG-Token was judged more factual in 42.7% of pairs vs 7.1% for BART (both factual in 17%), and much more specific. RAG-Token beat RAG-Sequence on Q-BLEU-1, perhaps because Jeopardy clues combine facts from several documents.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §4.3
- How do parametric and non-parametric memory interact in RAG-Token?Generating a Hemingway clue, the document posterior peaks on the passage about “The Sun Also Rises” when the first title token is produced, then flattens: retrieved text cues the right knowledge, and BART’s parametric memory completes the title.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §4.3
4.4 Fact Verification
- How did RAG do on FEVER, and what supervision did it lack?Within 4.3% of state-of-the-art pipelines on 3-way classification and within 2.7% of a RoBERTa classifier given gold evidence on 2-way, without any supervision on retrieved evidence; its top document came from a gold article 71% of the time.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §4.4
4.5 Additional Results
- What did RAG’s retrieval ablations show?Learning the retriever improved all tasks over freezing it. Replacing it with BM25 hurt everywhere except FEVER, whose entity-centric claims suit word-overlap retrieval; differentiable retrieval mattered most for open-domain QA.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §4.5
- How can RAG’s knowledge be updated without retraining?By hot-swapping the index: with a 2016 Wikipedia index RAG answered 70% of “Who is {position}?” questions correctly for 2016 world leaders, with the 2018 index 68% for 2018 leaders, while mismatched index and year gave 12% and 4%.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §4.5
6 Discussion
- What advantages does a raw-text memory give RAG over memories of learned embeddings?It is human-readable, giving a form of interpretability and provenance, and human-writable: the model’s knowledge can be updated by editing the document index.
- Lewis et al., 2020, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Advances in Neural Information Processing Systems 33 (NeurIPS 2020)), §6
Source
- Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel and Douwe Kiela. 2020. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. In Advances in Neural Information Processing Systems 33 (NeurIPS 2020). https://papers.nips.cc/paper/2020/hash/6b493230205f780e1bc26945df7481e5-Abstract.html