RAG
The complete path from "what is RAG" to production concerns — indexing, embeddings, vector search, retrieval strategies, augmentation, evaluation, and the advanced architectures built on top of all of it.
document loaders
chunking
embeddings
vector search
MMR / MQR
BM25
hybrid search
reranking
RAGAS
agentic RAG
Topic overview
RAG grounds an LLM's answers in external, up-to-date, or private documents by retrieving relevant text at query time instead of relying only on the model's frozen training knowledge. This guide walks the full pipeline in order: why RAG exists and why you can't just paste everything into the prompt, how documents are loaded, split, and embedded during indexing, how a vector database makes similarity search fast at scale, how retrieved chunks get assembled into a grounded prompt, how retrievers (from a plain top-k search up through MMR, reranking, and HyDE) pull the right chunks back out, how semantic and keyword search combine in hybrid search, how to actually measure whether a RAG system is any good, and the advanced architectures and production concerns that separate a prototype from something you'd ship.
Core concepts
Document object (page content + metadata), chunking strategies (character, recursive, semantic, contextual retrieval), chunk overlap, bi-encoder vs. cross-encoder embeddings, MTEB, vector indexing (IVF, HNSW, LSH), the cosine similarity formula, top-k retrieval, MMR, Multi-Query Retriever, hybrid search (BM25 formula + dense + RRF), reranking (ColBERT), HyDE, parent-document retrieval, grounding prompts, citation verification, map-reduce / refine chains, "lost in the middle," prompt injection via retrieved documents, RAGAS + MRR/NDCG metrics, agentic (ReAct), corrective, and Self-RAG, GraphRAG, RAPTOR.
Why it matters
LLMs can't answer questions about data they never saw, and left alone they hallucinate confidently instead of admitting they don't know. RAG fixes both problems — without the cost or delay of retraining the model — by handing it the actual source text it needs at answer time, so the answer can be traced back to where it came from. Every technique past the basics exists to fix one specific, well-documented failure mode: duplicate results, vague queries, missed exact-keyword matches, imprecise ranking, or answers that silently drift from the source.
Interview relevance
RAG comes up in nearly every AI engineering interview. Strong answers explain why chunking is necessary, what a vector database actually indexes, why a vanilla top-k retriever returns duplicates, how MMR, hybrid search, or reranking fixes a specific failure mode, and how you'd actually measure whether a change helped — not just recite the retrieval-augmentation-generation acronym.