/Learn

Beginner · 200 minutes

Build a RAG Pipeline from Embeddings to Answers

Generate embeddings locally, measure cosine similarity, store vectors in Chroma, add BM25 hybrid search and a reranker, then produce grounded answers with citations.

7 modules 200 minutes 250 points By Sammy Deprez
Outcomes

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
Curriculum

Course modules

1

Set up and load data

Create the project, install the dependencies, and define the document corpus you will search.

2 pages · 2 questions
2

Embeddings

Turn every passage into a vector with a local model and inspect what you get.

1 pages · 2 questions
3

Cosine similarity

Score a question against every passage and keep the best matches.

1 pages · 2 questions
4

Vector database

Store the vectors in Chroma, query them, and filter by metadata.

1 pages · 2 questions
5

Hybrid search

Add BM25 keyword search and merge it with dense results using reciprocal rank fusion.

2 pages · 3 questions
6

Reranking

Reorder the candidate passages with a cross-encoder that reads the question and each passage together.

1 pages · 2 questions
7

Answers

Generate a grounded answer from the retrieved passages, with citations, using Groq.

1 pages · 3 questions