N
NexusDigitalLabs
← Back to Academy

Phase 3 — Core AI Engineering · Lesson 30 · 20 XP

Hybrid search, reranking, citations

Vector search alone can miss exact matches — a product code, a person's name, an acronym — because embeddings capture meaning, not precise tokens. Hybrid search runs a keyword search (like Postgres full-text search or BM25) alongside vector search and combines both result sets, catching what either one alone would miss.

Reranking adds a second pass: take the top 20-50 candidates from the first-pass retrieval and score them with a more expensive, more accurate model, keeping only the true top few. It's applied only to the shortlist because reranking every document in a large corpus would be far too slow and costly. Attaching a citation — which chunk or source backed a given claim — makes the final answer verifiable and makes your own debugging much easier.

Exercise

Add keyword search alongside your Lesson 29 vector search, combine the two result sets, and attach a source citation to each retrieved chunk so the final answer can reference exactly where it came from.

Check yourself

1. Give one example of a query where keyword search would beat pure vector search.

2. Why rerank only the top-N candidates instead of reranking the entire corpus?

← Previous lesson

Chunking and the RAG pipeline

Answer the check-yourself questions to unlock this