Skip to content

Commit 628905c

Browse files
Milvus-doc-botMilvus-doc-bot
authored andcommitted
Generate en docs
1 parent 5c05c7d commit 628905c

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

localization/v2.4.x/site/en/userGuide/search-query-get/single-vector-search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

localization/v2.4.x/site/en/userGuide/search-query-get/single-vector-search.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ res = <span class="hljs-keyword">await</span> client.<span class="hljs-title fun
17691769
</svg>
17701770
</button></h2><p>In Milvus, grouping search is designed to improve comprehensiveness and accuracy for search results.</p>
17711771
<p>Consider a scenario in RAG, where loads of documents are split into various passages, and each passage is represented by one vector embedding. Users want to find the most relevant passages to prompt the LLMs accurately. The ordinary Milvus search function can meet this requirement, but it may result in highly skewed and biased results: most of the passages come from only a few documents, and the comprehensiveness of the search results is very poor. This can seriously impair the accuracy or even correctness of the results given by the LLM and influence the LLM users’ experience negatively.</p>
1772-
<p>Grouping search can effectively solve this problem. By passing a group_by_field and group_size, Milvus users can bucket the search results into several groups and ensure that the number of entities from each group does not exceed a specific group_size. This feature can significantly enhance the comprehensiveness and fairness of search results, noticeably improving the quality of LLM output.</p>
1772+
<p>Grouping search can effectively solve this problem. By passing a <code translate="no">group_by_field</code>, Milvus users can bucket the search results into several groups. This feature can significantly enhance the comprehensiveness and fairness of search results, noticeably improving the quality of LLM output.</p>
17731773
<p>Here is the example code to group search results by field:</p>
17741774
<pre><code translate="no" class="language-python"><span class="hljs-comment"># Connect to Milvus</span>
17751775
client = MilvusClient(uri=<span class="hljs-string">&#x27;http://localhost:19530&#x27;</span>) <span class="hljs-comment"># Milvus server address</span>
@@ -1787,8 +1787,6 @@ res = client.search(
17871787
}, <span class="hljs-comment"># Search parameters</span>
17881788
limit=<span class="hljs-number">5</span>, <span class="hljs-comment"># Max. number of groups to return</span>
17891789
group_by_field=<span class="hljs-string">&quot;doc_id&quot;</span>, <span class="hljs-comment"># Group results by document ID</span>
1790-
group_size=<span class="hljs-number">2</span>, <span class="hljs-comment"># returned at most 2 passages per document, the default value is 1</span>
1791-
group_strict_size=<span class="hljs-literal">True</span>, <span class="hljs-comment"># ensure every group contains exactly 3 passages</span>
17921790
output_fields=[<span class="hljs-string">&quot;doc_id&quot;</span>, <span class="hljs-string">&quot;passage_id&quot;</span>]
17931791
)
17941792

@@ -1821,8 +1819,6 @@ res = client.search(
18211819
}, <span class="hljs-comment"># Search parameters</span>
18221820
limit=<span class="hljs-number">5</span>, <span class="hljs-comment"># Max. number of search results to return</span>
18231821
<span class="hljs-comment"># group_by_field=&quot;doc_id&quot;, # Group results by document ID</span>
1824-
<span class="hljs-comment"># group_size=2, </span>
1825-
<span class="hljs-comment"># group_strict_size=True,</span>
18261822
output_fields=[<span class="hljs-string">&quot;doc_id&quot;</span>, <span class="hljs-string">&quot;passage_id&quot;</span>]
18271823
)
18281824

