RAG lesson 04 · Rerank and assemble context
Versioned evidence corpus · deterministic retrieval fixtures
Lighthouse Policy Evidence Assistant. A fictional support assistant answers questions from a versioned product-policy corpus. It must retrieve current, authorized evidence, cite exact source spans, and abstain when evidence is missing or conflicting.
01 · Smallest useful mechanism
A reranker can score query-document interaction more precisely over a small candidate set. Context assembly then removes duplicates, preserves necessary parent context, handles conflicts, and orders spans within a token budget.
Candidate recall and final context precision are different optimization problems.
02 · Experiment
Deterministic retrieval fixture
This workbench uses inspectable ranking and evidence fixtures and injected failures. It does not make live calls or execute external effects.
Retrieval workbench · lighthouse-context-v4
Injected failure
Five overlapping FAQ chunks outrank the exception and consume 1,300 tokens.
The trace has not run.
Commit to an implementation, then inject the failure and inspect the actual state transitions.
03 · Implementation brief
Your learning artifact
Stored only in this browser. No account required; course reset does not delete it.
04 · Check your understanding
Primary sources · verified 2026-08-02
Blind top-k packing repeats overlapping chunks, buries decisive evidence, and increases latency and prompt-injection surface. Long context capacity does not guarantee uniform use of every position.
Common mistake: If context fits in the window, adding it cannot hurt. Distractors, contradictions, redundancy, and evidence position can change model behavior even when every token technically fits.
Transfer exercise: Compare fused-rank order, cross-encoder reranking, and a budgeted evidence packet when three chunks repeat the same rule.
Next: A precise evidence packet still needs a generation contract that maps claims to supporting spans and declines unsupported answers.