CourseRetrieval-Augmented Generation: The Complete Course · Module 8: Reranking and Post-Retrieval Processing · part 57 of 95
Part 57 · Module 8: Reranking and Post-Retrieval Processing

Lab: Rerank and assemble the context

55 min read·13 Oct 2026
Module 8 · Lab · About 75 minutes · Needs: lessons 1 and 2 of this module, and the Module 6 lab (or the cells in Step 1)

What you are building

MODULE 8 IN THE PACKAGE: QUESTION AND USER IN, ONE CONTEXT OUT Module 6 Search filter, bar, signals Reranker MiniLM, 10 chunks keep_strong bar -6 collapse, compress sentence bar -5 group, order best first fit_budget 200 tokens context + sources + reason Ellie: 3 labelled blocks, 182 tokens; Module 9 reads it
The lab's piece: Module 6's search (grey, unchanged) feeds the reranker and the context steps (blue), which end in one labelled context and its sources (green) for Module 9.

On Friday 9 October Hollin's search ends at Module 6: a user and a question in, up to ten permitted chunks out, ordered by fused scores and Module 6's signals. Lesson 1 showed a cross-encoder orders such a list better; Lesson 2 turned a ranked list into a small, labelled context. This lab moves them into the package, on top of Module 6's chunk search: hollin/rerank.py reorders the ten chunks, and hollin/context.py applies the bars, collapses copies, keeps relevant sentences and fits whole blocks into 200 tokens. You re-measure on chunks what the lessons measured on documents, probe every user for leaks, write the tests and commit. No language model is called; Module 9 reads what this lab builds.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.