Skip to content

Module 3 of Building a RAG system. About 90 minutes.

Retrieval

Build keyword search, compare it with search by meaning and a hybrid of the two, and fix clinic shorthand with an abbreviation table. Then look at what retrieval returns for each of the ten questions, before any model sees it.

Open the notebook in Colab View it on GitHub

Colab opens a fresh copy each time. Save your own with File, then Save a copy in Drive.

A simulation with hand-set scores. Try the third question: the closest match is not the right one.

What you do in this module

  1. Build keyword search (BM25), and see why drug names favour it.
  2. Mix keyword and vector scores into hybrid search.
  3. Add an abbreviation table, so "HBC" finds the hit-by-car protocol.
  4. Filter results by species and status.
  5. Inspect the top results for all ten questions.

The habit of looking at retrieval first is the most useful thing in the course. If the right passage is not retrieved, no prompt can fix the answer. Nothing in this module calls Gemini.

Before you start: a question no document covers. How many results does search return?

The usual number. Search always returns its top results, however poor the match. Deciding that they do not answer the question is a job for the next step, which Module 4 builds.

Where next

Building a RAG system: Module 4: Generation with citations

A shared question channel is on the way. When it opens, each answer will be written once and shared with everyone taking the course.