Beyond Semantic Search: The Complete Guide to Advanced RAG with Milvus | Sagar Patil

· Source: Data Science on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Data Science & Analytics, Software Development & Engineering · Depth: Intermediate, extended

Summary

This guide presents a comprehensive approach to building production-ready Retrieval-Augmented Generation (RAG) systems using Milvus as the vector database. It moves beyond basic semantic search, detailing an indexing pipeline that processes PDFs into dense and sparse embeddings using OpenAI's `text-embedding-3-large` model with a dimension of 1024, and BM25, respectively. The article demonstrates basic dense vector search and then introduces hybrid search, combining dense and sparse results with RRF (Reciprocal Rank Fusion) using a k=60 smoothing constant. It systematically layers on four advanced retrieval techniques: Metadata Filtering, Query Rewriting, Hypothetical Document Embeddings (HyDE), and Query Decomposition, each addressing specific RAG failure modes. Finally, it integrates Cross-Encoder Reranking using `ms-marco-MiniLM-L12-v2` to refine the top 5 results from an initial 20 candidates, emphasizing that retrieval quality directly impacts LLM answer quality.

Key takeaway

For AI Engineers building RAG systems for production, relying solely on basic semantic search is insufficient. You should implement a multi-stage retrieval pipeline, starting with Milvus's hybrid search (dense + sparse) as a baseline. Systematically integrate advanced techniques like metadata filtering for scope, query rewriting for conversational queries, or HyDE for vague questions. Always incorporate cross-encoder reranking on retrieved candidates to significantly improve the relevance and accuracy of context provided to your LLM, ensuring robust and reliable answers.

Key insights

Advanced RAG requires multi-stage retrieval, combining hybrid search with techniques like query rewriting and reranking for production reliability.

Principles

Method

The guide outlines an indexing pipeline: PDF → Chunks (500 chars, 100 overlap) → Dense & Sparse Embeddings → Milvus Collection. Retrieval involves hybrid search, then optional advanced techniques and cross-encoder reranking.

In practice

Topics

Best for: AI Engineer, Machine Learning Engineer, MLOps Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Data Science on Medium.