Skip to content

The agent engineering platform.

docs: Add Comments and Supplementary Example Code to Vearch Vector Dat… (#29706)

Edmond Wangc36e6d437175
diff --git a/docs/docs/integrations/vectorstores/vearch.ipynb b/docs/docs/integrations/vectorstores/vearch.ipynb
index da2efb893a..d5e40fdc4c 100644
--- a/docs/docs/integrations/vectorstores/vearch.ipynb
+++ b/docs/docs/integrations/vectorstores/vearch.ipynb
@@ -156,6 +156,15 @@
" db_name=\"vearch_cluster_langchian\",\n",
" table_name=\"tobenumone\",\n",
" flag=1,\n",
+ ")\n",
+ "\n",
+ "# The vector data is usually already initialized, so we don’t need the document parameter and can directly create the object.\n",
+ "vearch_cluster_b = Vearch(\n",
+ " embeddings,\n",
+ " path_or_url=\"http://test-vearch-langchain-router.vectorbase.svc.ht1.n.jd.local\",\n",
+ " db_name=\"vearch_cluster_langchian\",\n",
+ " table_name=\"tobenumone\",\n",
+ " flag=1,\n",
")"
]
},
@@ -244,6 +253,7 @@
],
"source": [
"query = \"你知道凌波微步吗,你知道都有谁会凌波微步?\"\n",
+ "# The second parameter is the top-n to retrieve, and its default value is 4.\n",
"vearch_standalone_res = vearch_standalone.similarity_search(query, 3)\n",
"for idx, tmp in enumerate(vearch_standalone_res):\n",
" print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\n",
@@ -261,6 +271,11 @@
"for idx, tmp in enumerate(cluster_res):\n",
" print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\n",
"\n",
+ "# In practical applications, we usually limit the boundary value of similarity. The following method can set this value.\n",
+ "cluster_res_with_bound = vearch_cluster.similarity_search_with_score(\n",
+ " query=query_c, k=3, min_score=0.5\n",
+ ")\n",
+ "\n",
"# combine your local knowleadge and query\n",
"context_c = \"\".join([tmp.page_content for tmp in cluster_res])\n",
"new_query_c = f\"基于以下信息,尽可能准确的来回答用户的问题。背景信息:\\n {context_c} \\n 回答用户这个问题:{query_c}\\n\\n\"\n",