RAG (Retrieval-Augmented Generation) retrieves relevant information from an external source and inserts it into the model's prompt before generation — grounding answers in real, specific content instead of relying purely on what the model memorized during training.
The Full Pipeline
PDF / documents
↓ text extraction
Raw text
↓ chunking
Text chunks
↓ embedding
Vectors
↓ stored in a
Vector DB
↓ (at query time) retriever fetches relevant chunks
Retrieved context
↓ inserted into a prompt with the user's question
LLM
↓
Answer, grounded in the retrieved content
Every stage of this pipeline is covered in its own note below — this page is the map.
Why RAG, Instead of Just a Bigger/Smarter Model?
| Problem | How RAG Addresses It |
|---|---|
| Model has a knowledge cutoff — no awareness of recent or private information | Retrieval supplies current, specific information at query time, not baked into training |
| Model hallucinates on questions outside its training data | Grounding answers in retrieved real content reduces (not eliminates) this risk |
| You need answers about your own private/internal data | Retrieval can pull from your own document store — data the model was never trained on |
| Retraining/fine-tuning for every new fact is impractical | Updating a document in your knowledge base takes effect immediately, no retraining |
What This Section Covers
| Stage | Notes |
|---|---|
| Architecture | RAG Architecture, RAG Pipeline |
| Ingestion & chunking | Document Processing, Chunking Strategies, Chunk Size, Chunk Overlap |
| Retrieval | Vector Retrieval, Hybrid RAG, Reranking, Context Retrieval |
| Generation | RAG Prompt |
| Quality & risk | RAG Evaluation, RAG Hallucinations, RAG Failure Modes, RAG Security |
| Alternatives & comparisons | RAG vs Fine-Tuning, RAG vs Long Context |
| Beyond the basics | Advanced RAG |
Common Mistakes
- Treating RAG as "just add retrieval and it works" — every stage (chunking, retrieval quality, prompt design) has real failure modes that need deliberate engineering, not just wiring pieces together
- Assuming RAG eliminates hallucination entirely — it substantially reduces the risk for grounded questions, but doesn't guarantee correctness
Interview Relevance
Q: "Explain RAG end to end." — the PDF → chunking → embedding → vector DB → retrieval → prompt → answer pipeline above is exactly the expected shape of a strong answer.
Practice Question
Explain, in plain terms, why RAG can answer questions about a document uploaded five minutes ago, while a model without RAG cannot.