Retrieve, filter, and rerank evidence
Build a candidate set and improve its ordering before generation.
- Explain top-k retrieval, metadata filters, and reranking.
A retriever often returns the top k candidate passages by a score. Metadata filters can constrain results to an allowed tenant, document type, or time period. A reranker then evaluates query-passage pairs more precisely and reorders a smaller candidate set. These stages improve selection but still need evaluation on representative questions.
A small example
1candidates = [("old policy", 0.86), ("current policy", 0.82), ("faq", 0.51)]
2# Apply a freshness preference after retrieval
3ranked = sorted(candidates, key=lambda item: ("current" in item[0], item[1]), reverse=True)
4print(ranked[0][0])current policy
Too few candidates can omit the needed evidence; too many can add noise and cost. Apply authorization filters before content reaches the model. A reranker cannot recover a relevant document that candidate retrieval never found.
Key takeaways
Explain top-k retrieval, metadata filters, and reranking.
Check that retrieved evidence is relevant, current, and allowed for this user.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…