What is retrieval-augmented generation (RAG)?

Retrieval-augmented generation (RAG) is a way of answering questions with a language model in two steps: first retrieve the passages from real documents that are closest to the question, then have the model answer from those passages. Because the answer is built on retrieved text, it can cite its sources, and it invents less than a model answering from memory.

A RAG system splits documents into passages, turns each into an embedding, and stores them in a vector index. A question is embedded the same way, and the nearest passages are sent to the model with instructions to answer only from them.

RAG doesn’t remove mistakes: retrieval can miss the right passage, and a model can still misread one. That is why answers should cite the passages they used.

Read next

The whole glossary →

Help PaperLab reach the next researcher

PaperLab is free, open source and built by one person. A star helps other researchers find it and puts each new release in your GitHub feed. The PaperLab page on LinkedIn posts a weekly breakdown of how one feature works.