insideout Get Pro
Learn
AI engineering · Module 09

Search and Retrieval

Find the right text and ground a model's answer in it.

Start here · Lesson 01

Keyword search with TF-IDF and BM25

Score documents by the words they share with the query.

Start lesson

LessonsAll lessons

  1. 01 Keyword search with TF-IDF and BM25Score documents by the words they share with the query. Free
  2. 02 Vector searchFind text by meaning with embeddings and nearest neighbours. Free
  3. 03 Combining keyword and vector searchFuse two ranked lists into one that beats both. Free
  4. 04 RerankingA slower model rescores the top results for precision. Pro
  5. 05 Chunk size and overlapHow you split documents decides what search can find. Pro
  6. 06 Indexes at scale with HNSWApproximate nearest neighbours, fast enough for millions of vectors. Pro
  7. 07 Filters and metadataCombine vector search with dates, owners and permissions. Pro
  8. 08 Measuring search with recall, MRR and NDCGScore a ranked list, and pick the metric that matches the job. Pro
  9. 09 Answering from documentsRetrieve passages, then have the model answer from them. Pro
  10. 10 Citing sourcesMake every claim point to the passage it came from. Pro
  11. 11 Checking answers against sourcesTest whether each answer is supported by what was retrieved. Pro
  12. 12 Why grounded answers still go wrongMissed passages, conflicting sources, and claims the text doesn't support. Pro
  13. 13 Knowledge graphs and GraphRAGStore the links between facts, and know when a graph beats vectors. Pro
  14. 14 Capstone: a search-backed assistantBuild and measure an assistant that answers from your documents. Pro

Build it yourself · on your own machine

Search over your own notes

A hybrid search over a folder of your own notes, with a scorecard that shows whether each part earns its place.
  1. Split a folder of your notes (or a project's docs) into pieces of about 300 words, each keeping its file name and heading.
  2. Build a keyword index with BM25 and an embedding index with a small local model.
  3. Combine the two rankings with reciprocal rank fusion.
  4. Write 20 questions and, for each, the piece that answers it; measure recall at 5 for keywords, embeddings and the hybrid.
  5. Read the misses, fix one cause (piece size, a missing synonym, a heading boost) and measure again.

How you'll know it worksA table of recall at 5 for all three, before and after your fix, and one sentence on which change helped and why.

Python, rank_bm25, sentence-transformers with all-MiniLM-L6-v2 (runs locally, no API) and NumPy. Uses lessons 01 to 14.