XYZNOT

Papers · arXiv 2005.11401

Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks

Published cs.CLcs.LG arXivPDF

Read with translation and AI

Summary in three lines

  1. 🎯 Purely parametric language models struggle to access, revise, and ground factual knowledge, leading to hallucinations on knowledge-intensive tasks.
  2. 🔧 Introduces RAG, combining a Dense Passage Retriever (non-parametric memory over Wikipedia) with a BART generator (parametric memory), fine-tuned end-to-end via marginalization over latent documents.
  3. 📈 Sets state-of-the-art results on open-domain QA (44.5 EM on Natural Questions) and generates more factual, specific, and diverse text than parametric-only baselines.

Abstract

Large pre-trained language models have been shown to store factual knowledge in their parameters, and achieve state-of-the-art results when fine-tuned on downstream NLP tasks. However, their ability to access and precisely manipulate knowledge is still limited, and hence on knowledge-intensive tasks, their performance lags behind task-specific architectures. Additionally, providing provenance for their decisions and updating their world knowledge remain open research problems. Pre-trained models with a differentiable access mechanism to explicit non-parametric memory can overcome this issue, but have so far been only investigated for extractive downstream tasks. We explore a general-purpose fine-tuning recipe for retrieval-augmented generation (RAG) -- models which combine pre-trained parametric and non-parametric memory for language generation. We introduce RAG models where the parametric memory is a pre-trained seq2seq model and the non-parametric memory is a dense vector index of Wikipedia, accessed with a pre-trained neural retriever. We compare two RAG formulations, one which conditions on the same retrieved passages across the whole generated sequence, the other can use different passages per token. We fine-tune and evaluate our models on a wide range of knowledge-intensive NLP tasks and set the state-of-the-art on three open domain QA tasks, outperforming parametric seq2seq models and task-specific retrieve-and-extract architectures. For language generation tasks, we find that RAG models generate more specific, diverse and factual language than a state-of-the-art parametric-only seq2seq baseline.

Reading guide

Problem and motivation

Pre-trained language models store substantial factual knowledge within their parameters (parametric memory). However, they have significant drawbacks: they struggle to expand or update their knowledge without retraining, cannot easily provide provenance or interpretability for their outputs, and are prone to hallucinations.

While hybrid parametric/non-parametric models like REALM and ORQA combined differentiable retrieval with masked language modeling, they were restricted to extractive question answering. Standard sequence-to-sequence (seq2seq) architectures like BART and T5 remained largely closed-book. This work bridges that gap by proposing Retrieval-Augmented Generation (RAG), a general fine-tuning framework that couples a pre-trained dense neural retriever with an autoregressive seq2seq generator for both open-domain generation and classification.

Key ideas

  • Hybrid Parametric and Non-Parametric Memory: Non-parametric memory consists of a dense vector index over 21M 100-word Wikipedia passages accessed via Maximum Inner Product Search (MIPS). Parametric memory is a pre-trained BART generator.
  • End-to-End Fine-Tuning: The query encoder and generator are trained jointly by treating the retrieved passages as latent variables and minimizing the negative marginal log-likelihood of target tokens without explicit retrieval supervision.
  • Two Conditioning Formulations:
    • RAG-Sequence: Conditions on the same retrieved document across the entire generated sequence.
    • RAG-Token: Allows each generated token to attend and marginalize over different retrieved passages.
  • Hot-Swappable World Knowledge: The external index can be swapped at inference time (e.g., swapping a 2016 Wikipedia index for a 2018 index) to update world knowledge without modifying model weights.

Method

Given an input sequence , the retriever produces a distribution over documents , and the generator generates target tokens conditioned on both and .

The retriever uses Dense Passage Retriever (DPR): where and . Top- candidates are retrieved using FAISS MIPS. The document index and document encoder are kept fixed, while and the BART generator parameters are fine-tuned.

RAG-Sequence

The model treats the retrieved document as a single latent variable across the entire sequence : Decoding can be evaluated using Thorough Decoding (running beam search per document and computing forward passes for candidate hypotheses across all documents) or Fast Decoding (approximating missing beam probabilities as 0).

RAG-Token

The model marginalizes over documents at each token step, enabling token-level content mixing across sources: This yields a standard autoregressive transition probability that plugs directly into beam search.

