vishal patel
Applied in productionIntermediateUpdated 2026-09-23

RAG (Retrieval-Augmented Generation) Architecture

Ground LLM answers in your own data — ingestion, chunking, embeddings, vector search, reranking, prompting with citations, and evaluation.

llmembeddingsvector-dbpineconeretrieval

The pipeline

diagram

Decisions that decide quality

DecisionGuidance
ChunkingRespect document structure (headings, code blocks); add the title and breadcrumbs to each chunk
RetrievalHybrid (BM25 + vectors) beats either alone; filter by metadata (team, product, date, permissions)
RerankingRetrieve ~50, rerank to ~5. A large relevance boost for little cost
Prompting"Answer only from context; say 'I don't know'; cite sources"
FreshnessIncremental re-index on doc change events
SecurityEnforce the user's permissions at retrieval time, never in the prompt

Evaluate it like software

Build a golden set of 50–200 real questions with expected sources. Measure retrieval recall@k, answer faithfulness (grounded in context?) and answer relevance. Re-run it on every change to chunking, the embedding model or the prompt. See LLM Evals.

Where I've used it

I built an internal RAG knowledge app over our engineering docs: chunk → embed → Pinecone → an LLM answers from retrieved context. It cut down repeated onboarding and "where is this documented?" questions.

Sources & further learning

Videos, courses, docs and books I recommend for this topic.

Related topics