What is RAG? Retrieval-Augmented Generation explained
RAG gives LLMs accurate answers from your own documents. A simple, technical, and practical explanation.
Definition
Retrieval-Augmented Generation (RAG) is an architecture that supplies a large language model with relevant information retrieved from an external knowledge base before generating an answer.
Simple explanation
Instead of asking the model to remember everything, RAG lets it look things up. You ask a question, the system searches your documents, then the model writes an answer using what it found.
Technical explanation
The RAG pipeline has two phases:
Indexing (offline)
- Split documents into chunks
- Embed each chunk into a vector
- Store vectors in a vector database
Retrieval and generation (online)
- Embed the user question
- Search for the most similar chunks
- Pass question + chunks to the LLM as context
- The LLM generates a grounded answer
Architecture
- Document loader and splitter
- Embedding model
- Vector database
- Retriever
- LLM with grounding prompt
Use cases
- Company knowledge bases
- Support assistants
- Legal and policy research
- Product documentation Q&A
Common mistakes
- Poor chunking: answers are scattered across chunks
- No evaluation: retrieval quality is never measured
- No citations: users cannot verify the answer
FAQ
Is RAG the same as an AI Agent? No. RAG retrieves and answers. An agent plans and acts. Many systems use both.