Results

  • Open-Domain QA: RAG sets new state-of-the-art results on open benchmarks using exact match (EM):
    • Natural Questions: 44.5 (RAG-Seq) vs. 41.5 (DPR) and 36.6 (T5-11B+SSM).
    • TriviaQA (standard open split): 56.8 (RAG-Seq); on the TQA-Wiki test split: 68.0 (RAG-Seq) vs. 60.5 (T5-11B+SSM).
    • WebQuestions: 45.5 (RAG-Token) vs. 41.1 (DPR).
    • CuratedTrec: 52.2 (RAG-Seq) vs. 50.6 (DPR).
    • Notably, on Natural Questions, RAG achieved 11.8% EM when the correct answer was completely missing from the retrieved context (where extractive models score 0%).
  • Abstractive Generation: On Open MS-MARCO, RAG-Sequence achieves 40.8 Rouge-L and 44.2 Bleu-1, outperforming BART (38.2 Rouge-L, 41.6 Bleu-1).
  • Jeopardy Question Generation: Human annotators rated RAG-Token as more factual than BART in 42.7% of cases versus BART being superior in only 7.1%. Evaluators also found RAG more specific (37.4% vs. 16.8%).
  • Fact Verification: On FEVER 3-way, RAG reaches 72.5% label accuracy (within 4.3% of pipeline systems using gold evidence supervision); on 2-way, RAG achieves 89.5% accuracy.
  • Knowledge Update via Hot-Swapping: Using an 82-leader temporal test between 2016 and 2018, RAG scored 70% accuracy for 2016 leaders using the 2016 index and 68% for 2018 leaders with the 2018 index, dropping drastically (12% and 4%) when mismatched.

Limitations and open questions

  • Retrieval Collapse: For tasks that require weaker explicit factual conditioning (such as open-ended story generation), the retriever can collapse to retrieving static, invariant documents while the generator learns to ignore them.
  • Fixed Document Indexing: The document encoder is kept static during task fine-tuning due to the computational cost of continually re-indexing 21M vectors, limiting retriever adaptation.
  • Source Grounding and Bias: Non-parametric memory remains vulnerable to misinformation and biases embedded in the underlying knowledge corpus (Wikipedia).
  • Joint Pre-training: The retriever and generator components were pre-trained separately prior to downstream task fine-tuning, leaving joint pre-training from scratch as an open direction.

Key terms

Retrieval-Augmented Generation (RAG)
A hybrid framework combining a pre-trained neural retriever with a pre-trained sequence-to-sequence model to condition generation on retrieved non-parametric text passages.
Parametric Memory
The implicit factual knowledge stored within the neural network weights of the pre-trained seq2seq generator (BART).
Non-Parametric Memory
An explicit, external document collection (e.g., a FAISS dense vector index of 21 million Wikipedia passages) accessed at runtime.
RAG-Sequence
A RAG formulation that treats the retrieved passage as a latent variable held constant across the entire generated sequence.
RAG-Token
A RAG formulation that marginalizes over the top-k retrieved documents individually at each generated token, allowing synthesis across multiple sources.
Dense Passage Retriever (DPR)
A dual-BERT encoder architecture that scores document relevance to a query via maximum inner product search in dense embedding space.
Maximum Inner Product Search (MIPS)
The mathematical search formulation used to rapidly retrieve top-k document vectors closest to a query vector in sub-linear time.
Index Hot-Swapping
The practice of replacing the non-parametric document index with updated information without retraining or fine-tuning the model's parameters.

Questions

What is the difference between RAG-Sequence and RAG-Token?

RAG-Sequence uses the exact same retrieved document to condition every token across the whole sequence, whereas RAG-Token marginalizes over top documents at each step, allowing different tokens to be supported by different documents.

Are the document representations updated during fine-tuning?

No. The document encoder and the FAISS index remain fixed to avoid the high computational cost of re-indexing 21 million documents during training; only the query encoder and BART generator parameters are updated.

Can RAG answer questions when the answer is not present in retrieved documents?

Yes. Because generation is unconstrained and supported by BART's parametric memory, RAG correctly answers 11.8% of Natural Questions cases where none of the top retrieved passages contain the target string, whereas extractive models achieve 0%.

How does RAG update its knowledge when world facts change?

Because its external memory is modular, the document index can be 'hot-swapped' with a newer text dump (e.g., swapping a 2016 Wikipedia index for a 2018 index) without retraining the model parameters.

The overview on this page was written by AI from the paper and may contain mistakes. Read the paper for the details.

Read with translation and AI