Retrieval-Augmented Generation (RAG) · Lesson 5 of 7
Hybrid search and reranking
Combine lexical and semantic retrieval, then rank candidates for the question.
Lesson
Lexical retrieval matches terms and identifiers; semantic retrieval can match related meaning even when phrasing differs. Combining signals can improve coverage for questions that include both domain language and exact product names. The candidate lists need a deliberate merge strategy because raw scores from different methods may not be directly comparable. A ranker can then evaluate each candidate passage in relation to the full query and reorder the shortlist.
Every added retrieval stage has a latency and cost. Compare lexical-only, semantic-only, and hybrid candidates on the same relevance labels. Check whether relevant passages appear in the candidate set before tuning the reranker; a ranker cannot recover evidence that was never retrieved.
Keyword and semantic retrieval solve different failure patterns. Lexical search is often strong for exact identifiers, product names, and quoted phrases; vector retrieval can find paraphrases whose wording differs from the source. A hybrid approach combines candidate sets, then a ranker can reorder the candidates using the query and passage together. More stages add latency and cost, so compare them on the same labeled query set. Inspect cases where a relevant result is missing, buried, or duplicated, and tune candidate depth, filters, and ranking only against measured evidence.
Implementation drill: trace one representative request through the stages in the diagram. Write down what enters each stage, what output or evidence it produces, and which identity is allowed to perform it. Then test an empty input, an unauthorized request, a dependency timeout, and an unexpected result. For each case, state whether the application should retry, reject, abstain, or ask a person for help. Keep the observed failure as a regression example so changes to prompts, models, data, or code can be checked against the same behavior.
Practice task: Can a reranker return a relevant passage that was not in its candidate set?
Visual guide
Combine search signals and rerank
-
Step 01
Lexical
Find exact terms and identifiers.
-
Step 02
Semantic
Find related meaning and paraphrases.
-
Step 03
Merge
Combine candidate passages.
-
Step 04
Rerank
Order candidates against the question.
Key points
- Lexical and semantic retrieval address different query patterns.
- Merge candidates carefully and do not assume scores are calibrated alike.
- Measure candidate recall before tuning a reranker.
Check your understanding
Practice
Your learning progress