Living note
A Retrieval Pipeline That Can Be Debugged
Separate candidate generation, ranking, context assembly, and answer generation into observable stages.
Retrieval quality is easier to improve when each stage produces an inspectable artifact.
Four inspectable stages
- Generate a broad candidate set.
- Rank against the actual user intent.
- Assemble a bounded context window.
- Generate with source references.
const candidates = await retrieve(query, { limit: 40 });
const ranked = await rerank(query, candidates);
const context = assembleContext(ranked.slice(0, 6));