Build a Retrieval-Augmented Generation pipeline from the ground up — embeddings and semantic search, vector databases, chunking, ingestion, retrieval and reranking, grounded generation, and the frameworks that wrap it all. Every lesson is runnable Python.
Before you start
You will build a real pipeline in Python. You need Python 3.10+ and a few libraries the lessons install as they go — sentence-transformers and faiss-cpu run locally and free. Grounded generation uses the Anthropic API, so have a key ready. Every piece ports to hosted embeddings, pgvector, or Pinecone.
What Are Embeddings?
Embeddings turn text into vectors whose distance is meaning. Generate them, measure similarity with cosine, and build a tiny semantic search — the core primitive behind RAG.
Choosing an Embedding Model
Hosted or open source, big or small, general or domain-specific — the embedding model sets your retrieval ceiling. Compare the options and pin the one decision that must never drift.
Vector Databases
Once you have thousands of vectors, a linear scan is too slow. Store and search them with FAISS locally, then see how pgvector and Pinecone do the same job at scale.
Chunking Your Documents
You embed chunks, not whole documents. Split text so each chunk is self-contained and retrievable — the decision that quietly makes or breaks retrieval quality.
Building the Ingestion Pipeline
Wire the pieces into one repeatable pipeline: load, chunk, embed, store. Then handle the part everyone forgets — re-ingesting documents when they change.
Retrieval & Reranking
Retrieval is where RAG quality is won or lost. Tune top-k, add keyword search for exact terms, and rerank the candidates so the best passages reach the model.
Generation: Answering from Context
The final step: hand the retrieved passages to the model and make it answer only from them — with citations, and an honest "I don’t know" when the context is silent.
Frameworks: LangChain & LlamaIndex
You built RAG by hand so you understand every part. Now see how LangChain and LlamaIndex collapse it into a few lines — and when the raw SDK is still the better choice.