RAG (Retrieval-Augmented Generation) is the pattern of giving an LLM extra context fetched from your data, then asking it to answer with that context. The most useful AI architecture pattern of 2024-2026.
The Problem RAG Solves
LLMs don't know your company's data. Their training cutoff is months old. Their context windows can't fit your entire knowledge base.
How It Works
- Embed: convert documents to vectors (numerical representations)
- Store: put vectors in a vector database (Pinecone, Qdrant, Chroma)
- Query: at inference time, embed the user question, retrieve top-K similar chunks
- Generate: send retrieved chunks + question to the LLM, get an answer grounded in your data
Vector Database Options
- Pinecone: managed, scaled, $$
- Qdrant: open-source, fast, easy self-host
- Weaviate: hybrid search, multi-modal
- Chroma: simple, embed-in-Python
- pgvector: Postgres extension
When RAG vs Fine-Tuning
- RAG: dynamic data, frequent updates, source attribution required
- Fine-tune: style/behavior change, large stable corpus, no source attribution needed
Most modern AI apps use RAG, not fine-tuning.
Common Failure Modes
- Bad chunks: too small (context lost) or too big (irrelevant filler)
- Bad embeddings: not matching the language of queries
- Wrong K: too few = miss; too many = overwhelm LLM
- No reranking: top-K cosine similarity ≠ semantic relevance
Reranking
After initial retrieval, use a reranker model (Cohere Rerank, BGE) to refine results. Big quality boost.
RAG in 2026 vs 2024
Tools mature: built-in retrievers in LangChain, LlamaIndex, Vercel AI SDK. Vector DBs cheaper. Embedding models multilingual.
Next Step
Build a small RAG bot in n8n — covered in how to use n8n.