RAG Optimization · Module 02
Advanced Retrieval Strategies
Why vector search alone misses exact terms, how BM25 scores keywords, and how hybrid search merges both result lists with Reciprocal Rank Fusion.
Học xong bạn làm được
- Explain where vector search fails and BM25 helps
- Describe TF saturation, IDF and length normalisation in BM25
- Build a hybrid retriever and merge results with RRF
- Describe late-interaction, Matryoshka and multimodal embeddings
Bài học
- Advanced Retrieval Strategies: Vector Search and BM25
Vector search captures meaning but misses exact wording such as proper names, product codes and rare terms - an "Error 503" query can come back with "server overloaded". BM25, the gold standard of classical keyword retrieval and a refined TF-IDF, fixes this with term-frequency saturation, IDF and length normalisation.
- Hybrid Search
Hybrid search is not a new algorithm but a process - send the query to a sparse retriever (BM25) and a dense retriever (vector search) in parallel, fuse the two result lists into one, and rank the result to give the LLM the top-K documents.
- Reciprocal Rank Fusion (RRF)
Vector search scores lie in [0, 1] while BM25 scores can be any positive number, so they cannot be added. RRF ignores scores and uses ranks - each document gets the sum of 1 / (k + rank) over the lists, with k usually 60 - so a document ranked well by both engines beats one ranked first by only one.
- Modern Embedding Techniques (2025-2026)
ColBERT v2 represents queries and documents as token vectors and scores them by late interaction (MaxSim), at the cost of a much larger index. Matryoshka Representation Learning makes the first N dimensions a valid smaller embedding, cutting storage. Natively multimodal models embed text, images, video, audio and PDFs in one shared space.
- Assignment: Hybrid Search
Hybrid Search with BM25 and Reciprocal Rank Fusion