Retrieval-Augmented Generation (RAG)
A RAG system looks up relevant material when you ask a question and gives it to a model to help write the answer.
How a handbook question gets answered
- Ask
An employee asks, “Can I bring my bike into the office?” The assistant searches the company handbook.
- Retrieve
In this example, the handbook says, “Employees may store bicycles in the ground-floor bike room.” The system gives that passage to the model.
- Answer
“Yes, you can store it in the ground-floor bike room.” The assistant links to the passage so the employee can check the wording.
How the passage gets picked
The question uses “bike” while the handbook says “bicycles.” One way to make that match is to turn both the question and handbook passages into numerical representations called embeddings. A vector search can then retrieve passages with similar meanings. A vector database can store those representations alongside each passage’s document and edition.
Systems can also search by keywords or combine search methods. Once a few relevant passages have been selected, they become part of the model’s input for this answer. Updating the searchable handbook can change the next answer without retraining the model.
What if the handbook is out of date?
Suppose the bike room moved upstairs last week. The answer could quote the old edition accurately and still send the employee to the wrong floor. Check which edition was retrieved, then check whether its wording supports the answer. A link gives the reader a way to make both checks.
Retrieval can also miss the relevant section entirely. If the passage only mentions bicycle storage, an answer that also promises a repair station adds an unsupported detail. That is one way a hallucination can survive even when a system uses RAG.
Follow the idea
Vector search finds passages with related meanings.
Grounding connects an answer to supporting material.
Examples in the AI guides
Related Yenra articles (12)
Related concepts (8)
Source · The original RAG paper by Lewis and colleagues
Return to RAG in the A–Z glossary