mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-18 00:51:18 +00:00
docs: Add Comments and Supplementary Example Code to Vearch Vector Dat… (#29706)
- **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 <wangchuxiong@jd.com>
This commit is contained in:
parent
bc5fafa20e
commit
c36e6d4371
@ -156,6 +156,15 @@
|
|||||||
" db_name=\"vearch_cluster_langchian\",\n",
|
" db_name=\"vearch_cluster_langchian\",\n",
|
||||||
" table_name=\"tobenumone\",\n",
|
" table_name=\"tobenumone\",\n",
|
||||||
" flag=1,\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": [
|
"source": [
|
||||||
"query = \"你知道凌波微步吗,你知道都有谁会凌波微步?\"\n",
|
"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",
|
"vearch_standalone_res = vearch_standalone.similarity_search(query, 3)\n",
|
||||||
"for idx, tmp in enumerate(vearch_standalone_res):\n",
|
"for idx, tmp in enumerate(vearch_standalone_res):\n",
|
||||||
" print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\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",
|
"for idx, tmp in enumerate(cluster_res):\n",
|
||||||
" print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\n",
|
" print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\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",
|
"# combine your local knowleadge and query\n",
|
||||||
"context_c = \"\".join([tmp.page_content for tmp in cluster_res])\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",
|
"new_query_c = f\"基于以下信息,尽可能准确的来回答用户的问题。背景信息:\\n {context_c} \\n 回答用户这个问题:{query_c}\\n\\n\"\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user