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

  1. 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.
  2. 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.
    input xquery encoder (trained)search 21M passages (fixed)z₁z₂…zKBART generator (trained)output yx
    The generator reads x with each retrieved passage; outputs are marginalized over the passages
  3. 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.
  4. 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.

2.1 Models

  1. 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.
  2. 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.

2.2 Retriever: DPR

  1. 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.

2.3 Generator: BART

  1. 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.

2.4 Training

  1. 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.

2.5 Decoding

  1. 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”).

3 Experiments

  1. 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.

4.1 Open-domain Question Answering

  1. 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.
  2. 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.

4.2 Abstractive Question Answering

  1. 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.

4.3 Jeopardy Question Generation

  1. 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.
  2. 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.

4.4 Fact Verification

  1. 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.

4.5 Additional Results

  1. 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.
  2. 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%.

6 Discussion

  1. 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.

Source