From c36e6d4371750037b156f76549519db0692b7b6f Mon Sep 17 00:00:00 2001 From: Edmond Wang Date: Mon, 10 Feb 2025 21:35:38 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20Add=20Comments=20and=20Supplementary=20?= =?UTF-8?q?Example=20Code=20to=20Vearch=20Vector=20Dat=E2=80=A6=20(#29706)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - **Description:** Added some comments to the example code in the Vearch vector database documentation and included commonly used sample code. - **Issue:** None - **Dependencies:** None --------- Co-authored-by: wangchuxiong --- docs/docs/integrations/vectorstores/vearch.ipynb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/docs/integrations/vectorstores/vearch.ipynb b/docs/docs/integrations/vectorstores/vearch.ipynb index da2efb893a7..d5e40fdc4c1 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",