{"id":14906,"date":"2024-12-06T10:38:39","date_gmt":"2024-12-06T02:38:39","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=14906"},"modified":"2024-12-08T10:45:04","modified_gmt":"2024-12-08T02:45:04","slug":"aigongchengxueyuan22","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/de\/aigongchengxueyuan22\/","title":{"rendered":"AI\u5de5\u7a0b\u5b66\u9662\uff1a2.2\u57fa\u672c RAG \u5b9e\u73b0"},"content":{"rendered":"<h2 dir=\"auto\">\u4ecb\u7ecd<\/h2>\n<p>&nbsp;<\/p>\n<p dir=\"auto\">\u68c0\u7d22\u589e\u5f3a\u751f\u6210 (<a href=\"https:\/\/www.kdjingpai.com\/de\/rag\/\">RAG<\/a>) \u662f\u4e00\u79cd\u5f3a\u5927\u7684\u6280\u672f\uff0c\u5b83\u5c06\u5927\u578b\u8bed\u8a00\u6a21\u578b\u7684\u4f18\u52bf\u4e0e\u4ece\u77e5\u8bc6\u5e93\u4e2d\u68c0\u7d22\u76f8\u5173\u4fe1\u606f\u7684\u80fd\u529b\u76f8\u7ed3\u5408\u3002\u8fd9\u79cd\u65b9\u6cd5\u901a\u8fc7\u5c06\u751f\u6210\u7684\u54cd\u5e94\u5efa\u7acb\u5728\u7279\u5b9a\u7684\u68c0\u7d22\u4fe1\u606f\u4e0a\u6765\u63d0\u9ad8\u751f\u6210\u54cd\u5e94\u7684\u8d28\u91cf\u548c\u51c6\u786e\u6027\u3002a \u672c\u7b14\u8bb0\u672c\u65e8\u5728\u63d0\u4f9b\u6e05\u6670\u7b80\u6d01\u7684 RAG \u4ecb\u7ecd\uff0c\u9002\u5408\u60f3\u8981\u4e86\u89e3\u548c\u5b9e\u65bd\u8fd9\u9879\u6280\u672f\u7684\u521d\u5b66\u8005\u3002<\/p>\n<p dir=\"auto\">\n<h3 dir=\"auto\">RAG \u6d41\u7a0b<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-14907\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/2a84ae316d0a55c.jpg\" alt=\"\" width=\"715\" height=\"1205\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/2a84ae316d0a55c.jpg 1246w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/2a84ae316d0a55c-178x300.jpg 178w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/2a84ae316d0a55c-608x1024.jpg 608w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/2a84ae316d0a55c-768x1294.jpg 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/2a84ae316d0a55c-911x1536.jpg 911w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/2a84ae316d0a55c-1215x2048.jpg 1215w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/2a84ae316d0a55c-7x12.jpg 7w\" sizes=\"auto, (max-width: 715px) 100vw, 715px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>\u5f00\u59cb<\/h2>\n<h3>Notebook<\/h3>\n<p>\u60a8\u53ef\u4ee5\u8fd0\u884c\u6b64\u4ed3\u5e93\u4e2d\u63d0\u4f9b\u7684 Notebook\u3002https:\/\/github.com\/adithya-s-k\/AI-Engineering.academy\/tree\/main\/RAG\/01_Basic_RAG<\/p>\n<h3>\u804a\u5929\u5e94\u7528\u7a0b\u5e8f<\/h3>\n<ol>\n<li>\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a\n<pre><code>pip install -r requirements.txt\r\n<\/code><\/pre>\n<\/li>\n<li>\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff1a\n<pre><code>python app.py\r\n<\/code><\/pre>\n<\/li>\n<li>\u52a8\u6001\u5bfc\u5165\u6570\u636e\uff1a\n<pre><code>python app.py --ingest --data_dir \/path\/to\/documents\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>\u670d\u52a1\u5668<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u670d\u52a1\u5668\uff1a<\/p>\n<pre><code>python server.py\r\n<\/code><\/pre>\n<p>\u670d\u52a1\u5668\u63d0\u4f9b\u4e24\u4e2a\u7aef\u70b9\uff1a<\/p>\n<ul>\n<li><code>\/api\/ingest<\/code><\/li>\n<li><code>\/api\/query<\/code><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u52a8\u673a<\/h2>\n<p>\u4f20\u7edf\u8bed\u8a00\u6a21\u578b\u6839\u636e\u8bad\u7ec3\u6570\u636e\u4e2d\u5b66\u5230\u7684\u6a21\u5f0f\u751f\u6210\u6587\u672c\u3002\u7136\u800c\uff0c\u5f53\u9762\u5bf9\u9700\u8981\u7279\u5b9a\u3001\u66f4\u65b0\u6216\u4e13\u4e1a\u4fe1\u606f\u7684\u67e5\u8be2\u65f6\uff0c\u5b83\u4eec\u53ef\u80fd\u96be\u4ee5\u63d0\u4f9b\u51c6\u786e\u7684\u56de\u590d\u3002RAG \u901a\u8fc7\u5f15\u5165\u68c0\u7d22\u6b65\u9aa4\uff0c\u5411\u8bed\u8a00\u6a21\u578b\u63d0\u4f9b\u76f8\u5173\u4e0a\u4e0b\u6587\uff0c\u4ece\u800c\u751f\u6210\u66f4\u51c6\u786e\u7684\u7b54\u6848\uff0c\u89e3\u51b3\u4e86\u8fd9\u4e00\u9650\u5236\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u65b9\u6cd5\u8be6\u60c5<\/h2>\n<h3>\u6587\u6863\u9884\u5904\u7406\u548c\u5411\u91cf\u5b58\u50a8\u521b\u5efa<\/h3>\n<ol>\n<li><strong>\u6587\u6863\u5206\u5757<\/strong>: \u5c06\u77e5\u8bc6\u5e93\u6587\u6863\uff08\u4f8b\u5982 PDF\u3001\u6587\u7ae0\uff09\u9884\u5904\u7406\u5e76\u62c6\u5206\u4e3a\u53ef\u7ba1\u7406\u7684\u5757\u3002\u8fd9\u6837\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u53ef\u641c\u7d22\u7684\u8bed\u6599\u5e93\uff0c\u7528\u4e8e\u9ad8\u6548\u68c0\u7d22\u8fc7\u7a0b\u3002<\/li>\n<li><strong>\u751f\u6210\u5d4c\u5165<\/strong>: \u4f7f\u7528\u9884\u8bad\u7ec3\u7684\u5d4c\u5165\uff08\u4f8b\u5982 OpenAI \u7684\u5d4c\u5165\uff09\u5c06\u6bcf\u4e2a\u5757\u8f6c\u6362\u4e3a\u5411\u91cf\u8868\u793a\u3002\u8fd9\u4e9b\u6587\u6863\u968f\u540e\u88ab\u5b58\u50a8\u5728\u5411\u91cf\u6570\u636e\u5e93\uff08\u5982 Qdrant\uff09\u4e2d\uff0c\u4ee5\u5b9e\u73b0\u9ad8\u6548\u7684\u76f8\u4f3c\u6027\u641c\u7d22\u3002<\/li>\n<\/ol>\n<h3>\u68c0\u7d22\u589e\u5f3a\u751f\u6210 (RAG) \u5de5\u4f5c\u6d41<\/h3>\n<ol>\n<li><strong>\u67e5\u8be2\u8f93\u5165<\/strong>: \u7528\u6237\u63d0\u4f9b\u9700\u8981\u56de\u7b54\u7684\u67e5\u8be2\u3002<\/li>\n<li><strong>\u68c0\u7d22\u6b65\u9aa4<\/strong>: \u4f7f\u7528\u4e0e\u6587\u6863\u76f8\u540c\u7684\u5d4c\u5165\u6a21\u578b\u5c06\u67e5\u8be2\u5d4c\u5165\u4e3a\u5411\u91cf\u3002\u7136\u540e\u5728\u5411\u91cf\u6570\u636e\u5e93\u4e2d\u6267\u884c\u76f8\u4f3c\u6027\u641c\u7d22\uff0c\u4ee5\u627e\u5230\u6700\u76f8\u5173\u7684\u6587\u6863\u5757\u3002<\/li>\n<li><strong>\u751f\u6210\u6b65\u9aa4<\/strong>: \u5c06\u68c0\u7d22\u5230\u7684\u6587\u6863\u5757\u4f5c\u4e3a\u9644\u52a0\u4e0a\u4e0b\u6587\u4f20\u9012\u7ed9\u5927\u8bed\u8a00\u6a21\u578b\uff08\u4f8b\u5982 GPT-4\uff09\u3002\u6a21\u578b\u5229\u7528\u8fd9\u4e9b\u4e0a\u4e0b\u6587\u751f\u6210\u66f4\u51c6\u786e\u4e14\u76f8\u5173\u7684\u56de\u590d\u3002<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2>RAG \u7684\u5173\u952e\u7279\u6027<\/h2>\n<ol>\n<li><strong>\u4e0a\u4e0b\u6587\u76f8\u5173\u6027<\/strong>: \u901a\u8fc7\u57fa\u4e8e\u5b9e\u9645\u68c0\u7d22\u4fe1\u606f\u751f\u6210\u56de\u590d\uff0cRAG \u6a21\u578b\u53ef\u4ee5\u751f\u6210\u66f4\u5177\u4e0a\u4e0b\u6587\u76f8\u5173\u6027\u548c\u51c6\u786e\u6027\u7684\u7b54\u6848\u3002<\/li>\n<li><strong>\u53ef\u6269\u5c55\u6027<\/strong>: \u68c0\u7d22\u6b65\u9aa4\u53ef\u4ee5\u6269\u5c55\u4ee5\u5904\u7406\u5927\u578b\u77e5\u8bc6\u5e93\uff0c\u4f7f\u6a21\u578b\u80fd\u591f\u4ece\u6d77\u91cf\u4fe1\u606f\u4e2d\u63d0\u53d6\u5185\u5bb9\u3002<\/li>\n<li><strong>\u7528\u4f8b\u7075\u6d3b\u6027<\/strong>: RAG \u53ef\u4ee5\u9002\u914d\u4e8e\u5404\u79cd\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u95ee\u7b54\u3001\u6458\u8981\u751f\u6210\u3001\u63a8\u8350\u7cfb\u7edf\u7b49\u3002<\/li>\n<li><strong>\u51c6\u786e\u6027\u63d0\u9ad8<\/strong>: \u7ed3\u5408\u68c0\u7d22\u4e0e\u751f\u6210\u7684\u65b9\u5f0f\u901a\u5e38\u80fd\u4ea7\u751f\u66f4\u7cbe\u786e\u7684\u7ed3\u679c\uff0c\u5c24\u5176\u662f\u9488\u5bf9\u9700\u8981\u7279\u5b9a\u6216\u51b7\u95e8\u4fe1\u606f\u7684\u67e5\u8be2\u3002<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2>\u6b64\u65b9\u6cd5\u7684\u4f18\u52bf<\/h2>\n<ol>\n<li><strong>\u7ed3\u5408\u68c0\u7d22\u548c\u751f\u6210\u7684\u4f18\u70b9<\/strong>\uff1aRAG \u6709\u6548\u878d\u5408\u4e86\u57fa\u4e8e\u68c0\u7d22\u7684\u65b9\u6cd5\u4e0e\u751f\u6210\u6a21\u578b\uff0c\u65e2\u53ef\u4ee5\u7cbe\u786e\u67e5\u627e\u4e8b\u5b9e\uff0c\u53c8\u80fd\u8fdb\u884c\u81ea\u7136\u8bed\u8a00\u751f\u6210\u3002<\/li>\n<li><strong>\u589e\u5f3a\u5bf9\u957f\u5c3e\u67e5\u8be2\u7684\u5904\u7406<\/strong>\uff1a\u5bf9\u4e8e\u9700\u8981\u7279\u5b9a\u4e14\u4e0d\u5e38\u89c1\u4fe1\u606f\u7684\u67e5\u8be2\uff0c\u8be5\u65b9\u6cd5\u8868\u73b0\u5c24\u4e3a\u51fa\u8272\u3002<\/li>\n<li><strong>\u9886\u57df\u9002\u5e94\u6027<\/strong>\uff1a\u68c0\u7d22\u673a\u5236\u53ef\u4ee5\u9488\u5bf9\u7279\u5b9a\u9886\u57df\u8fdb\u884c\u8c03\u4f18\uff0c\u786e\u4fdd\u751f\u6210\u7684\u56de\u7b54\u57fa\u4e8e\u6700\u76f8\u5173\u548c\u51c6\u786e\u7684\u9886\u57df\u7279\u5b9a\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2>\u7ed3\u8bba<\/h2>\n<p>\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08Retrieval-Augmented Generation\uff0cRAG\uff09\u662f\u4e00\u79cd\u5c06\u68c0\u7d22\u4e0e\u751f\u6210\u6280\u672f\u521b\u65b0\u878d\u5408\u7684\u65b9\u5f0f\uff0c\u901a\u8fc7\u5c06\u8f93\u51fa\u5185\u5bb9\u57fa\u4e8e\u76f8\u5173\u5916\u90e8\u4fe1\u606f\uff0c\u6709\u6548\u589e\u5f3a\u8bed\u8a00\u6a21\u578b\u7684\u80fd\u529b\u3002\u8fd9\u79cd\u65b9\u6cd5\u5728\u9700\u8981\u7cbe\u51c6\u4e14\u5177\u4e0a\u4e0b\u6587\u610f\u8bc6\u7684\u56de\u7b54\u573a\u666f\u4e2d\uff08\u5982\u5ba2\u6237\u652f\u6301\u3001\u5b66\u672f\u7814\u7a76\u7b49\uff09\u5c24\u5176\u6709\u4ef7\u503c\u3002\u968f\u7740 AI \u7684\u4e0d\u65ad\u53d1\u5c55\uff0cRAG \u5728\u6784\u5efa\u66f4\u53ef\u9760\u548c\u4e0a\u4e0b\u6587\u654f\u611f\u7684 AI \u7cfb\u7edf\u4e2d\u8131\u9896\u800c\u51fa\uff0c\u5c55\u73b0\u4e86\u5176\u5f3a\u5927\u7684\u6f5c\u529b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u524d\u7f6e\u6761\u4ef6<\/h2>\n<ul>\n<li>\u4f18\u9009 Python 3.11<\/li>\n<li>Jupyter Notebook \u6216 JupyterLab<\/li>\n<li>LLM API Key\n<ul>\n<li>\u53ef\u4f7f\u7528\u4efb\u610f LLM\u3002\u5728\u672c notebook \u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 OpenAI \u548c GPT-4o-mini\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u5b9e\u73b0\u4e00\u4e2a\u57fa\u7840\u7684 RAG \u7cfb\u7edf\uff0c\u7ed3\u5408\u771f\u5b9e\u4e16\u754c\u7684\u6700\u65b0\u4fe1\u606f\uff0c\u63d0\u5347\u8bed\u8a00\u6a21\u578b\u5728\u5404\u79cd\u5e94\u7528\u4e2d\u7684\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ecb\u7ecd &nbsp; \u68c0\u7d22\u589e\u5f3a\u751f\u6210 (RAG) \u662f\u4e00\u79cd\u5f3a\u5927\u7684\u6280\u672f\uff0c\u5b83\u5c06\u5927\u578b\u8bed\u8a00\u6a21\u578b\u7684\u4f18\u52bf\u4e0e\u4ece\u77e5\u8bc6\u5e93\u4e2d\u68c0\u7d22\u76f8\u5173\u4fe1\u606f\u7684\u80fd\u529b\u76f8\u7ed3\u5408\u3002\u8fd9\u79cd\u65b9\u6cd5\u901a\u8fc7\u5c06\u751f\u6210\u7684\u54cd\u5e94\u5efa\u7acb\u5728\u7279\u5b9a\u7684\u68c0\u7d22\u4fe1\u606f\u4e0a\u6765\u63d0\u9ad8\u751f\u6210\u54cd\u5e94\u7684\u8d28\u91cf\u548c\u51c6\u786e\u6027\u3002a \u672c\u7b14\u8bb0\u672c\u65e8\u5728\u63d0\u4f9b\u6e05\u6670\u7b80\u6d01\u7684 RAG &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-14906","post","type-post","status-publish","format-standard","hentry","category-knowledge"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts\/14906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/comments?post=14906"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts\/14906\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/media?parent=14906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/categories?post=14906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/tags?post=14906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}