KatalockAi AcademyBack to KatalockAi
Build track, required for the Phase 11 certificate

Ship a production RAG pipeline with evals

Build a RAG system on your own corpus: compared chunkers, BM25 plus dense retrieval with RRF, a cross-encoder reranker, query rewriting, cited answers that refuse when unsure, and a metric gate that fails CI.

about 26 h 6 guided steps Reviewed against a 6-point rubric
Submit your project Get coached by Professor Katalock

Build it step by step

  1. 1Chunking Strategies, ComparedPhase 19: Capstone projects
  2. 2Hybrid Retrieval with BM25 and Dense EmbeddingsPhase 19: Capstone projects
  3. 3Cross-Encoder RerankerPhase 19: Capstone projects
  4. 4Query Rewriting: HyDE, Multi-Query, and DecompositionPhase 19: Capstone projects
  5. 5RAG Evaluation: Precision, Recall, MRR, nDCG, Faithfulness, Answer RelevancePhase 19: Capstone projects
  6. 6End-to-End RAG SystemPhase 19: Capstone projects

What You'll Build

An end-to-end retrieval-augmented generation pipeline over a document set you choose, with every stage built and measured separately and then composed behind stable interfaces: chunking, hybrid retrieval, query rewriting, reranking and a citing answer generator. A labelled qrels file drives retrieval and answer metrics, and the CLI exits non-zero when any metric falls below its threshold, so the pipeline can sit in CI.

Requirements

  1. Corpus and qrels. At least 20 documents from a domain you pick (your own project docs, a public manual, a markdown wiki), mixing prose and markdown. At least 15 labelled queries with gold doc ids, graded relevance and a gold answer substring, tagged as literal, paraphrased or multi-topic, plus at least 2 queries the corpus cannot answer.
  2. Chunking. Fixed-window, sentence, recursive-split, semantic and structural-markdown chunkers, and a recall@k table (k = 1, 3, 5) on your corpus. Pick a default and justify it from the table.
  3. Hybrid retrieval. BM25 written by hand (smoothed IDF, k1 1.5, b 0.75, field weighting by repetition), a dense retriever, and reciprocal rank fusion 1 / (k + rank) with k = 60 and per-modality weights. Show one query where BM25 wins, one where dense wins and the fused rank for each.
  4. Reranker. A small PyTorch cross-encoder over packed [query] [SEP] [document] input with batched scoring, trained on labelled triples that share no queries with the eval set. Sweep the candidate budget N and report quality and latency.
  5. Query rewriting. HyDE, multi-query with RRF merge, and decomposition behind one rewriter interface, plus a per-query selector based on length and conjunctions.
  6. Answer generation. Answers built only from top-K chunks, each claim followed by a [doc_id:chunk_index] anchor, and "I do not know" when the reranker top score is below a threshold. Your unanswerable queries must produce the refusal.
  7. Evaluation. precision@k, recall@k, MRR, nDCG@k with graded gains, faithfulness (claims supported by retrieved context) and answer relevance. Report a table for at least four variants: chunker baseline, hybrid, hybrid plus rerank, and the full pipeline with rewriting.
  8. Pipeline and gate. A Pipeline with swappable stages and query() returning answer, top-K and per-stage latency. python main.py ingests the corpus, prints one full query trace, runs the eval and exits 0 only if every threshold passes, otherwise non-zero naming the failing metric. Start from the lesson 69 thresholds (recall@5 0.75, precision@1 0.50, MRR 0.60, faithfulness 0.75, answer relevance 0.75), keep them in a config file and justify any change.

Constraints

  • Runs on a CPU laptop. The hash-based mock embedding and the mock LLM from the lessons are acceptable, so the whole system can run offline with no keys.
  • Optional upgrades: a local embedding model (for example a small sentence-transformers model on CPU) and a real generator or judge through any OpenAI-compatible endpoint, including the KatalockAi API or a local model. If you add them, keep a --mock flag so the graded run is reproducible.
  • Only index documents you are allowed to share. Keep the corpus small enough to commit, or give a fetch script.

Stretch Goals

  • Add chunk summaries as a third ranked list in the fusion and measure the gain.
  • Sweep the RRF k constant (10 to 200) and plot recall@k.
  • Slice every metric by query class and report where each stage helps.

How to Submit

Public repo with rag/ (chunkers, bm25, dense, fusion, reranker, rewriter, generator, pipeline), eval/ (metrics, qrels loader), data/ (corpus or fetch script, qrels.jsonl), config/thresholds.json, main.py, tests/ and results/ (chunker table, variant metrics table, N sweep). The README must give run commands, describe the corpus and how you labelled qrels, explain each stage choice from your own numbers, use the diagnosis table from lesson 68 to explain your weakest metric, and describe one failure you fixed.

How It's Reviewed

Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.

CriterionWeightHow it's checked
End-to-end pipeline and gate25Pasted `python main.py` output shows a full query trace, the metrics table and exit 0 against thresholds in a config file; a second pasted run with a deliberately weakened stage exits non-zero naming the metric.
Retrieval stack correctness20BM25, RRF and the cross-encoder are hand-written; output shows one BM25-wins and one dense-wins query with fused ranks; reranker training queries are disjoint from eval queries; N sweep is reported.
Evaluation rigor20The learner's qrels has at least 15 tagged queries plus unanswerable ones; the variant table reports P@k, R@k, MRR, nDCG, faithfulness and relevance for at least four variants; metric tests pass.
Grounded generation10Answers carry [doc_id:chunk_index] anchors that point at retrieved chunks, and unanswerable queries return the refusal in pasted output.
Code quality10Each stage has a stable interface and can be swapped, mock and real backends share interfaces, pytest suite passes.
README and diagnosis15README covers run steps, corpus and labelling, stage choices tied to the learner's numbers, a diagnosis of the weakest metric and a fixed failure.

Submit

Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.

  • Full output of `python main.py` with the query trace, metrics table and exit code
  • Output of a run that fails the gate (for example with the reranker disabled) and its exit code
  • The chunker recall@k table and the four-variant metrics table
  • Two example answers with citations and one refusal on an unanswerable query
  • Output of `python -m pytest -q`
  • A short note on the weakest metric and what you think causes it

Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.