Information Retrieval and Retrieval-Augmented Generation
Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 11
6 cards in “11.4 Retrieval-augmented generation” · whole deck
11.4 Retrieval-augmented generation
- What are the two components of a RAG system?The retriever, which finds relevant passages in a document collection, and the generator (historically the “reader”), an LLM that answers conditioned on the retrieved passages and the user prompt.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 11, §11.4, p. 267
- Give the basic RAG algorithm.(1) Retrieve the top-k passages \(R(q) = d_1 \ldots d_k\) for query \(q\); (2) build a prompt with the passages and the question (“Based on these texts, answer this question: …”); (3) call the LLM, which generates \(p(x_i \mid R(q); \text{instruction}; q; x_{<i})\).
Retrieve, then generate an answer grounded in the passages. - Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 11, §11.4, p. 268
- What is agent-based RAG?The system decides when to call retrieval and from which collection (web, private data…), instead of always retrieving for every turn.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 11, §11.4, pp. 268–269
- How can RAG deal with noisy or insufficient retrieved passages?Add a reranker to reorder passages after retrieval, or use multi-hop retrieval: append the first-stage documents to the query and retrieve again.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 11, §11.4, p. 269
- How can the LLM or the retriever be trained for RAG?Instruction-tune the LLM on questions annotated with retrieved passages and correct answers; or use test-time compute to have it reflect on which passages were useful; or train the retriever and LLM end-to-end on question–answer data, since the IR engine wasn’t optimized for feeding an LLM.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 11, §11.4, p. 269
- What are knowledge citations, and how are they most simply generated?Evidence for factual statements, like numbered references to URLs or literature. Simplest: instruct the model in the prompt to answer only from the provided search results and cite them for every factual claim.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 11, §11.4, p. 269
Source
- Daniel Jurafsky and James H. Martin. Speech and Language Processing. 3rd edition (draft). https://web.stanford.edu/~jurafsky/slp3/