Build a small retrieval augmented generation pipeline from the ground up, one idea at a time. You will turn text into vectors with a local embedding model, measure how close two meanings are with cosine similarity, store and query those vectors in a database, then improve retrieval with keyword search, hybrid fusion, and reranking, and finally generate an answer grounded in the retrieved passages.
Everything runs locally and free. The embedding and reranking models download once, and the only external service is Groq, which is used just for the final answering chapter and has a free tier.
Your workshop route
| Chapter | Pages | What you produce | Lesson time |
|---|---|---|---|
| 1. Set up and load data | 2 | A project, dependencies, and a document corpus | 25 minutes |
| 2. Embeddings | 1 | A script that turns text into vectors | 22 minutes |
| 3. Cosine similarity | 1 | A ranked list of passages by meaning | 22 minutes |
| 4. Vector database | 1 | The same search stored and queried in Chroma | 26 minutes |
| 5. Hybrid search | 2 | Dense plus BM25 results merged with RRF | 33 minutes |
| 6. Reranking | 1 | A cross-encoder that reorders the candidates | 22 minutes |
| 7. Answers | 1 | A grounded answer with citations | 26 minutes |
Each chapter pairs the hands-on steps with a short theory section, so you always know why the code works, not only what it does. Allow about 175 minutes for lessons and exercises, 15 minutes for chapter checks, and 10 minutes for the final test. The first run downloads the models, which can add a few minutes.
Each chapter ends with two or three questions, and the final test has ten new questions. For multiple-choice questions, select every correct option. Every question must be correct to pass a check or the final test.
How you will work
Each chapter adds a few functions to a file called rag.py and ends with a small check you can run. The complete reference for every step is shown in the lesson, so you can compare if you get stuck and then continue from your own file.
If you have not read RAG Essentials, read it first. It explains the ideas behind each step in plain language, and this workshop assumes them.
Keep any API key in a local .env file and never commit it.
What you will learn
- Generate text embeddings locally and explain what their dimensions mean
- Compute cosine similarity and rank documents by meaning
- Store and query vectors in Chroma, including metadata filters
- Add BM25 keyword search and merge results with reciprocal rank fusion
- Rerank candidates with a cross-encoder and explain when it helps
- Generate a grounded answer that cites the passages it used
Before you start
- You can read and edit Python functions, lists, and dictionaries
- Python 3.10 or newer, a terminal, and a code editor
- About 2 GB of free disk space for the embedding and reranking models
- A free Groq API key, optional and used only for the answering chapter
Course modules
Set up and load data
Create the project, install the dependencies, and define the document corpus you will search.
Embeddings
Turn every passage into a vector with a local model and inspect what you get.
Cosine similarity
Score a question against every passage and keep the best matches.
Vector database
Store the vectors in Chroma, query them, and filter by metadata.
Hybrid search
Add BM25 keyword search and merge it with dense results using reciprocal rank fusion.
Reranking
Reorder the candidate passages with a cross-encoder that reads the question and each passage together.
Answers
Generate a grounded answer from the retrieved passages, with citations, using Groq.