Retrieval Benchmark for a Docs Corpus
A reproducible experiment that ingests a licensed documentation corpus and compares chunking, embedding and hybrid search configurations by precision@k and recall@k. The winning configuration and its code feed the capstone.
- Intermediate
- 5 milestones · 35 steps in all
- Quizzes on 5 skills
- Self-paced
Start with M1: Corpus and labelled queries. Build it one step at a time; your progress is saved as you go.
What you will build
- Build a labelled benchmark: a licensed docs corpus and 20 queries with the documents that answer them.
- Ingest the corpus deterministically, with stable chunk IDs and source metadata.
- Measure an exact-search baseline with correctly computed mean precision@k and recall@k.
- Compare chunking settings, embedding models and hybrid BM25 + vector search, and choose on the numbers.
- Trace missed queries to the stage that failed and carry the winning configuration into the RAG assistant.
Tools and ground rules
- Python 3.12 with NumPy, sentence-transformers (small local models), rank-bm25 and pytest.
- A corpus whose licence allows your use (for example MIT, BSD, Apache-2.0 or CC BY), recorded with its source and commit.
- Free and local: no paid provider or API key at any milestone, and no secrets in the repository.
- The benchmark reruns from a clean checkout with the documented commands and gives the same table.
Getting started
Follow the milestones in order. Each one is a short list of steps you work through and mark done, and ends with a quiz on each skill it used: passing a quiz is what counts as evidence for that skill.
From brief to evidence
- Milestone 1 · M1
Corpus and labelled queries
Licensed corpus, ingestion script and 20 queries with expected source IDs
Done when: The licence is confirmed and every query lists at least one expected source.
7 steps
- Create the repository and environment
- Choose a corpus and check its licence
- Record where the corpus came from
- Load every document with a stable ID
- Write 20 labelled queries
- Check the query file automatically
- Test the checker and commit the benchmark
- Milestone 2 · M2
Deterministic ingestion
Parsing and chunking pipeline producing stable chunk IDs with source metadata
Done when: An automated test runs ingestion twice and gets identical chunk IDs and counts.
7 steps
- Normalise the text first
- Split Markdown into sections, skipping code blocks
- Write two chunking settings
- Test the parser and the chunkers
- Give every chunk a stable ID and its metadata
- Write the chunks and print a fingerprint
- Prove ingestion is deterministic, then commit
- Milestone 3 · M3Includes an exercise
Baseline index and metrics
Exact-search baseline plus a script computing mean precision@k and recall@k
Done when: The metric code passes the platform's retrieval-metrics fixture.
7 steps
- Embed the chunks and cache the vectors
- Search exactly with NumPy
- Write precision@k and recall@k
- Test the metrics on cases you can work out by hand
- Check your metric code on the Tech Atlas fixture
- Score a retriever on the 20 queries
- Run the baseline and save per-query results
- Milestone 4 · M4
Configuration comparison
Results table for at least two chunking settings, two embedding models and hybrid search
Done when: A reviewer reruns the benchmark, reproduces the table and finds the chosen configuration justified by its numbers.
7 steps
- Add keyword search with BM25
- Fuse the two rankings with reciprocal rank fusion
- Test fusion on a case you can compute
- Define every configuration in one place
- Run the comparison with one command
- Check that a rerun gives the same table
- Choose a configuration and justify it
- Milestone 5 · M5
Failure analysis
Write-up of at least three missed queries with causes and proposed fixes
Done when: Each failure is traced to a stage (parsing, chunking, embedding or ranking) with evidence from the run.
7 steps
- List the queries that were missed
- Trace a query through each retriever
- Name the stage that failed, with evidence
- Write up each failure and a fix
- Try one fix: put the heading path in every chunk
- Rerun the full table and compare
- Rerun from a fresh clone and hand over
A project worth finishing
Finish all 5 milestones and pass their quizzes to demonstrate the skills this project uses. Next in the series: Build a Grounded RAG Assistant.