Milvus官方教混合搜索
向量搜索擅长语义匹配,但搜索精确型号如“XR-2048”可能出错。BM25能精确匹配术语,但会漏掉语义相近的“refund policy”和“return process”。Milvus通过RRF(Reciprocal Rank Fusion)融合向量搜索和BM25结果。配置只需三步:添加稠密和稀疏向量字段、启用内建BM25函数、使用RRFRanker。内建BM25时不要手动插入稀疏向量,外部模型如BGE-M3才需手动提供。
Vector search works well when semantic meaning matters, but it can be unreliable with exact terms. S...
Vector search works well when semantic meaning matters, but it can be unreliable with exact terms. Search for "XR-2048" using vector search alone, and you may get specs for a similar product, but not the exact model you asked for. BM25 is better at the thing vector search often misses: exact terms. Search for “refund policy” when the document says “return process,” though, and BM25 may miss it. 𝗧𝗵𝗮𝘁'𝘀 𝘄𝗵𝘆 𝗵𝘆𝗯𝗿𝗶𝗱 𝘀𝗲𝗮𝗿𝗰𝗵 𝗲𝘅𝗶𝘀𝘁𝘀. 𝗩𝗲𝗰𝘁𝗼𝗿 𝘀𝗲𝗮𝗿𝗰𝗵 𝗰𝗼𝘃𝗲𝗿𝘀 𝘀𝗲𝗺𝗮𝗻𝘁𝗶𝗰 𝗺𝗮𝘁𝗰𝗵𝗲𝘀, 𝗕𝗠𝟮𝟱 𝗰𝗮𝘁𝗰𝗵𝗲𝘀 𝗲𝘅𝗮𝗰𝘁 𝘁𝗲𝗿𝗺𝘀, 𝗮𝗻𝗱 𝗥𝗥𝗙 (𝗥𝗲𝗰𝗶𝗽𝗿𝗼𝗰𝗮𝗹 𝗥𝗮𝗻𝗸 𝗙𝘂𝘀𝗶𝗼𝗻) 𝗺𝗲𝗿𝗴𝗲𝘀 𝗯𝗼𝘁𝗵 𝗶𝗻𝘁𝗼 𝗼𝗻𝗲 𝗿𝗮𝗻𝗸𝗲𝗱 𝗹𝗶𝘀𝘁. 𝗜𝗻 𝗠𝗶𝗹𝘃𝘂𝘀, 𝘆𝗼𝘂 𝗰𝗮𝗻 𝘀𝗲𝘁 𝘁𝗵𝗶𝘀 𝘂𝗽 𝗶𝗻 𝘁𝗵𝗿𝗲𝗲 𝘀𝘁𝗲𝗽𝘀: 1️⃣ Add both dense and sparse vector fields to the same collection 2️⃣ Enable the built-in BM25 Function so Milvus can generate sparse vectors from raw text 3️⃣ Use RRFRanker to fuse the vector and BM25 results ⚠️ 𝗢𝗻𝗲 𝗶𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗻𝗼𝘁𝗲: 𝗜𝗳 𝘆𝗼𝘂 𝘂𝘀𝗲 𝘁𝗵𝗲 𝗯𝘂𝗶𝗹𝘁-𝗶𝗻 𝗕𝗠𝟮𝟱 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻, 𝗱𝗼 𝗻𝗼𝘁 𝗺𝗮𝗻𝘂𝗮𝗹𝗹𝘆 𝗶𝗻𝘀𝗲𝗿𝘁 𝘀𝗽𝗮𝗿𝘀𝗲 𝘃𝗲𝗰𝘁𝗼𝗿𝘀. Milvus generates them for you. You only provide your own sparse vectors when using an external sparse embedding model, such as BGE-M3. 𝗜𝗳 𝘆𝗼𝘂𝗿 𝗾𝘂𝗲𝗿𝗶𝗲𝘀 𝗶𝗻𝗰𝗹𝘂𝗱𝗲 𝗽𝗿𝗼𝗱𝘂𝗰𝘁 𝗻𝗮𝗺𝗲𝘀, 𝗲𝗿𝗿𝗼𝗿 𝗰𝗼𝗱𝗲𝘀, 𝗔𝗣𝗜 𝗲𝗻𝗱𝗽𝗼𝗶𝗻𝘁𝘀, 𝗼𝗿 𝗼𝘁𝗵𝗲𝗿 𝗲𝘅𝗮𝗰𝘁 𝗶𝗱𝗲𝗻𝘁𝗶𝗳𝗶𝗲𝗿𝘀, 𝘃𝗲𝗰𝘁𝗼𝗿 𝘀𝗲𝗮𝗿𝗰𝗵 𝗮𝗹𝗼𝗻𝗲 𝗶𝘀 𝗽𝗿𝗼𝗯𝗮𝗯𝗹𝘆 𝗻𝗼𝘁 𝗲𝗻𝗼𝘂𝗴𝗵. 𝗧𝗿𝘆 𝗵𝘆𝗯𝗿𝗶𝗱 𝘀𝗲𝗮𝗿𝗰𝗵. 💬 0 🔄 0 ❤️ 2 👀 43 ⚡