@@ -1838,10 +1834,9 @@ passage_ids = [result[<span class="hljs-string">&#x27;entity&#x27;</span>][<span
18381834
[<span class="hljs-meta">1, 10, 3, 12, 9</span>]
18391835
<button class="copy-code-btn"></button></code></pre>
18401836
<p>In the given output, it can be observed that “doc_11” completely dominated the search results, overshadowing the high-quality paragraphs from other documents, which can be a poor prompt to LLM.</p>
1841-
<p>One more point to note: by default, grouping_search will return results instantly when it has enough groups, which may lead to the number of results in each group not being sufficient to meet the group_size. If you care about the number of results for each group, set group_strict_size=True as shown in the code above. This will make Milvus strive to obtain enough results for each group, at a slight cost to performance.</p>
18421837
<p><strong>Limitations</strong></p>
18431838
<ul>
1844-
<li><p><strong>Indexing</strong>: This grouping feature works only for collections that are indexed with the <strong>HNSW</strong>, <strong>IVF_FLAT</strong>, or <strong>FLAT</strong> type. For more information, refer to <a href="https://milvus.io/docs/index.md#HNSW">In-memory Index</a>.</p></li>
1839+
<li><p><strong>Indexing</strong>: This grouping feature works only for collections that are indexed with these index types: <strong>FLAT</strong>, <strong>IVF_FLAT</strong>, <strong>IVF_SQ8</strong>, <strong>HNSW</strong>, <strong>DISKANN</strong>, <strong>SPARSE_INVERTED_INDEX</strong>.</p></li>
18451840
<li><p><strong>Vector</strong>: Currently, grouping search does not support a vector field of the <strong>BINARY_VECTOR</strong> type. For more information on data types, refer to <a href="https://milvus.io/docs/schema.md#Supported-data-types">Supported data types</a>.</p></li>
18461841
<li><p><strong>Field</strong>: Currently, grouping search allows only for a single column. You cannot specify multiple field names in the <code translate="no">group_by_field</code> config. Additionally, grouping search is incompatible with data types of JSON, FLOAT, DOUBLE, ARRAY, or vector fields.</p></li>
18471842
<li><p><strong>Performance Impact</strong>: Be mindful that performance degrades with increasing query vector counts. Using a cluster with 2 CPU cores and 8 GB of memory as an example, the execution time for grouping search increases proportionally with the number of input query vectors.</p></li>

localization/v2.5.x/site/en/userGuide/search-query-get/grouping-search.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ res = <span class="hljs-keyword">await</span> client.<span class="hljs-title fun
371371
></path>
372372
</svg>
373373
</button></h2><ul>
374+
<li><p><strong>Indexing</strong>: This grouping feature works only for collections that are indexed with these index types: <strong>FLAT</strong>, <strong>IVF_FLAT</strong>, <strong>IVF_SQ8</strong>, <strong>HNSW</strong>, <strong>HNSW_PQ</strong>, <strong>HNSW_PRQ</strong>, <strong>HNSW_SQ</strong>, <strong>DISKANN</strong>, <strong>SPARSE_INVERTED_INDEX</strong>.</p></li>
374375
<li><p><strong>Number of groups</strong>: The <code translate="no">limit</code> parameter controls the number of groups from which search results are returned, rather than the specific number of entities within each group. Setting an appropriate <code translate="no">limit</code> helps control search diversity and query performance. Reducing <code translate="no">limit</code> can reduce computation costs if data is densely distributed or performance is a concern.​</p></li>
375376
<li><p><strong>Entities per group</strong>: The <code translate="no">group_size</code> parameter controls the number of entities returned per group. Adjusting <code translate="no">group_size</code> based on your use case can increase the richness of search results. However, if data is unevenly distributed, some groups may return fewer entities than specified by <code translate="no">group_size</code>, particularly in limited data scenarios.​</p></li>
376377
<li><p><strong>Strict group size</strong>: When <code translate="no">strict_group_size=True</code>, the system will attempt to return the specified number of entities (<code translate="no">group_size</code>) for each group, unless there isn’t enough data in that group. This setting ensures consistent entity counts per group but may lead to performance degradation with uneven data distribution or limited resources. If strict entity counts aren’t required, setting <code translate="no">strict_group_size=False</code> can improve query speed.​</p></li>

0 commit comments

Comments
 (0)