{"id":91107,"date":"2026-08-06T22:24:40","date_gmt":"2026-08-06T14:24:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/91107.html"},"modified":"2026-08-06T22:24:40","modified_gmt":"2026-08-06T14:24:40","slug":"rag-%e5%90%91%e9%87%8f%e6%a3%80%e7%b4%a2%ef%bc%9a%e4%bb%8e%e6%9f%a5%e5%ad%97%e5%88%b0%e6%9f%a5%e6%84%8f","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/91107.html","title":{"rendered":"RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c"},"content":{"rendered":"<p>LLM \u5f88\u806a\u660e&#xff0c;\u4f46\u5b83\u6709\u4e00\u4e2a\u786c\u4f24&#xff1a;\u77e5\u8bc6\u622a\u6b62\u5230\u8bad\u7ec3\u90a3\u5929\u3002\u4f60\u4eca\u5929\u95ee\u5b83&#034;\u516c\u53f8\u4e0a\u5468\u66f4\u65b0\u7684\u62a5\u9500\u6d41\u7a0b&#034;&#xff0c;\u5b83\u53ea\u80fd\u778e\u7f16\u3002RAG&#xff08;Retrieval-Augmented Generation&#xff0c;\u68c0\u7d22\u589e\u5f3a\u751f\u6210&#xff09;\u5c31\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898&#xff1a;\u5148\u68c0\u7d22\u5916\u90e8\u77e5\u8bc6&#xff0c;\u518d\u8ba9 LLM \u57fa\u4e8e\u68c0\u7d22\u7ed3\u679c\u751f\u6210\u7b54\u6848\u3002\u800c RAG \u7684\u68c0\u7d22\u73af\u8282&#xff0c;\u6838\u5fc3\u9760\u7684\u5c31\u662f\u5411\u91cf\u68c0\u7d22\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u4ece\u96f6\u8bb2\u6e05\u695a&#xff1a;\u4ec0\u4e48\u662f\u5411\u91cf\u68c0\u7d22\u3001Embedding \u5e72\u4e86\u4ec0\u4e48\u3001\u76f8\u4f3c\u5ea6\u600e\u4e48\u7b97\u3001\u5927\u89c4\u6a21\u68c0\u7d22\u600e\u4e48\u52a0\u901f&#xff0c;\u4ee5\u53ca\u5b83\u5728 Agent \u91cc\u5230\u5e95\u957f\u4ec0\u4e48\u6837\u3002<\/p>\n<h3>\u4e00\u3001\u4f20\u7edf\u641c\u7d22 vs \u5411\u91cf\u68c0\u7d22&#xff1a;\u4e3a\u4ec0\u4e48&#034;\u540c\u4e49\u8bcd&#034;\u662f\u4e2a\u5927\u9ebb\u70e6<\/h3>\n<p>\u4f20\u7edf\u641c\u7d22\u5f15\u64ce&#xff08;\u6bd4\u5982\u6570\u636e\u5e93\u91cc LIKE &#039;%\u5173\u952e\u8bcd%&#039; \u6216\u5012\u6392\u7d22\u5f15\u7684 BM25&#xff09;\u7684\u6838\u5fc3\u903b\u8f91\u662f\u5b57\u9762\u5339\u914d\u3002\u4f60\u7528&#034;\u8c03\u85aa&#034;\u53bb\u641c&#xff0c;\u6587\u6863\u91cc\u5199\u7684\u662f&#034;\u85aa\u916c\u8c03\u6574\u6d41\u7a0b&#034;\u2014\u2014\u4e00\u4e2a\u8bcd\u5bf9\u4e0d\u4e0a&#xff0c;\u76f4\u63a5\u641c\u4e0d\u5230\u3002<\/p>\n<p>\u8fd9\u53eb\u8bcd\u6c47\u9e3f\u6c9f&#xff08;lexical gap&#xff09;&#xff1a;\u4f60\u8bf4\u7684\u8bdd\u548c\u6587\u6863\u91cc\u5199\u7684\u8bdd\u7528\u7684\u662f\u4e0d\u540c\u8bcd&#xff0c;\u4f46\u610f\u601d\u4e00\u6837\u3002\u4f20\u7edf\u641c\u7d22\u5bf9\u6b64\u6beb\u65e0\u529e\u6cd5\u2014\u2014\u5b83\u6ca1\u6709&#034;\u8bed\u4e49\u7406\u89e3&#034;\u80fd\u529b&#xff0c;\u53ea\u6709&#034;\u5b57\u7b26\u4e32\u5339\u914d&#034;\u80fd\u529b\u3002<\/p>\n<p>\u5411\u91cf\u68c0\u7d22\u6362\u4e86\u4e00\u4e2a\u601d\u8def&#xff1a;\u4e0d\u627e&#034;\u5b57&#034;&#xff0c;\u627e&#034;\u610f\u601d&#034;\u3002\u5b83\u628a\u67e5\u8be2\u548c\u6587\u6863\u90fd\u8f6c\u6210\u4e00\u4e32\u6570\u5b57&#xff08;\u5411\u91cf&#xff09;&#xff0c;\u7136\u540e\u5728\u6570\u5b66\u7a7a\u95f4\u91cc\u7b97\u8ddd\u79bb\u3002\u8bed\u4e49\u76f8\u8fd1 \u2192 \u8ddd\u79bb\u8fd1 \u2192 \u547d\u4e2d\u3002\u4f60\u8bf4&#034;\u600e\u4e48\u8c03\u85aa&#034;&#xff0c;\u6587\u6863\u91cc\u6709&#034;\u85aa\u916c\u8c03\u6574\u6d41\u7a0b&#034;&#xff0c;\u5b83\u4eec\u5728\u5411\u91cf\u7a7a\u95f4\u91cc\u7d27\u6328\u7740\u2014\u2014\u54ea\u6015\u5b57\u9762\u4e0a\u5b8c\u5168\u4e0d\u540c\u3002<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u7ef4\u5ea6\u4f20\u7edf\u5173\u952e\u8bcd\u641c\u7d22\u5411\u91cf\u68c0\u7d22<\/tr>\n<tbody>\n<tr>\n<td>\u5339\u914d\u4f9d\u636e<\/td>\n<td>\u5b57\u9762\u547d\u4e2d&#xff08;TF-IDF\/BM25&#xff09;<\/td>\n<td>\u8bed\u4e49\u8ddd\u79bb&#xff08;\u4f59\u5f26\u76f8\u4f3c\u5ea6\u7b49&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u201c\u8c03\u85aa&#034;\u641c&#034;\u85aa\u916c\u8c03\u6574\u201d<\/td>\n<td>\u641c\u4e0d\u5230<\/td>\n<td>\u80fd\u641c\u5230&#xff0c;\u5411\u91cf\u8ddd\u79bb\u8fd1<\/td>\n<\/tr>\n<tr>\n<td>\u641c\u4eba\u540d\u3001\u578b\u53f7\u3001\u7f16\u53f7<\/td>\n<td>\u7cbe\u51c6<\/td>\n<td>\u53ef\u80fd\u6f02\u79fb<\/td>\n<\/tr>\n<tr>\n<td>\u641c&#034;\u5927\u6982\u610f\u601d&#034;<\/td>\n<td>\u65e0\u80fd\u4e3a\u529b<\/td>\n<td>\u5f3a\u9879<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u53e5\u8bdd&#xff1a;\u4f20\u7edf\u641c\u7d22\u50cf\u5728\u627e\u5b57&#xff0c;\u5411\u91cf\u68c0\u7d22\u50cf\u5728\u627e\u610f\u3002\u6210\u719f\u7684\u7cfb\u7edf\u90fd\u4f1a\u505a\u6df7\u5408\u68c0\u7d22&#xff08;Hybrid Search&#xff09;\u2014\u2014\u4e24\u8def\u7ed3\u679c\u878d\u5408&#xff0c;\u4e92\u8865\u77ed\u677f\u3002<\/p>\n<h3>\u4e8c\u3001Embedding&#xff1a;\u628a\u6587\u5b57\u53d8\u6210&#034;\u8bed\u4e49\u5750\u6807&#034;<\/h3>\n<h4>\u4e3a\u4ec0\u4e48\u9700\u8981 Embedding<\/h4>\n<p>\u8ba1\u7b97\u673a\u53ea\u8ba4\u8bc6\u6570\u5b57\u3002\u60f3\u8ba9\u8ba1\u7b97\u673a\u5224\u65ad&#034;\u732b\u5728\u6c99\u53d1\u4e0a\u7761\u89c9&#034;\u548c&#034;\u732b\u54aa\u5728\u6c99\u53d1\u4e0a\u6253\u76f9&#034;\u610f\u601d\u76f8\u8fd1&#xff0c;\u5f97\u5148\u628a\u8fd9\u4e24\u53e5\u8bdd\u90fd\u53d8\u6210\u6570\u5b57\u3002Embedding \u5c31\u662f\u8fd9\u4e2a\u8f6c\u6362\u8fc7\u7a0b\u2014\u2014\u628a\u6587\u672c\u6620\u5c04\u5230\u4e00\u4e2a\u9ad8\u7ef4\u5411\u91cf\u7a7a\u95f4\u91cc\u7684\u4e00\u4e2a\u70b9\u3002<\/p>\n<p>\u8f93\u5165\u4e00\u6bb5\u6587\u5b57&#xff0c;Embedding \u6a21\u578b\u8f93\u51fa\u4e00\u4e2a\u56fa\u5b9a\u957f\u5ea6\u7684\u6d6e\u70b9\u6570\u6570\u7ec4&#xff0c;\u6bd4\u5982 OpenAI \u7684 text-embedding-3-small \u5410\u51fa 1536 \u4e2a\u6d6e\u70b9\u6570&#xff1a;<\/p>\n<p>[0.012, -0.453, 0.891, -0.023, &#8230;, 0.147]   # \u5171 1536 \u7ef4<\/p>\n<p>\u4f60\u6ca1\u6cd5\u60f3\u8c61 1536 \u7ef4\u7a7a\u95f4\u957f\u4ec0\u4e48\u6837&#xff08;\u4eba\u7c7b\u5927\u8111\u8d85\u8fc7\u4e09\u7ef4\u5c31\u6293\u778e\u4e86&#xff09;&#xff0c;\u4f46\u6570\u5b66\u4e0a\u5b8c\u5168\u5408\u7406\u3002Embedding \u6a21\u578b\u5728\u8bad\u7ec3\u65f6\u5c31\u662f\u9760\u6d77\u91cf\u8bed\u6599\u5b66\u5230\u4e86\u4e00\u4e2a\u89c4\u5f8b&#xff1a;\u628a\u8bed\u4e49\u76f8\u8fd1\u7684\u6587\u5b57\u653e\u5728\u9ad8\u7ef4\u7a7a\u95f4\u4e2d\u76f8\u90bb\u7684\u4f4d\u7f6e\u3002<\/p>\n<h4>\u7ecf\u5178\u7c7b\u6bd4&#xff1a;\u5411\u91cf\u7b97\u672f<\/h4>\n<p>Embedding \u7684\u5999\u5904\u8fd8\u4e0d\u6b62\u4e8e\u6b64\u3002\u7ecf\u5178\u5b9e\u9a8c&#xff1a;&#034;\u56fd\u738b&#034; &#8211; &#034;\u7537\u4eba&#034; &#043; &#034;\u5973\u4eba&#034; \u2248 &#034;\u5973\u738b&#034;\u3002\u5411\u91cf\u53ef\u4ee5\u505a\u52a0\u51cf\u6cd5&#xff0c;\u800c\u4e14\u7ed3\u679c\u8fd8\u7b26\u5408\u4eba\u7c7b\u76f4\u89c9\u2014\u2014\u8fd9\u8bf4\u660e\u5411\u91cf\u786e\u5b9e\u7f16\u7801\u4e86\u8bed\u4e49\u4fe1\u606f&#xff0c;\u4e0d\u53ea\u662f\u968f\u673a\u6570\u5b57\u3002<\/p>\n<h4>\u4e3b\u6d41 Embedding \u6a21\u578b\u4e00\u89c8<\/h4>\n<table>\n<tr>\u6a21\u578b\u7ef4\u5ea6\u7279\u70b9<\/tr>\n<tbody>\n<tr>\n<td>OpenAI text-embedding-3-small<\/td>\n<td>1536<\/td>\n<td>\u901a\u7528\u6027\u5f3a&#xff0c;\u6027\u4ef7\u6bd4\u9ad8&#xff0c;\u4e2d\u6587\u652f\u6301\u4e0d\u9519<\/td>\n<\/tr>\n<tr>\n<td>OpenAI text-embedding-3-large<\/td>\n<td>3072<\/td>\n<td>\u7cbe\u5ea6\u66f4\u9ad8&#xff0c;\u7ef4\u5ea6\u66f4\u5927&#xff0c;\u9002\u5408\u9ad8\u8981\u6c42\u573a\u666f<\/td>\n<\/tr>\n<tr>\n<td>BGE (BAAI)<\/td>\n<td>768\/1024<\/td>\n<td>\u5f00\u6e90&#xff0c;\u4e2d\u6587\u4f18\u5316&#xff0c;\u81ea\u90e8\u7f72\u514d API \u8d39\u7528<\/td>\n<\/tr>\n<tr>\n<td>Jina Embeddings v3<\/td>\n<td>1024<\/td>\n<td>\u591a\u8bed\u8a00&#xff0c;\u652f\u6301 8192 token \u957f\u6587\u672c\u8f93\u5165<\/td>\n<\/tr>\n<tr>\n<td>Cohere Embed v3<\/td>\n<td>1024<\/td>\n<td>\u652f\u6301\u591a\u79cd\u8f93\u5165\u7c7b\u578b&#xff08;\u641c\u7d22\u6587\u6863\/\u641c\u7d22\u67e5\u8be2\u7b49&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9009\u6a21\u578b\u7684\u6838\u5fc3\u539f\u5219&#xff1a;\u5165\u5e93\u548c\u68c0\u7d22\u5fc5\u987b\u7528\u540c\u4e00\u4e2a Embedding \u6a21\u578b\u3002\u4e0d\u540c\u6a21\u578b\u4ea7\u51fa\u7684\u5411\u91cf\u7a7a\u95f4\u4e0d\u4e00\u81f4&#xff0c;\u6362\u6a21\u578b &#061; \u63a8\u5012\u91cd\u6765\u3002<\/p>\n<h3>\u4e09\u3001\u76f8\u4f3c\u5ea6&#xff1a;\u600e\u4e48\u5224\u65ad\u4e24\u4e2a\u5411\u91cf&#034;\u9760\u5f97\u8fd1&#034;<\/h3>\n<p>\u5411\u91cf\u68c0\u7d22\u6700\u540e\u4e00\u6b65&#xff0c;\u5c31\u662f\u62ff\u7528\u6237 query \u7684\u5411\u91cf&#xff0c;\u53bb\u5411\u91cf\u5e93\u91cc\u627e\u8ddd\u79bb\u6700\u8fd1\u7684 K \u4e2a\u6587\u6863\u5411\u91cf\u3002\u8fd9\u91cc&#034;\u8ddd\u79bb&#034;\u6709\u4e09\u79cd\u5e38\u7528\u5ea6\u91cf&#xff1a;<\/p>\n<h4>\u4f59\u5f26\u76f8\u4f3c\u5ea6&#xff08;Cosine Similarity&#xff09;<\/h4>\n<p>\u6700\u901a\u7528\u3002\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u5939\u89d2\u7684\u4f59\u5f26\u503c&#xff0c;\u8303\u56f4 [-1, 1]\u3002\u53ea\u770b\u65b9\u5411\u4e0d\u770b\u957f\u5ea6&#xff0c;\u6240\u4ee5\u957f\u7684\u6587\u6863\u548c\u77ed\u7684 query \u4e5f\u80fd\u516c\u5e73\u6bd4\u8f83\u3002<\/p>\n<p>\u4f59\u5f26\u76f8\u4f3c\u5ea6 &#061; (A \u00b7 B) \/ (||A|| \u00d7 ||B||)<\/p>\n<h4>\u6b27\u6c0f\u8ddd\u79bb&#xff08;Euclidean Distance&#xff09;<\/h4>\n<p>\u4e24\u70b9\u4e4b\u95f4\u76f4\u7ebf\u8ddd\u79bb\u3002\u5f53\u5411\u91cf\u5df2\u7ecf L2 \u5f52\u4e00\u5316\u540e&#xff0c;\u6b27\u6c0f\u8ddd\u79bb\u548c\u4f59\u5f26\u76f8\u4f3c\u5ea6\u7b49\u4ef7\u3002<\/p>\n<h4>\u70b9\u79ef&#xff08;Dot Product&#xff09;<\/h4>\n<p>\u4e24\u4e2a\u5411\u91cf\u9010\u5143\u7d20\u76f8\u4e58\u518d\u6c42\u548c\u3002\u5411\u91cf\u5f52\u4e00\u5316\u540e &#061; \u4f59\u5f26\u76f8\u4f3c\u5ea6\u3002\u9002\u5408\u9700\u8981\u52a0\u6743\u6392\u5e8f\u7684\u573a\u666f\u3002<\/p>\n<p>\u5b9e\u9645\u5de5\u7a0b\u91cc 90% \u7684\u573a\u666f\u7528\u4f59\u5f26\u76f8\u4f3c\u5ea6\u5c31\u5bf9\u4e86\u3002\u63a8\u7406\u5f00\u9500\u5c0f&#xff0c;\u8bed\u4e49\u8868\u8fbe\u529b\u8db3\u591f\u3002<\/p>\n<h3>\u56db\u3001ANN \u52a0\u901f&#xff1a;\u767e\u4e07\u5411\u91cf\u600e\u4e48\u6beb\u79d2\u7ea7\u641c\u5b8c<\/h3>\n<h4>\u4e3a\u4ec0\u4e48\u8981\u8fd1\u4f3c<\/h4>\n<p>\u5982\u679c\u66b4\u529b\u641c\u7d22&#xff08;kNN&#xff09;\u2014\u2014\u62ff query \u5411\u91cf\u548c\u5e93\u91cc\u6bcf\u4e2a\u5411\u91cf\u90fd\u7b97\u4e00\u904d\u8ddd\u79bb\u518d\u6392\u5e8f\u2014\u2014\u590d\u6742\u5ea6\u662f O(N)\u3002N &#061; \u5341\u4e07\u7684\u65f6\u5019\u8fd8\u884c&#xff0c;N &#061; \u767e\u4e07\u3001\u5343\u4e07\u5c31\u5d29\u4e86&#xff1a;\u6bcf\u6b21\u67e5\u8be2\u8981\u8dd1\u51e0\u767e\u4e07\u6b21\u6d6e\u70b9\u8fd0\u7b97&#xff0c;\u5ef6\u8fdf\u79d2\u7ea7\u8d77\u6b65\u3002<\/p>\n<p>\u6240\u4ee5\u5b9e\u9645\u7528\u7684\u4e0d\u662f\u7cbe\u786e\u641c\u7d22&#xff0c;\u800c\u662f ANN&#xff08;Approximate Nearest Neighbor&#xff0c;\u8fd1\u4f3c\u6700\u8fd1\u90bb&#xff09;\u2014\u2014\u727a\u7272\u4e00\u4e01\u70b9\u7cbe\u5ea6&#xff08;\u6bd4\u5982\u4ece&#034;100% \u53ec\u56de&#034;\u964d\u5230 \u201c99.5% \u53ec\u56de\u201d&#xff09;&#xff0c;\u6362\u56de\u51e0\u5341\u4e0a\u767e\u500d\u7684\u52a0\u901f\u3002<\/p>\n<h4>\u4e24\u5927\u4e3b\u6d41\u7b97\u6cd5<\/h4>\n<p>IVF&#xff08;Inverted File&#xff0c;\u5012\u6392\u6587\u4ef6&#xff09;&#xff1a;\u5148\u628a\u6240\u6709\u5411\u91cf\u7528 K-Means \u805a\u6210 N \u4e2a\u6876&#xff08;\u7c07&#xff09;\u3002\u67e5\u8be2\u65f6\u53ea\u641c\u79bb query \u6700\u8fd1\u7684\u51e0\u4e2a\u6876&#xff0c;\u6876\u5185\u505a\u66b4\u529b\u641c\u7d22\u3002\u6838\u5fc3\u601d\u60f3\u662f&#034;\u5148\u7c97\u7b5b\u518d\u7ec6\u67e5&#034;\u3002<\/p>\n<p>\u5173\u952e\u53c2\u6570&#xff1a;<\/p>\n<ul>\n<li>nlist&#xff1a;\u5206\u591a\u5c11\u4e2a\u6876\u3002\u8d8a\u5927\u8d8a\u7ec6&#xff0c;\u4f46\u5efa\u7d22\u5f15\u8d8a\u6162\u3002<\/li>\n<li>nprobe&#xff1a;\u67e5\u51e0\u4e2a\u6876\u3002\u8d8a\u5927\u53ec\u56de\u8d8a\u9ad8&#xff0c;\u4f46\u8d8a\u6162\u3002<\/li>\n<\/ul>\n<p>HNSW&#xff08;Hierarchical Navigable Small World&#xff0c;\u5206\u5c42\u53ef\u5bfc\u822a\u5c0f\u4e16\u754c\u56fe&#xff09;&#xff1a;\u76ee\u524d\u7cbe\u5ea6\u548c\u901f\u5ea6\u7684\u6807\u6746\u3002\u6784\u5efa\u4e00\u4e2a\u5206\u5c42\u56fe\u7ed3\u6784\u2014\u2014\u4e0a\u5c42\u7a00\u758f\u7528\u4e8e&#034;\u5bfc\u822a\u5230\u5927\u81f4\u533a\u57df&#034;&#xff0c;\u4e0b\u5c42\u7a20\u5bc6\u7528\u4e8e&#034;\u7cbe\u786e\u5b9a\u4f4d&#034;\u3002\u641c\u7d22\u65f6\u4ece\u9876\u5c42\u9010\u5c42\u4e0b\u964d&#xff0c;\u7c7b\u4f3c\u5728\u591a\u5c42\u505c\u8f66\u573a\u91cc\u4ece\u9876\u5c42\u4fef\u77b0\u9010\u6b65\u627e\u5230\u8f66\u4f4d\u3002<\/p>\n<p>\u5173\u952e\u53c2\u6570&#xff1a;<\/p>\n<ul>\n<li>M&#xff1a;\u6bcf\u4e2a\u8282\u70b9\u7684\u6700\u5927\u8fde\u63a5\u6570&#xff08;16~64&#xff09;\u3002\u8d8a\u5927\u8d8a\u7cbe\u786e&#xff0c;\u4f46\u5185\u5b58\u4e5f\u8d8a\u5927\u3002<\/li>\n<li>efSearch&#xff1a;\u641c\u7d22\u65f6\u8003\u5bdf\u7684\u5019\u9009\u6570&#xff08;50~200&#xff09;\u3002\u8d8a\u5927\u53ec\u56de\u8d8a\u9ad8&#xff0c;\u4f46\u8d8a\u6162\u3002<\/li>\n<\/ul>\n<table>\n<tr>\u5bf9\u6bd4\u7ef4\u5ea6IVFHNSW<\/tr>\n<tbody>\n<tr>\n<td>\u53ec\u56de\u7cbe\u5ea6<\/td>\n<td>\u9ad8&#xff0c;\u4f46\u4f9d\u8d56 nprobe \u8c03\u53c2<\/td>\n<td>\u6781\u9ad8&#xff0c;\u901a\u5e38\u4f18\u4e8e IVF<\/td>\n<\/tr>\n<tr>\n<td>\u68c0\u7d22\u901f\u5ea6<\/td>\n<td>\u5feb<\/td>\n<td>\u6781\u5feb&#xff0c;\u63a5\u8fd1 O(log N)<\/td>\n<\/tr>\n<tr>\n<td>\u6784\u5efa\u901f\u5ea6<\/td>\n<td>\u5feb&#xff08;\u53ea\u805a\u7c7b&#xff09;<\/td>\n<td>\u6162&#xff08;\u9010\u70b9\u5efa\u56fe&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5360\u7528<\/td>\n<td>\u9ad8&#xff08;\u5b58\u5168\u90e8\u539f\u59cb\u5411\u91cf&#xff09;<\/td>\n<td>\u9ad8&#xff08;\u5b58\u56fe\u7ed3\u6784 &#043; \u5411\u91cf&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u5408\u573a\u666f<\/td>\n<td>\u5e73\u8861\u901f\u5ea6\u4e0e\u7cbe\u5ea6\u7684\u901a\u7528\u573a\u666f<\/td>\n<td>\u9ad8\u8981\u6c42\u573a\u666f&#xff08;RAG\u3001\u63a8\u8350\u7cfb\u7edf&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u4ee3\u8868\u5411\u91cf\u6570\u636e\u5e93<\/h4>\n<table>\n<tr>\u6570\u636e\u5e93\u6838\u5fc3\u7b97\u6cd5\u7279\u70b9<\/tr>\n<tbody>\n<tr>\n<td>FAISS (Meta)<\/td>\n<td>IVF, HNSW, PQ<\/td>\n<td>\u5e93\u800c\u975e\u6570\u636e\u5e93&#xff0c;\u6781\u9ad8\u6027\u80fd&#xff0c;GPU \u52a0\u901f<\/td>\n<\/tr>\n<tr>\n<td>Milvus<\/td>\n<td>IVF, HNSW<\/td>\n<td>\u5206\u5e03\u5f0f\u67b6\u6784&#xff0c;\u652f\u6301\u5341\u4ebf\u7ea7<\/td>\n<\/tr>\n<tr>\n<td>Qdrant<\/td>\n<td>HNSW<\/td>\n<td>\u8fc7\u6ee4\u529f\u80fd\u4e30\u5bcc&#xff0c;Rust \u5b9e\u73b0\u6027\u80fd\u597d<\/td>\n<\/tr>\n<tr>\n<td>Chroma<\/td>\n<td>HNSW<\/td>\n<td>\u8f7b\u91cf\u6613\u7528&#xff0c;\u9002\u5408\u539f\u578b\u548c\u4e2d\u5c0f\u89c4\u6a21<\/td>\n<\/tr>\n<tr>\n<td>pgvector<\/td>\n<td>IVF, HNSW<\/td>\n<td>PostgreSQL \u6269\u5c55&#xff0c;\u548c\u4e1a\u52a1\u5e93\u540c\u5b58<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e94\u3001\u5206\u5757\u7b56\u7565&#xff1a;\u5207\u591a\u5927\u624d\u5408\u9002<\/h3>\n<p>Embedding \u6a21\u578b\u518d\u597d&#xff0c;\u5206\u5757\u6ca1\u641e\u5bf9&#xff0c;\u68c0\u7d22\u7167\u6837\u70c2\u3002\u8fd9\u662f\u5de5\u7a0b\u4e2d\u6700\u5bb9\u6613\u88ab\u4f4e\u4f30\u7684\u73af\u8282\u3002<\/p>\n<h4>\u6838\u5fc3\u77db\u76fe<\/h4>\n<ul>\n<li>\u5207\u592a\u5927&#xff08;\u6bd4\u5982 2048 token&#xff09;&#xff1a;\u4e00\u6bb5\u91cc\u585e\u4e86\u4e09\u4e2a\u4e0d\u540c\u8bdd\u9898&#xff0c;Embedding \u5411\u91cf\u53d8\u6210\u4e00\u4e2a&#034;\u6742\u7cc5\u8bed\u4e49\u70b9&#034;&#xff0c;\u641c\u4ec0\u4e48\u90fd\u80fd\u547d\u4e2d\u4e00\u70b9&#xff0c;\u4f46\u7cbe\u51c6\u5ea6\u6781\u5dee\u3002<\/li>\n<li>\u5207\u592a\u5c0f&#xff08;\u6bd4\u5982 128 token&#xff09;&#xff1a;\u4e00\u53e5\u5b8c\u6574\u7684\u8bdd\u88ab\u8170\u65a9&#xff0c;\u4e0a\u4e0b\u6587\u4e22\u5931&#xff0c;LLM \u62ff\u5230\u788e\u7247\u7b54\u4e0d\u51fa\u5b8c\u6574\u7b54\u6848\u3002<\/li>\n<\/ul>\n<h4>\u5de5\u7a0b\u4e0a\u7684\u7ecf\u9a8c\u503c<\/h4>\n<ul>\n<li>\u901a\u7528\u573a\u666f&#xff1a;512 token \u4e3a\u4e00\u5757&#xff0c;\u76f8\u90bb\u5757\u91cd\u53e0 10%~15%&#xff08;overlap&#xff09;\u3002\u8fd9\u6837\u5173\u952e\u53e5\u843d\u5728\u8fb9\u754c\u5904\u4e5f\u4e0d\u88ab\u5207\u5f00\u3002<\/li>\n<li>\u6280\u672f\u6587\u6863\/\u4ee3\u7801&#xff1a;\u6309\u81ea\u7136\u8fb9\u754c\u5207\u2014\u2014\u51fd\u6570\u7ea7\u3001\u6bb5\u843d\u7ea7\u3001\u7ae0\u8282\u7ea7\u3002\u4e0d\u8981\u673a\u68b0\u6309\u5b57\u7b26\u6570\u5207\u3002<\/li>\n<li>QA \u573a\u666f&#xff1a;\u6bcf\u4e2a Q&amp;A \u5bf9\u72ec\u7acb\u6210\u5757\u3002<\/li>\n<\/ul>\n<p><span class=\"token comment\"># chunking_config.py \u2014 \u5178\u578b\u5206\u5757\u914d\u7f6e<\/span><br \/>\n<span class=\"token keyword\">from<\/span> langchain<span class=\"token punctuation\">.<\/span>text_splitter <span class=\"token keyword\">import<\/span> RecursiveCharacterTextSplitter<\/p>\n<p>splitter <span class=\"token operator\">&#061;<\/span> RecursiveCharacterTextSplitter<span class=\"token punctuation\">(<\/span><br \/>\n    chunk_size<span class=\"token operator\">&#061;<\/span><span class=\"token number\">500<\/span><span class=\"token punctuation\">,<\/span>        <span class=\"token comment\"># \u6bcf\u5757 500 \u5b57\u7b26<\/span><br \/>\n    chunk_overlap<span class=\"token operator\">&#061;<\/span><span class=\"token number\">50<\/span><span class=\"token punctuation\">,<\/span>      <span class=\"token comment\"># \u76f8\u90bb\u5757\u91cd\u53e0 50 \u5b57\u7b26&#xff08;10%&#xff09;<\/span><br \/>\n    separators<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;\\\\n\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u3002&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;.&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034; &#034;<\/span><span class=\"token punctuation\">]<\/span>  <span class=\"token comment\"># \u4f18\u5148\u6309\u81ea\u7136\u8fb9\u754c\u5207<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><br \/>\nchunks <span class=\"token operator\">&#061;<\/span> splitter<span class=\"token punctuation\">.<\/span>create_documents<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span>document<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u5206\u5757\u540c\u65f6\u8981\u5e26\u4e0a\u5143\u6570\u636e&#xff1a;\u6765\u6e90\u6587\u6863\u540d\u3001\u7ae0\u8282\u6807\u9898\u3001\u65f6\u95f4\u6233\u3001\u7248\u672c\u53f7\u3002\u68c0\u7d22\u65f6\u53ef\u4ee5\u7528\u5143\u6570\u636e\u505a\u8fc7\u6ee4&#xff08;\u201c\u53ea\u641c 2024 \u5e74\u7684\u6587\u6863\u201d&#xff09;&#xff0c;\u7cbe\u5ea6\u5927\u5e45\u63d0\u5347\u3002<\/p>\n<h3>\u516d\u3001Rerank&#xff1a;\u5c11\u82b1\u94b1\u3001\u591a\u529e\u4e8b<\/h3>\n<p>\u5411\u91cf\u68c0\u7d22\u62c9\u56de top-20 \u4e2a\u5019\u9009\u5757&#xff0c;\u76f4\u63a5\u5168\u585e\u7ed9 LLM&#xff1f;token \u6d6a\u8d39\u4e0d\u8bf4&#xff0c;\u540e\u9762\u5341\u51e0\u6761\u53ef\u80fd\u662f\u566a\u97f3\u3002<\/p>\n<p>\u4e24\u9636\u6bb5\u68c0\u7d22\u662f\u6027\u4ef7\u6bd4\u6700\u4f18\u89e3&#xff1a;<\/p>\n<li>\u7c97\u7b5b&#xff08;\u5411\u91cf\u68c0\u7d22&#xff09;&#xff1a;\u4ece\u5168\u5e93\u62c9 top-20 ~ top-50<\/li>\n<li>\u7cbe\u6392&#xff08;Rerank \u6a21\u578b&#xff09;&#xff1a;\u7528\u4e00\u4e2a\u4e13\u95e8\u7684\u91cd\u6392\u5e8f\u6a21\u578b\u5bf9\u5019\u9009\u96c6\u6253\u5206&#xff0c;\u53d6 top-3 ~ top-5 \u5582 LLM<\/li>\n<p>Rerank \u6a21\u578b\u6bd4 Embedding \u6a21\u578b\u66f4&#034;\u8d35&#034;\u4f46\u66f4\u51c6\u2014\u2014\u5b83\u4f1a\u628a query \u548c\u5019\u9009\u6587\u6863\u9010\u5bf9\u7cbe\u7ec6\u6bd4\u5bf9&#xff0c;\u800c\u4e0d\u662f\u53ea\u7b97\u4e00\u6b21\u5411\u91cf\u8ddd\u79bb\u3002Cohere Rerank\u3001BGE-Reranker \u662f\u5e38\u7528\u9009\u62e9\u3002<\/p>\n<p><span class=\"token comment\"># retrieval.py \u2014 \u4e24\u9636\u6bb5\u68c0\u7d22\u4f2a\u4ee3\u7801<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">retrieve_and_rerank<\/span><span class=\"token punctuation\">(<\/span>query<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">,<\/span> top_k<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">int<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">20<\/span><span class=\"token punctuation\">,<\/span> final_k<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">int<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token builtin\">list<\/span><span class=\"token punctuation\">[<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u9636\u6bb51&#xff1a;\u5411\u91cf\u7c97\u7b5b<\/span><br \/>\n    query_vec <span class=\"token operator\">&#061;<\/span> embed<span class=\"token punctuation\">(<\/span>query<span class=\"token punctuation\">)<\/span><br \/>\n    candidates <span class=\"token operator\">&#061;<\/span> vector_db<span class=\"token punctuation\">.<\/span>search<span class=\"token punctuation\">(<\/span>query_vec<span class=\"token punctuation\">,<\/span> top_k<span class=\"token operator\">&#061;<\/span>top_k<span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token comment\"># \u9636\u6bb52&#xff1a;Rerank \u7cbe\u6392<\/span><br \/>\n    scores <span class=\"token operator\">&#061;<\/span> reranker<span class=\"token punctuation\">.<\/span>compute_scores<span class=\"token punctuation\">(<\/span>query<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">[<\/span>c<span class=\"token punctuation\">.<\/span>text <span class=\"token keyword\">for<\/span> c <span class=\"token keyword\">in<\/span> candidates<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    ranked <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">sorted<\/span><span class=\"token punctuation\">(<\/span><span class=\"token builtin\">zip<\/span><span class=\"token punctuation\">(<\/span>candidates<span class=\"token punctuation\">,<\/span> scores<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> key<span class=\"token operator\">&#061;<\/span><span class=\"token keyword\">lambda<\/span> x<span class=\"token punctuation\">:<\/span> x<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> reverse<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">[<\/span>c<span class=\"token punctuation\">.<\/span>text <span class=\"token keyword\">for<\/span> c<span class=\"token punctuation\">,<\/span> _ <span class=\"token keyword\">in<\/span> ranked<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">:<\/span>final_k<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">]<\/span><\/p>\n<h3>\u4e03\u3001\u5728 Agent \u4e2d\u957f\u4ec0\u4e48\u6837<\/h3>\n<p>Agent \u7528 RAG \u4e0d\u9700\u8981\u628a\u6bcf\u4e2a\u7ec6\u8282\u90fd\u81ea\u5df1\u624b\u5199&#xff0c;\u6210\u719f\u7684\u6846\u67b6\u5df2\u7ecf\u5c01\u88c5\u597d\u4e86\u3002\u4ee5\u4f60\u6b63\u5728\u5b66\u7684 LangChain \u4e3a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token comment\"># agent_rag_pipeline.py \u2014 Agent \u4e2d RAG \u7684\u6700\u5c0f\u95ed\u73af<\/span><br \/>\n<span class=\"token keyword\">from<\/span> langchain<span class=\"token punctuation\">.<\/span>document_loaders <span class=\"token keyword\">import<\/span> TextLoader<br \/>\n<span class=\"token keyword\">from<\/span> langchain<span class=\"token punctuation\">.<\/span>text_splitter <span class=\"token keyword\">import<\/span> RecursiveCharacterTextSplitter<br \/>\n<span class=\"token keyword\">from<\/span> langchain<span class=\"token punctuation\">.<\/span>embeddings <span class=\"token keyword\">import<\/span> OpenAIEmbeddings<br \/>\n<span class=\"token keyword\">from<\/span> langchain<span class=\"token punctuation\">.<\/span>vectorstores <span class=\"token keyword\">import<\/span> Chroma<\/p>\n<p><span class=\"token comment\"># 1. \u52a0\u8f7d\u6587\u6863 &#043; \u5206\u5757<\/span><br \/>\nloader <span class=\"token operator\">&#061;<\/span> TextLoader<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;company_policy.txt&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\ndocs <span class=\"token operator\">&#061;<\/span> loader<span class=\"token punctuation\">.<\/span>load<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\nchunks <span class=\"token operator\">&#061;<\/span> RecursiveCharacterTextSplitter<span class=\"token punctuation\">(<\/span><br \/>\n    chunk_size<span class=\"token operator\">&#061;<\/span><span class=\"token number\">500<\/span><span class=\"token punctuation\">,<\/span> chunk_overlap<span class=\"token operator\">&#061;<\/span><span class=\"token number\">50<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>split_documents<span class=\"token punctuation\">(<\/span>docs<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># 2. \u5411\u91cf\u5316 &#043; \u5b58\u5165\u5411\u91cf\u5e93<\/span><br \/>\nembeddings <span class=\"token operator\">&#061;<\/span> OpenAIEmbeddings<span class=\"token punctuation\">(<\/span>model<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;text-embedding-3-small&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nvectorstore <span class=\"token operator\">&#061;<\/span> Chroma<span class=\"token punctuation\">.<\/span>from_documents<span class=\"token punctuation\">(<\/span>chunks<span class=\"token punctuation\">,<\/span> embeddings<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># 3. \u4f5c\u4e3a\u68c0\u7d22\u5668\u63a5\u5165 Agent<\/span><br \/>\nretriever <span class=\"token operator\">&#061;<\/span> vectorstore<span class=\"token punctuation\">.<\/span>as_retriever<span class=\"token punctuation\">(<\/span>search_kwargs<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;k&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">5<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># 4. Agent \u8c03\u7528\u65f6&#xff0c;retriever \u81ea\u52a8\u641c\u76f8\u5173\u6587\u6863\u6ce8\u5165\u4e0a\u4e0b\u6587<\/span><\/p>\n<p>\u5b8c\u6574\u94fe\u8def&#xff1a;\u7528\u6237\u95ee \u2192 Agent \u51b3\u7b56 \u2192 \u8c03 retriever \u641c\u5411\u91cf\u5e93 \u2192 \u62ff top-k \u6587\u6863 \u2192 \u62fc prompt \u2192 LLM \u751f\u6210 \u2192 \u8fd4\u56de\u7b54\u6848\u3002<\/p>\n<p>\u5173\u952e\u8bbe\u8ba1\u70b9&#xff1a;<\/p>\n<ul>\n<li>retriever \u5bf9 Agent \u6765\u8bf4\u662f\u4e00\u4e2a\u5de5\u5177&#xff08;Tool&#xff09;&#xff0c;\u548c\u5176\u4ed6\u5de5\u5177&#xff08;API \u8c03\u7528\u3001\u6570\u636e\u5e93\u67e5\u8be2\u3001\u4ee3\u7801\u6267\u884c&#xff09;\u5e76\u5217\u3002Agent \u81ea\u5df1\u51b3\u5b9a\u4ec0\u4e48\u65f6\u5019\u8be5\u7528\u68c0\u7d22\u3001\u4ec0\u4e48\u65f6\u5019\u4e0d\u8be5\u3002<\/li>\n<li>\u68c0\u7d22\u5230\u7684\u5185\u5bb9\u6ce8\u5165\u5230 LLM \u7684 system prompt \u6216\u4e0a\u4e0b\u6587\u91cc&#xff0c;\u800c\u4e0d\u662f\u66ff\u6362\u7528\u6237\u539f\u59cb\u95ee\u9898\u3002<\/li>\n<\/ul>\n<h3>\u516b\u3001\u5e38\u89c1\u5751<\/h3>\n<table>\n<tr>\u73b0\u8c61\u771f\u76f8<\/tr>\n<tbody>\n<tr>\n<td>\u5411\u91cf\u68c0\u7d22\u7ed3\u679c\u5b8c\u5168\u4e0d\u5bf9<\/td>\n<td>\u5165\u5e93\u548c\u68c0\u7d22\u7528\u4e86\u4e0d\u540c\u7684 Embedding \u6a21\u578b&#xff0c;\u5411\u91cf\u7a7a\u95f4\u4e0d\u7edf\u4e00<\/td>\n<\/tr>\n<tr>\n<td>\u6362\u4e86\u4e2a\u76f8\u4f3c\u95ee\u6cd5\u5c31\u641c\u4e0d\u5230\u4e86<\/td>\n<td>Embedding \u6a21\u578b\u5bf9\u9886\u57df\u672f\u8bed\u6ca1\u8bad\u7ec3\u8fc7&#xff0c;\u8003\u8651\u5fae\u8c03\u6216\u6362\u9886\u57df\u6a21\u578b<\/td>\n<\/tr>\n<tr>\n<td>\u660e\u660e\u6587\u6863\u6709\u7b54\u6848&#xff0c;\u68c0\u7d22\u5c31\u662f\u547d\u4e2d\u4e0d\u4e86<\/td>\n<td>\u5206\u5757\u592a\u5927&#xff0c;\u8bed\u4e49\u88ab\u7a00\u91ca&#xff1b;\u6216\u5206\u5757\u592a\u5c0f&#xff0c;\u5173\u952e\u4e0a\u4e0b\u6587\u88ab\u5207\u65ad<\/td>\n<\/tr>\n<tr>\n<td>\u5411\u91cf\u68c0\u7d22\u5feb\u4f46\u5185\u5b58\u7206\u70b8<\/td>\n<td>\u6ca1\u505a\u5411\u91cf\u538b\u7f29&#xff08;PQ&#xff09;&#xff0c;1536 \u7ef4 \u00d7 \u767e\u4e07\u6761 &#061; \u51e0\u4e2a GB \u8d77<\/td>\n<\/tr>\n<tr>\n<td>Rerank \u52a0\u4e86\u53cd\u800c\u53d8\u6162<\/td>\n<td>Rerank \u6a21\u578b\u548c Embedding \u6a21\u578b\u6709&#034;\u6392\u5e8f\u504f\u597d\u51b2\u7a81&#034;\u2014\u2014\u7c97\u7b5b\u9009\u51fa\u7684\u5019\u9009\u96c6\u672c\u8eab\u4e0d\u884c&#xff0c;\u7cbe\u6392\u6551\u4e0d\u56de\u6765<\/td>\n<\/tr>\n<tr>\n<td>\u6df7\u5408\u68c0\u7d22\u5206\u6570\u65e0\u6cd5\u5bf9\u9f50<\/td>\n<td>\u5411\u91cf\u4f59\u5f26\u503c&#xff08;-1~1&#xff09;\u548c BM25 \u5f97\u5206\u91cf\u7eb2\u4e0d\u540c&#xff0c;\u76f4\u63a5\u52a0\u6743\u65e0\u6548&#xff1b;\u7528 RRF&#xff08;\u5012\u6570\u6392\u540d\u878d\u5408&#xff09;\u4ee3\u66ff<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e5d\u3001\u603b\u7ed3<\/h3>\n<p>\u5411\u91cf\u68c0\u7d22\u7528\u4e00\u53e5\u8bdd\u6982\u62ec&#xff1a;\u628a\u6587\u672c\u6620\u5c04\u5230\u9ad8\u7ef4\u5411\u91cf\u7684\u8bed\u4e49\u7a7a\u95f4&#xff0c;\u9760\u8ddd\u79bb\u5ea6\u91cf&#034;\u610f\u601d\u6709\u591a\u8fd1&#034;&#xff0c;\u7528 ANN \u7b97\u6cd5\u5728\u5927\u89c4\u6a21\u6570\u636e\u4e2d\u6beb\u79d2\u7ea7\u627e\u51fa\u6700\u76f8\u5173\u7684\u6587\u6863\u3002\u5b83\u5728 RAG \u94fe\u8def\u91cc\u626e\u6f14&#034;\u5916\u90e8\u5927\u8111\u7684\u8bb0\u5fc6\u7d22\u5f15&#034;\u2014\u2014\u4e0d\u662f\u53d6\u4ee3 LLM&#xff0c;\u800c\u662f\u8ba9 LLM \u6709\u636e\u53ef\u4f9d\u3002<\/p>\n<p>\u5de5\u7a0b\u4e0a\u7684\u4f18\u5148\u7ea7&#xff1a;\u5206\u5757\u7b56\u7565 &gt; Embedding \u6a21\u578b\u9009\u62e9 &gt; \u5411\u91cf\u6570\u636e\u5e93\u9009\u578b\u3002\u5f88\u591a\u9879\u76ee\u5728\u5411\u91cf\u6570\u636e\u5e93\u4e0a\u7ea0\u7ed3\u534a\u5929&#xff0c;\u7ed3\u679c\u5206\u5757\u4e00\u584c\u7cca\u6d82\u2014\u2014\u65b9\u5411\u8dd1\u504f\u4e86\u3002<\/p>\n<p>\u6700\u540e\u8bb0\u4f4f\u4e00\u4e2a\u6838\u5fc3\u5224\u65ad&#xff1a;\u5411\u91cf\u68c0\u7d22\u64c5\u957f&#034;\u8bed\u4e49\u6a21\u7cca\u5339\u914d&#034;&#xff0c;\u4e0d\u64c5\u957f&#034;\u7cbe\u786e\u6761\u4ef6\u67e5\u627e&#034;\u3002\u4eba\u540d\u3001\u578b\u53f7\u3001\u7f16\u53f7\u3001\u65e5\u671f\u8303\u56f4\u3001\u6cd5\u6761\u7f16\u53f7\u2014\u2014\u8fd9\u4e9b\u8001\u8001\u5b9e\u5b9e\u7528\u8fc7\u6ee4\u6761\u4ef6\u6216\u5173\u952e\u8bcd\u641c\u7d22&#xff0c;\u522b\u786c\u5f80\u5411\u91cf\u4e0a\u5957\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LLM \u5f88\u806a\u660e&#xff0c;\u4f46\u5b83\u6709\u4e00\u4e2a\u786c\u4f24&#xff1a;\u77e5\u8bc6\u622a\u6b62\u5230\u8bad\u7ec3\u90a3\u5929\u3002\u4f60\u4eca\u5929\u95ee\u5b83\\&#8221;\u516c\u53f8\u4e0a\u5468\u66f4\u65b0\u7684\u62a5\u9500\u6d41\u7a0b\\&#8221;&#xff0c;\u5b83\u53ea\u80fd\u778e\u7f16\u3002RAG&#xff08;Retrieval-Augmented Generation&#xff0c;\u68c0\u7d22\u589e\u5f3a\u751f\u6210&#xff09;\u5c31\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898&#xff1a;\u5148\u68c0\u7d22\u5916\u90e8\u77e5\u8bc6&#xff0c;\u518d\u8ba9 LLM \u57fa\u4e8e\u68c0\u7d22\u7ed3\u679c\u751f\u6210\u7b54\u6848\u3002\u800c RAG \u7684\u68c0\u7d22\u73af\u8282&#xff0c;\u6838\u5fc3\u9760\u7684\u5c31\u662f\u5411\u91cf\u68c0\u7d22\u3002<br \/>\n\u8fd9\u7bc7\u6587\u7ae0\u4ece\u96f6\u8bb2\u6e05\u695a&#xff1a;\u4ec0\u4e48\u662f\u5411\u91cf<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10187,604,50,371,100],"topic":[],"class_list":["post-91107","post","type-post","status-publish","format-standard","hentry","category-server","tag-codingplan","tag-oracle","tag-50","tag-371","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/91107.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"LLM \u5f88\u806a\u660e&#xff0c;\u4f46\u5b83\u6709\u4e00\u4e2a\u786c\u4f24&#xff1a;\u77e5\u8bc6\u622a\u6b62\u5230\u8bad\u7ec3\u90a3\u5929\u3002\u4f60\u4eca\u5929\u95ee\u5b83&quot;\u516c\u53f8\u4e0a\u5468\u66f4\u65b0\u7684\u62a5\u9500\u6d41\u7a0b&quot;&#xff0c;\u5b83\u53ea\u80fd\u778e\u7f16\u3002RAG&#xff08;Retrieval-Augmented Generation&#xff0c;\u68c0\u7d22\u589e\u5f3a\u751f\u6210&#xff09;\u5c31\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898&#xff1a;\u5148\u68c0\u7d22\u5916\u90e8\u77e5\u8bc6&#xff0c;\u518d\u8ba9 LLM \u57fa\u4e8e\u68c0\u7d22\u7ed3\u679c\u751f\u6210\u7b54\u6848\u3002\u800c RAG \u7684\u68c0\u7d22\u73af\u8282&#xff0c;\u6838\u5fc3\u9760\u7684\u5c31\u662f\u5411\u91cf\u68c0\u7d22\u3002 \u8fd9\u7bc7\u6587\u7ae0\u4ece\u96f6\u8bb2\u6e05\u695a&#xff1a;\u4ec0\u4e48\u662f\u5411\u91cf\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/91107.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-06T14:24:40+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/91107.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/91107.html\",\"name\":\"RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-06T14:24:40+00:00\",\"dateModified\":\"2026-08-06T14:24:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/91107.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/91107.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/91107.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/91107.html","og_locale":"zh_CN","og_type":"article","og_title":"RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"LLM \u5f88\u806a\u660e&#xff0c;\u4f46\u5b83\u6709\u4e00\u4e2a\u786c\u4f24&#xff1a;\u77e5\u8bc6\u622a\u6b62\u5230\u8bad\u7ec3\u90a3\u5929\u3002\u4f60\u4eca\u5929\u95ee\u5b83\"\u516c\u53f8\u4e0a\u5468\u66f4\u65b0\u7684\u62a5\u9500\u6d41\u7a0b\"&#xff0c;\u5b83\u53ea\u80fd\u778e\u7f16\u3002RAG&#xff08;Retrieval-Augmented Generation&#xff0c;\u68c0\u7d22\u589e\u5f3a\u751f\u6210&#xff09;\u5c31\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898&#xff1a;\u5148\u68c0\u7d22\u5916\u90e8\u77e5\u8bc6&#xff0c;\u518d\u8ba9 LLM \u57fa\u4e8e\u68c0\u7d22\u7ed3\u679c\u751f\u6210\u7b54\u6848\u3002\u800c RAG \u7684\u68c0\u7d22\u73af\u8282&#xff0c;\u6838\u5fc3\u9760\u7684\u5c31\u662f\u5411\u91cf\u68c0\u7d22\u3002 \u8fd9\u7bc7\u6587\u7ae0\u4ece\u96f6\u8bb2\u6e05\u695a&#xff1a;\u4ec0\u4e48\u662f\u5411\u91cf","og_url":"https:\/\/www.wsisp.com\/helps\/91107.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-06T14:24:40+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/91107.html","url":"https:\/\/www.wsisp.com\/helps\/91107.html","name":"RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-06T14:24:40+00:00","dateModified":"2026-08-06T14:24:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/91107.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/91107.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/91107.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"RAG \u5411\u91cf\u68c0\u7d22\uff1a\u4ece\u201c\u67e5\u5b57\u201c\u5230\u201c\u67e5\u610f\u201c"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/91107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=91107"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/91107\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=91107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=91107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=91107"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=91107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}