Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Retrieval and Knowledge Systems

Free · sign in to start and track progress

1 · Building the index

  • 1Embeddings in practice
  • 2Chunking structured documents
  • 3Vector indexes and databases
  • 4Measuring retrieval

    Exercise answers

    • Answer: Build and run a labelled query set
    • Answer: Verify citations end to end (stretch)

2 · Retrieval that reasons

  • 5Hybrid search and reranking
  • 6Agentic retrieval
  • 7Knowledge graphs and GraphRAG
  • 8Long context versus RAG
CapstoneA measured retrieval service for cases and reference documentsReference implementation

Module 1 · Building the index · Lesson 4

Measuring retrieval

How to build a labelled query set from real user questions, compute recall@k, MRR and nDCG, and check that answers are grounded in what was retrieved.

75 min 1 video 3 exercises 6-question quiz Answers
Setup for the exercises:Python with uvInstall Claude CodeGet an OpenRouter keyLocal models with Ollama

By the end of this lesson you can

  • Build a stratified, labelled query set from case and reference-library questions, with graded relevance at block level and no-answer queries
  • Compute recall@k, MRR and nDCG@k by hand and in code, and explain what each one rewards
  • Choose the metric and k that match how an agent consumes results
  • Measure faithfulness and citation correctness end to end, and separate retrieval failures from generation failures

On this page

  • Two layers of evaluation
  • Building the query set
  • Where the questions come from
  • Stratify
  • Label at block level, with grades
  • Pool before you label
  • The metrics
  • Worked example
  • Answer-level metrics
  • Faithfulness (groundedness)
  • Citation correctness, in code
  • Correctness
  • Running it continuously
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Two layers of evaluation
  2. 02Building the query set
  3. 03The metrics
  4. 04Answer-level metrics
  5. 05Running it continuously
  6. 06Connections
  7. 07Summary

Sources & further reading

  • BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval ModelsPaper · Thakur, Reimers, Rücklé, Srivastava, Gurevych · 2021The standard zero-shot retrieval benchmark across 18 datasets. Read why it reports nDCG@10, its finding that BM25 is a robust baseline, and its discussion of bias when relevance labels come from one kind of retrieval system.
  • Ragas: Automated Evaluation of Retrieval Augmented GenerationPaper · Es, James, Espinosa-Anke, Schockaert · 2023Defines faithfulness as the share of an answer's claims that the retrieved context supports, plus context relevance and answer relevance. Read section 3 for how each is computed with an LLM.
  • ARES: An Automated Evaluation Framework for Retrieval-Augmented Generation SystemsPaper · Saad-Falcon, Khattab, Potts, Zaharia · Stanford · 2024Trains small judges for context relevance, faithfulness and answer relevance, and uses a few hundred human labels with prediction-powered inference to put confidence intervals on judged scores.
  • Hallucination-Free? Assessing the Reliability of Leading AI Legal Research ToolsPaper · Magesh, Surani, Dahl, Suzgun, Manning, Ho · Stanford · 2024Commercial retrieval-backed legal research tools hallucinated between 17% and 33% of the time. Read the typology of errors, especially answers that cite a real source that doesn't support them.
  • LegalBench-RAG: A Benchmark for Retrieval-Augmented Generation in the Legal DomainPaper · Pipitone, Houir Alami · 20246,858 expert-labelled queries that score retrieval of minimal relevant snippets in contracts and policies, rather than whole documents. A model for labelling at span level; read its results tables critically.
  • Search results (citations for RAG)Docs · AnthropicPass retrieved chunks as search_result blocks and Claude returns structured citations with the cited text and source, which you can verify in code.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 7 more sections
  • 3 hands-on exercises
  • A 6-question quiz
  • Progress, quiz scores and bookmarks