Understanding RAG - step by step with real data
We build a Retrieval-Augmented Generation system from scratch. Real embeddings, a real vector database, and demos you can pause and pull apart whenever you want.
A language model only knows what was in its training data at the time. It knows nothing about your manuals, your team's tickets or last week's meeting notes. Ask anyway and you don't get an error message - you get a plausible-sounding invention. That is what makes the gap dangerous.
Retrieval-Augmented Generation flips the order around: search first, answer second. For every question, the matching passages are pulled from your own material and handed to the model as context. The model then only phrases what lies in front of it. That sounds simple. The work is in the steps in between.
What we build here
We build a RAG system from scratch, step by step, each step verifiable on its own: how text becomes numbers that carry meaning; why a document has to be cut into pieces and what a bad cut costs; how a vector database finds the nearest neighbours in milliseconds - we use pgvector in Postgres, because Postgres is already running in most projects; and how a list of hits turns into an answer you can point back at a source.
The second half of the course is the less comfortable one. A RAG system that works in a demo rarely fails in production because of the model. It fails because of badly placed chunk boundaries, questions the corpus has no answer for, and hits that are similar without being relevant. We look at each of these failure patterns separately - and measure them instead of guessing at them.
How you work through it
Almost every chapter comes with a lab that runs in the browser: a naive RAG you can poke at, an embedding explorer, a chunking workshop, a comparison of retrieval strategies, and a lab where you produce failures on purpose. You can pause any demo, change a parameter and watch what shifts. That is the actual point: RAG is not a recipe, it is a chain of decisions with visible consequences.
We assume an LLM call is not new to you and that you know what a prompt is. Programming helps when you carry this over to your own project, but the labs don't need it - they run without any installation. Whoever finishes the course can not only describe a RAG system, but name the exact place where their own one goes wrong.