{"id":48464,"date":"2025-07-30T11:59:38","date_gmt":"2025-07-30T03:59:38","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/48464.html"},"modified":"2025-07-30T11:59:38","modified_gmt":"2025-07-30T03:59:38","slug":"4%e5%8d%a14090%e6%9c%8d%e5%8a%a1%e5%99%a8graphrag%e7%8e%af%e5%a2%83%e9%83%a8%e7%bd%b2%e3%80%81%e5%8a%a0%e8%bd%bdollama%e5%90%91%e9%87%8f%e6%a8%a1%e5%9e%8b%e5%8f%8a%e5%90%91%e9%87%8f%e7%9f%a5%e8%af%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/48464.html","title":{"rendered":"4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528"},"content":{"rendered":"<p>&#064;4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528<\/p>\n<p>\u672c\u4eba\u5b89\u88c5\u7684\u786c\u4ef6\u73af\u5883\u5982\u4e0b:<br \/>\nCPU:intel\u81f3\u5f3a\u91d1\u724c6148*2\u4e3b\u98912.5G \u517140\u683880\u7ebf\u7a0b<br \/>\n\u5185\u5b58&#xff1a;\u4e09\u661f32G DDR4\u670d\u52a1\u5668\u5185\u5b582933 *4&#061;128GB<br \/>\n\u663e\u5361&#xff1a;\u82f1\u4f1f\u8fbe4090\u6da1\u8f6e\u516c\u7248 *4 &#061; 96G<br \/>\n\u64cd\u4f5c\u7cfb\u7edf:ubuntu 24.04 LTS<br \/>\nconda:Anaconda 24.11.3<\/p>\n<h2>\u90e8\u7f72GraphRAG\u73af\u5883<\/h2>\n<p>1.\u521b\u5efa\u865a\u62df\u73af\u5883,\u672c\u9879\u76ee\u7531\u4e8e\u90e8\u7f72GraphRAG\u7a33\u5b9a\u7248\u672c&#xff0c;\u7ecf\u591a\u6b21\u6d4b\u8bd5python3.10\u7248\u672c\u76f8\u5bf9\u8f83\u7a33\u5b9a\u3002<\/p>\n<p>conda create <span class=\"token parameter variable\">-n<\/span> graphrag <span class=\"token assign-left variable\">python<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">3.10<\/span> <span class=\"token parameter variable\">-y<\/span><\/p>\n<p>2.\u8fdb\u5165\u521b\u5efa\u7684GraphRAG\u73af\u5883<\/p>\n<p>conda activate graphrag <\/p>\n<p>\u865a\u62df\u73af\u5883\u521b\u5efa\u6210\u529f\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035918-6889989651256.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n3.\u5b89\u88c5graphrag\u73af\u5883&#xff0c;\u672c\u9879\u76ee\u5b89\u88c5\u7684\u7a33\u5b9a\u76840.5.0\u7248\u672c<\/p>\n<p>pip <span class=\"token function\">install<\/span> <span class=\"token assign-left variable\">graphrag<\/span><span class=\"token operator\">&#061;&#061;<\/span><span class=\"token number\">0.5<\/span>.0<\/p>\n<p>\u5b89\u88c5\u6210\u529f\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035919-68899897ddaab.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>4.\u5b89\u88c5openai\u6807\u51c6\u63a5\u5165\u5927\u6a21\u578b\u7684API\u534f\u8bae\u4f9d\u8d56\u9879<\/p>\n<p>pip <span class=\"token function\">install<\/span> openai<\/p>\n<p>\u5b89\u88c5\u6210\u529f\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035921-6889989969567.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n5.\u5b89\u88c5\u8c03\u7528ollama\u670d\u52a1\u7684\u4f9d\u8d56\u9879<\/p>\n<p>pip <span class=\"token function\">install<\/span> ollama<\/p>\n<p>\u5b89\u88c5\u6210\u529f\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035922-6889989a85879.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n6.\u7531\u4e8egraphrag\u53d1\u5e03\u662f\u57fa\u4e8eopenai\u73af\u5883\u7684&#xff0c;\u56e0\u6b64\u672c\u5730\u5316\u90e8\u7f72\u53ca\u8c03\u7528\u672c\u5730\u63a8\u7406\u5927\u6a21\u578b&#xff0c;\u9700\u8981\u4fee\u6539graphrag\u5f00\u6e90\u7684\u914d\u7f6e\u6587\u4ef6&#xff0c;\u6ee1\u8db3\u9879\u76ee\u6587\u4ef6\u8c03\u7528\u672c\u5730\u63a8\u7406\u6a21\u578b&#xff0c;\u652f\u6301\u6570\u636e\u4fdd\u5bc6\u76f8\u5173\u4e1a\u52a1\u8fd0\u884c&#xff1b;\u5171\u9700\u8981\u4fee\u6539\u4e09\u4e2aGraphrag\u7684python\u7684\u6e90\u4ee3\u7801\u6587\u4ef6&#xff0c;\u4fee\u6539\u7b80\u5355&#xff0c;\u4f46\u662f\u4e5f\u9700\u8981\u4f1apython\u7f16\u7a0b\u6280\u672f&#xff0c;\u9632\u6b62\u4fee\u6539\u540e\u683c\u5f0f\u95ee\u9898\u62a5\u9519\u3002<br \/>\n6.1.\u4fee\u6539llm\/openai\/openai_embeddings_llm.py\u7684GraphRAG\u6e90\u4ee3\u7801\u6587\u4ef6&#xff0c;\u67e5\u627e\u8def\u5f84\u5728conda\u7cfb\u7edf\u76ee\u5f55\u4e0b\u7684env-&gt;\u5f53\u524d\u5b89\u88c5\u73af\u5883,\u6211\u5f53\u524d\u9879\u76ee\u540d\u662fgraphrag-&gt;lib\/python3.10\/site-packages\/graphrag\u76ee\u5f55\u4e0b&#xff0c;\u5f53\u524d\u6211\u7684\u9879\u76ee\u5177\u4f53\u76ee\u5f55\u662f<\/p>\n<p>\/home\/allanfan\/anaconda3\/envs\/graphrag\/lib\/python3.10\/site-packages\/graphrag<\/p>\n<p>\u5f53\u524d\u9879\u76ee\u627e\u5230\u7684graphrag\u6e90\u4ee3\u7801\u4f4d\u7f6e\u76ee\u5f55\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035923-6889989b2483f.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5907\u6ce8&#xff1a;\u5927\u5bb6\u7684\u9879\u76ee\u6839\u636e\u5b89\u88c5\u7684conda\u73af\u5883\u76ee\u5f55&#xff0c;\u6309\u6211\u4e0a\u9762\u4e00\u76f4\u627e\u4e0b\u53bb\u5373\u53ef&#xff0c;\u5f53\u524dpython\u73af\u5883\u662f<span class=\"token number\">3.10<\/span>&#xff0c;\u5176\u5b83\u66f4\u9ad8\u7248\u672c\u6211\u8bd5\u8fc7&#xff0c;\u4e0d\u592a\u597d\u7528\u3002\u5982\u679c\u5927\u5bb6\u6709\u65f6\u95f4\u53ef\u4ee5\u8bd5\u4e00\u4e0b\u66f4\u9ad8\u7248\u672c&#xff0c;\u4f46\u662fgraphrag <span class=\"token number\">0.5<\/span><span class=\"token punctuation\">.<\/span><span class=\"token number\">0<\/span>\u4ee5\u4e0a\u7248\u672c\u5b8c\u5168\u57fa\u4e8eopenai\u534f\u8bae&#xff0c;\u4e2a\u4eba\u5c1d\u8bd5\u5f88\u591a\u6b21\u65e0\u6cd5\u672c\u5730\u5316\u63a5\u63a8\u7406\u6a21\u578b\u3002<\/p>\n<p>\u901a\u8fc7\u4e0a\u9762\u76ee\u5f55\u5411\u4e0b\u627e\u5230llm\/openai\/openai_embeddings_llm.py\u6e90\u6587\u4ef6&#xff0c;\u7528sudo nano\u6253\u5f00\u6587\u4ef6\u6ce8\u91ca\u6389\u4e0b\u9762\u4ee3\u7801&#xff0c;\u7136\u540e\u6dfb\u52a0\u4ee5\u4e0b\u65b0\u4ee3\u7801\u3002<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">nano<\/span> openai_embeddings_llm.py<\/p>\n<p>\u6ce8\u91ca36\u884c\u81f341\u884c&#xff0c;\u6ce8\u91ca\u5177\u4f53\u4ee3\u7801\u5982\u4e0b\u6240\u793a&#xff0c;\u884c\u6570\u4ec5\u4f9b\u53c2\u8003&#xff0c;\u5177\u4f53\u662f\u4ee5\u4e0b\u4ee3\u7801\u3002<\/p>\n<p><span class=\"token triple-quoted-string string\">&#039;&#039;&#039;embedding &#061; await self.client.embeddings.create(<br \/>\n    input&#061;input,<br \/>\n    **args,<br \/>\n)<br \/>\nreturn [d.embedding for d in embedding.data]&#039;&#039;&#039;<\/span><\/p>\n<p>\u6ce8\u91ca\u4ee3\u7801\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035923-6889989b9ff07.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u6dfb\u52a0\u4ee3\u7801\u5982\u4e0b\u6240\u793a\u3002\u5176\u4e2d&#xff0c;\u5411\u91cf\u6a21\u578b\u540d\u79f0\u6839\u636e\u81ea\u5df1\u4e0b\u8f7d\u7684\u6a21\u578b\u547d\u540d\u4fee\u6539&#xff0c;\u672c\u9879\u76ee\u6d4b\u8bd5\u7528\u7684\u662fnomic-embed-text\u6a21\u578b\u3002<br \/>\n\u6587\u4ef6\u5934\u90e8\u6dfb\u52a0\u5f15\u7528\u672c\u5730ollama\u4f9d\u8d56\u9879<\/p>\n<p><span class=\"token keyword\">import<\/span> ollama<\/p>\n<p>\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035924-6889989c45ea5.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e0a\u9762\u6ce8\u91ca\u540e\u9762\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801<\/p>\n<p>embedding_list <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">for<\/span> inp <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">input<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    embedding <span class=\"token operator\">&#061;<\/span> ollama<span class=\"token punctuation\">.<\/span>embeddings<span class=\"token punctuation\">(<\/span>model<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;nomic-embed-text&#034;<\/span><span class=\"token punctuation\">,<\/span>prompt<span class=\"token operator\">&#061;<\/span>inp<span class=\"token punctuation\">)<\/span><br \/>\n    embedding_list<span class=\"token punctuation\">.<\/span>append<span class=\"token punctuation\">(<\/span>embedding<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;embedding&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">return<\/span> embedding_list<\/p>\n<p>\u6dfb\u52a0\u65b0\u4ee3\u7801\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035924-6889989cd545c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\nnano\u4fdd\u5b58\u6587\u4ef6\u6309ctrl&#043;o,\u4fdd\u5b58\u540e\u9000\u51fa\u6309ctrl&#043;c\u3002\u4fee\u6539\u540e\u6574\u4f53\u4ee3\u7801\u53c2\u8003\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<p><span class=\"token comment\"># Copyright (c) 2024 Microsoft Corporation.<\/span><br \/>\n<span class=\"token comment\"># Licensed under the MIT License<\/span><\/p>\n<p><span class=\"token triple-quoted-string string\">&#034;&#034;&#034;The EmbeddingsLLM class.&#034;&#034;&#034;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> ollama<\/p>\n<p><span class=\"token keyword\">from<\/span> typing_extensions <span class=\"token keyword\">import<\/span> Unpack<\/p>\n<p><span class=\"token keyword\">from<\/span> graphrag<span class=\"token punctuation\">.<\/span>llm<span class=\"token punctuation\">.<\/span>base <span class=\"token keyword\">import<\/span> BaseLLM<br \/>\n<span class=\"token keyword\">from<\/span> graphrag<span class=\"token punctuation\">.<\/span>llm<span class=\"token punctuation\">.<\/span>types <span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">(<\/span><br \/>\n    EmbeddingInput<span class=\"token punctuation\">,<\/span><br \/>\n    EmbeddingOutput<span class=\"token punctuation\">,<\/span><br \/>\n    LLMInput<span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">from<\/span> <span class=\"token punctuation\">.<\/span>openai_configuration <span class=\"token keyword\">import<\/span> OpenAIConfiguration<br \/>\n<span class=\"token keyword\">from<\/span> <span class=\"token punctuation\">.<\/span>types <span class=\"token keyword\">import<\/span> OpenAIClientTypes<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">OpenAIEmbeddingsLLM<\/span><span class=\"token punctuation\">(<\/span>BaseLLM<span class=\"token punctuation\">[<\/span>EmbeddingInput<span class=\"token punctuation\">,<\/span> EmbeddingOutput<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;A text-embedding generator LLM.&#034;&#034;&#034;<\/span><\/p>\n<p>    _client<span class=\"token punctuation\">:<\/span> OpenAIClientTypes<br \/>\n    _configuration<span class=\"token punctuation\">:<\/span> OpenAIConfiguration<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> client<span class=\"token punctuation\">:<\/span> OpenAIClientTypes<span class=\"token punctuation\">,<\/span> configuration<span class=\"token punctuation\">:<\/span> OpenAIConfiguration<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>client <span class=\"token operator\">&#061;<\/span> client<br \/>\n        self<span class=\"token punctuation\">.<\/span>configuration <span class=\"token operator\">&#061;<\/span> configuration<\/p>\n<p>    <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">def<\/span> <span class=\"token function\">_execute_llm<\/span><span class=\"token punctuation\">(<\/span><br \/>\n        self<span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">input<\/span><span class=\"token punctuation\">:<\/span> EmbeddingInput<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">**<\/span>kwargs<span class=\"token punctuation\">:<\/span> Unpack<span class=\"token punctuation\">[<\/span>LLMInput<span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token operator\">&gt;<\/span> EmbeddingOutput <span class=\"token operator\">|<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        args <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token string\">&#034;model&#034;<\/span><span class=\"token punctuation\">:<\/span> self<span class=\"token punctuation\">.<\/span>configuration<span class=\"token punctuation\">.<\/span>model<span class=\"token punctuation\">,<\/span><br \/>\n            <span class=\"token operator\">**<\/span><span class=\"token punctuation\">(<\/span>kwargs<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;model_parameters&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">or<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;embedding &#061; await self.client.embeddings.create(<br \/>\n            input&#061;input,<br \/>\n            **args,<br \/>\n        ) return [d.embedding for d in embedding.data]&#034;&#034;&#034;<\/span><br \/>\n        embedding_list <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> inp <span class=\"token keyword\">in<\/span> <span class=\"token builtin\">input<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                embedding <span class=\"token operator\">&#061;<\/span> ollama<span class=\"token punctuation\">.<\/span>embeddings<span class=\"token punctuation\">(<\/span>model<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;nomic-embed-text&#034;<\/span><span class=\"token punctuation\">,<\/span>prompt<span class=\"token operator\">&#061;<\/span>inp<span class=\"token punctuation\">)<\/span><br \/>\n                embedding_list<span class=\"token punctuation\">.<\/span>append<span class=\"token punctuation\">(<\/span>embedding<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;embedding&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> embedding_list<\/p>\n<p>6.2.\u4fee\u6539qutry\/llm\/oai\/embedding.py\u6e90\u4ee3\u7801\u6587\u4ef6&#xff0c;\u8fd8\u5728\u5f53\u524d\u6211\u7684\u9879\u76ee\u4e0b\u67e5\u627e\u8be5\u6e90\u4ee3\u7801\u6587\u4ef6&#xff0c;\u4e0b\u9762\u5f53\u524d\u6211\u9879\u76ee\u7684graphrag\u76ee\u5f55.<\/p>\n<p>\/home\/allanfan\/anaconda3\/envs\/graphrag\/lib\/python3.10\/site-packages\/graphrag<\/p>\n<p>\u627e\u5230qutry\/llm\/oai\/embedding.py&#xff0c;\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035925-6889989d6d030.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u7528nano\u547d\u4ee4\u6253\u5f00\u6587\u4ef6&#xff0c;\u6ce8\u91ca\u53ca\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u3002<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">nano<\/span> embedding.py<\/p>\n<p>\u6587\u4ef6\u5934\u90e8\u6dfb\u52a0\u5f15\u7528\u672c\u5730ollama\u4f9d\u8d56\u9879<\/p>\n<p><span class=\"token keyword\">import<\/span> ollama<\/p>\n<p>\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035926-6889989e0c06e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u627e\u5230\u6e90\u4ee3\u7801\u4e2d\u4e24\u5904\u4ee5\u4e0b\u4ee3\u7801&#xff0c;\u5982\u4e0b\u6240\u793a<br \/>\n\u7b2c\u4e00\u5904&#xff1a;<\/p>\n<p>embedding<span class=\"token punctuation\">,<\/span> chunk_len <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>_embed_with_retry<span class=\"token punctuation\">(<\/span>chunk<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">**<\/span>kwargs<span class=\"token punctuation\">)<\/span><\/p>\n<p>\u7b2c\u4e8c\u5904&#xff1a;<\/p>\n<p>chunk_embeddings <span class=\"token operator\">&#061;<\/span> np<span class=\"token punctuation\">.<\/span>average<span class=\"token punctuation\">(<\/span>chunk_embeddings<span class=\"token punctuation\">,<\/span> axis<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> weights<span class=\"token operator\">&#061;<\/span>chunk_lens<span class=\"token punctuation\">)<\/span><br \/>\nchunk_embeddings <span class=\"token operator\">&#061;<\/span> chunk_embeddings <span class=\"token operator\">\/<\/span> np<span class=\"token punctuation\">.<\/span>linalg<span class=\"token punctuation\">.<\/span>norm<span class=\"token punctuation\">(<\/span>chunk_embeddings<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">return<\/span> chunk_embeddings<span class=\"token punctuation\">.<\/span>tolist<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u5c06\u4e0a\u9762\u4e24\u5904\u4ee3\u7801\u6dfb\u52a0#&#xff0c;\u6ce8\u91ca\u6389&#xff0c;\u64cd\u4f5c\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035926-6889989e9336c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u5728\u4e0a\u9762\u4e24\u5904\u6ce8\u91ca\u540e\u9762\u6dfb\u52a0\u4ee5\u4e0b\u4e24\u6bb5\u65b0\u4ee3\u7801&#xff0c;\u5176\u4e2d&#xff0c;\u7b2c\u4e00\u5904\u4ee3\u7801\u6a21\u578b\u540d\u79f0\u6839\u636e\u5b9e\u9645\u6a21\u578b\u540d\u79f0\u4fee\u6539&#xff0c;\u672c\u9879\u76ee\u5411\u91cf\u6a21\u578b\u4f7f\u7528\u7684\u662fnomic-embed-text\u3002<br \/>\n\u7b2c\u4e00\u5904&#xff1a;<\/p>\n<p>embedding <span class=\"token operator\">&#061;<\/span> ollama<span class=\"token punctuation\">.<\/span>embeddings<span class=\"token punctuation\">(<\/span>model<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;nomic-embed-text&#039;<\/span><span class=\"token punctuation\">,<\/span> prompt<span class=\"token operator\">&#061;<\/span>chunk<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;embedding&#039;<\/span><span class=\"token punctuation\">]<\/span><\/p>\n<p>\u7b2c\u4e8c\u5904&#xff1a;<\/p>\n<p><span class=\"token keyword\">return<\/span> chunk_embeddings<\/p>\n<p>\u5177\u4f53\u6dfb\u52a0\u4ee3\u7801\u540e&#xff0c;\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035927-6889989f2d6d8.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u6dfb\u52a0\u597d\u65b0\u4ee3\u7801\u540e\u6309ctrl&#043;o\u4fdd\u5b58&#xff0c;\u4fdd\u5b58\u540e\u6309ctrl&#043;c\u9000\u51fa\u5373\u53ef\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035927-6889989fbea6e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n6.3.\u4fee\u6539qutry\/llm\/text_utils.py\u6e90\u4ee3\u7801\u6587\u4ef6&#xff0c;&#xff0c;\u8fd8\u5728\u5f53\u524d\u6211\u7684\u9879\u76ee\u4e0b\u67e5\u627e\u8be5\u6e90\u4ee3\u7801\u6587\u4ef6&#xff0c;\u4e0b\u9762\u5f53\u524d\u6211\u9879\u76ee\u7684graphrag\u76ee\u5f55.<\/p>\n<p>\/home\/allanfan\/anaconda3\/envs\/graphrag\/lib\/python3.10\/site-packages\/graphrag<\/p>\n<p>\u627e\u5230qutry\/llm\/text_utils.py&#xff0c;\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035928-688998a053dc9.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u4f7f\u7528sudo nano\u6253\u5f00\u6e90\u4ee3\u7801\u6587\u4ef6&#xff0c;\u6dfb\u52a0\u4ee5\u4e0b\u4e00\u884c\u4ee3\u7801\u5373\u53ef&#xff0c;\u8be5\u4ee3\u7801\u662f\u5c06tokens\u89e3\u7801\u6210\u5b57\u7b26\u4e32\u3002<\/p>\n<p>tokens <span class=\"token operator\">&#061;<\/span> token_encoder<span class=\"token punctuation\">.<\/span>decode<span class=\"token punctuation\">(<\/span>tokens<span class=\"token punctuation\">)<\/span> <\/p>\n<p>\u6dfb\u52a0\u4e0a\u9762\u4ee3\u7801\u4f4d\u7f6e\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035929-688998a1095a5.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u6dfb\u52a0\u597d\u65b0\u4ee3\u7801\u540e\u6309ctrl&#043;o\u4fdd\u5b58&#xff0c;\u4fdd\u5b58\u540e\u6309ctrl&#043;c\u9000\u51fa\u5373\u53ef\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035929-688998a1e0674.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u81f3\u6b64GraphRAG\u73af\u5883\u90e8\u7f72\u5df2\u5b8c\u6210&#xff0c;\u63a5\u4e0b\u6765\u5f00\u59cbGraphRAG\u7684\u77e5\u8bc6\u5e93\u7d22\u5f15\u6784\u5efa\u3001\u77e5\u8bc6\u5e93\u67e5\u8be2\u670d\u52a1\u7b49\u3002<\/p>\n<h2>GraphRAG\u914d\u7f6eollama\u5411\u91cf\u6a21\u578b\u3001\u914d\u7f6e\u672c\u5730vllm\u7684DeepSeek 32B\u63a8\u7406\u6a21\u578b\u3001\u77e5\u8bc6\u5e93\u6784\u5efa\u3001\u793a\u4f8b\u77e5\u8bc6\u5e93\u7684\u67e5\u8be2<\/h2>\n<p>1.\u521b\u5efa\u77e5\u8bc6\u5e93\u76ee\u5f55&#xff0c;\u672c\u9879\u76ee\u793a\u4f8b\u6c11\u653f\u90e8\u76f8\u5173\u6587\u4ef6\u6784\u5efa\u77e5\u8bc6\u5e93&#xff0c;\u4e2a\u4eba\u5148\u5728\u6c11\u653f\u90e8\u4e0b\u8f7d\u201c\u6c11\u653f\u90e82024\u5e7411\u6708\u6587\u544a\u201d\u7684PDF\u7248&#xff0c;\u901a\u8fc7python\u7a0b\u5e8f\u5c06pdf\u8f6c\u5316\u6210word,\u8f6c\u5316\u7a0b\u5e8f\u5927\u5bb6\u53ef\u4ee5\u91c7\u7528\u5728\u7ebf\u8f6c\u6362&#xff0c;\u6216\u8005WPS\u8f6c\u6362&#xff0c;\u8fd9\u91cc\u5c31\u4e0d\u505a\u7b80\u5355\u7684python\u8f6c\u5316\u7a0b\u5e8f\u5206\u4eab&#xff1b;\u5728\u5f53\u524d\u9879\u76ee\u6839\u76ee\u5f55\u4e0b&#xff0c;\u672c\u4eba\u521b\u5efa\u7684\u77e5\u8bc6\u76ee\u5f55\u540d\u79f0\u4e3aminzheng,\u5177\u4f53\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035931-688998a30e8d2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n2.\u5728\u9879\u76ee\u6839\u636e\u4e0b&#xff0c;\u5bf9minzheng\u76ee\u5f55\u521d\u59cb\u6784\u5efa\u77e5\u8bc6\u5e93\u7d22\u5f15&#xff0c;\u6267\u884c\u547d\u4ee4\u5982\u4e0b\u3002\u6ce8\u610f&#xff1a;\u6267\u884c\u73af\u5883\u4e00\u5b9a\u8981\u5728\u4e0a\u9762\u81ea\u5df1\u547d\u540d\u7684CONDA\u73af\u5883\u4e0b&#xff0c;\u672c\u9879\u76eeCONDA\u73af\u5883\u540d\u79f0\u4e3agraphrag,\u5426\u5219\u6267\u884c\u62a5\u9519\u3002<\/p>\n<p>graphrag init <span class=\"token parameter variable\">&#8211;root<\/span> .\/minzheng<\/p>\n<p>\u6267\u884c\u5b8c\u6210\u4e4b\u540e&#xff0c;\u8fdb\u5165minzheng\u76ee\u5f55&#xff0c;\u4f1a\u770b\u5230graphrag\u521d\u59cb\u5316\u521b\u5efa\u7684\u76ee\u5f55\u53ca\u6587\u4ef6&#xff0c;.env\u9879\u76ee\u914d\u7f6e\u6587\u4ef6; settings.yaml\u9879\u76ee\u8fd0\u884c\u914d\u7f6e\u53ca\u4f9d\u8d56\u6587\u4ef6prompts\u9879\u76ee\u63d0\u793a\u8bcd\u5de5\u7a0b&#xff0c;\u8fd9\u4e2a\u6587\u4ef6\u5f88\u91cd\u8981&#xff0c;\u4ed6\u662f\u77e5\u8bc6\u56fe\u8c31\u6700\u6838\u5fc3\u5730\u65b9&#xff0c;\u6784\u5efa\u9879\u76ee\u7b80\u5355&#xff0c;\u4f46\u662f\u9488\u5bf9\u4e1a\u52a1\u6784\u5efa\u7b26\u5408\u4e1a\u52a1\u7684\u5de5\u4f5c\u5168\u5728\u8fd9\u91cc&#xff0c;\u4e00\u4e2a\u597d\u7684\u77e5\u8bc6\u5e93\u5c31\u770b\u4f60\u5199\u7684\u63d0\u793a\u8bcd\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035933-688998a53492a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n3.\u4fee\u6539\u5f53\u524d\u9879\u76ee\u914d\u7f6e\u6587\u4ef6.env,\u5f53\u524d\u9879\u76ee\u91c7\u7528\u672c\u5730ollama\u90e8\u7f72\u7684\u63a8\u7406\u6a21\u578b\u8fdb\u884c\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u53ca\u67e5\u8be2&#xff0c;\u90e8\u7f72\u73af\u5883\u5df2\u4fee\u6539\u6e90\u4ee3\u7801\u4e3a\u8c03\u7528\u672c\u5730&#xff0c;\u5982\u679c\u4e0d\u4fee\u6539&#xff0c;\u672c\u5730\u9700\u8981\u5728openai\u7533\u8bf7API\u5bc6\u94a5&#xff0c;\u5728\u8be5\u6587\u4ef6\u914d\u7f6e\u5373\u53ef&#xff0c;\u7531\u4e8e\u8c03\u7528\u672c\u5730vllm\u90e8\u7f72\u7684DeepSeek 32B\u63a8\u7406\u6a21\u578b&#xff0c;\u540c\u65f6\u672c\u5730\u5316\u8c03\u7528vllm\u542f\u7528api_key,\u56e0\u6b64\u672c\u914d\u7f6e\u6587\u4ef6\u53ef\u4fee\u6539\u4e3a\u6211\u8bbe\u7f6e\u7684api_key\u5373\u53ef&#xff0c;\u6211\u8bbe\u7f6e\u672c\u5730\u90e8\u7f72\u7684DeepSeek 32B\u7684api_key\u662fallanfan\u3002<br \/>\n\u4e3a\u4e86\u4e2a\u4eba\u66f4\u597d\u8bc6\u522b\u662f\u8c03\u7528\u672c\u5730&#xff0c;\u5efa\u8bae\u4fee\u6539\u914d\u7f6e\u4e3a<\/p>\n<p>GRAPHRAG_API_KEY&#061;allanfan<\/p>\n<p>\u5177\u4f53\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035935-688998a713f5a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u4fee\u6539\u597d\u540e\u6309ctrl&#043;o\u4fdd\u5b58&#xff0c;\u4fdd\u5b58\u540e\u6309ctrl&#043;c\u9000\u51fa\u5373\u53ef\u3002<\/p>\n<p>4.\u4fee\u6539\u5f53\u524d\u9879\u76ee\u914d\u7f6e\u6587\u4ef6settings.yaml,\u8be5\u6587\u4ef6\u539f\u5185\u5bb9\u5982\u4e0b\u3002<\/p>\n<p>### This config file contains required core defaults that must be set, along with a handful of common optional settings.<br \/>\n### For a full list of available settings, see https:\/\/microsoft.github.io\/graphrag\/config\/yaml\/<\/p>\n<p>### LLM settings ###<br \/>\n## There are a number of settings to tune the threading and token limits for LLM calls &#8211; check the docs.<\/p>\n<p>encoding_model: cl100k_base # this needs to be matched to your model!<\/p>\n<p>llm:<br \/>\n  api_key: ${GRAPHRAG_API_KEY} # set this in the generated .env file<br \/>\n  type: openai_chat # or azure_openai_chat<br \/>\n  model: gpt-4-turbo-preview<br \/>\n  model_supports_json: true # recommended if this is available for your model.<br \/>\n  # audience: &#034;https:\/\/cognitiveservices.azure.com\/.default&#034;<br \/>\n  # api_base: https:\/\/<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>instance<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>.openai.azure.com<br \/>\n  # api_version: 2024-02-15-preview<br \/>\n  # organization: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>organization_id<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n  # deployment_name: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>azure_model_deployment_name<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>parallelization:<br \/>\n  stagger: 0.3<br \/>\n  # num_threads: 50<\/p>\n<p>async_mode: threaded # or asyncio<\/p>\n<p>embeddings:<br \/>\n  async_mode: threaded # or asyncio<br \/>\n  vector_store:<br \/>\n    type: lancedb<br \/>\n    db_uri: &#039;output\/lancedb&#039;<br \/>\n    container_name: default<br \/>\n    overwrite: true<br \/>\n  llm:<br \/>\n    api_key: ${GRAPHRAG_API_KEY}<br \/>\n    type: openai_embedding # or azure_openai_embedding<br \/>\n    model: text-embedding-3-small<br \/>\n    # api_base: https:\/\/<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>instance<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>.openai.azure.com<br \/>\n    # api_version: 2024-02-15-preview<br \/>\n    # audience: &#034;https:\/\/cognitiveservices.azure.com\/.default&#034;<br \/>\n    # organization: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>organization_id<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    # deployment_name: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>azure_model_deployment_name<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>### Input settings ###<\/p>\n<p>input:<br \/>\n  type: file # or blob<br \/>\n  file_type: text # or csv<br \/>\n  base_dir: &#034;input&#034;<br \/>\n  file_encoding: utf-8<br \/>\n  file_pattern: &#034;.*\\\\\\\\.txt$&#034;<\/p>\n<p>chunks:<br \/>\n  size: 1200<br \/>\n  overlap: 100<br \/>\n  group_by_columns: [id]<\/p>\n<p>### Storage settings ###<br \/>\n## If blob storage is specified in the following four sections,<br \/>\n## connection_string and container_name must be provided<\/p>\n<p>cache:<br \/>\n  type: file # or blob<br \/>\n  base_dir: &#034;cache&#034;<\/p>\n<p>reporting:<br \/>\n  type: file # or console, blob<br \/>\n  base_dir: &#034;logs&#034;<\/p>\n<p>storage:<br \/>\n  type: file # or blob<br \/>\n  base_dir: &#034;output&#034;<\/p>\n<p>## only turn this on if running &#096;graphrag index&#096; with custom settings<br \/>\n## we normally use &#096;graphrag update&#096; with the defaults<br \/>\nupdate_index_storage:<br \/>\n  # type: file # or blob<br \/>\n  # base_dir: &#034;update_output&#034;<\/p>\n<p>### Workflow settings ###<\/p>\n<p>skip_workflows: []<\/p>\n<p>entity_extraction:<br \/>\n  prompt: &#034;prompts\/entity_extraction.txt&#034;<br \/>\n  entity_types: [organization,person,geo,event]<br \/>\n  max_gleanings: 1<\/p>\n<p>summarize_descriptions:<br \/>\n  prompt: &#034;prompts\/summarize_descriptions.txt&#034;<br \/>\n  max_length: 500<\/p>\n<p>claim_extraction:<br \/>\n  enabled: false<br \/>\n  prompt: &#034;prompts\/claim_extraction.txt&#034;<br \/>\n  description: &#034;Any claims or facts that could be relevant to information discovery.&#034;<br \/>\n  max_gleanings: 1<\/p>\n<p>community_reports:<br \/>\n  prompt: &#034;prompts\/community_report.txt&#034;<br \/>\n  max_length: 2000<br \/>\n  max_input_length: 8000<\/p>\n<p>cluster_graph:<br \/>\n  max_cluster_size: 10<\/p>\n<p>embed_graph:<br \/>\n  enabled: false # if true, will generate node2vec embeddings for nodes<\/p>\n<p>umap:<br \/>\n  enabled: false # if true, will generate UMAP embeddings for nodes<\/p>\n<p>snapshots:<br \/>\n  graphml: false<br \/>\n  raw_entities: false<br \/>\n  top_level_nodes: false<br \/>\n  embeddings: false<br \/>\n  transient: false<\/p>\n<p>### Query settings ###<br \/>\n## The prompt locations are required here, but each search method has a number of optional knobs that can be tuned.<br \/>\n## See the config docs: https:\/\/microsoft.github.io\/graphrag\/config\/yaml\/#query<\/p>\n<p>local_search:<br \/>\n  prompt: &#034;prompts\/local_search_system_prompt.txt&#034;<\/p>\n<p>global_search:<br \/>\n  map_prompt: &#034;prompts\/global_search_map_system_prompt.txt&#034;<br \/>\n  reduce_prompt: &#034;prompts\/global_search_reduce_system_prompt.txt&#034;<br \/>\n  knowledge_prompt: &#034;prompts\/global_search_knowledge_system_prompt.txt&#034;<\/p>\n<p>drift_search:<br \/>\n  prompt: &#034;prompts\/drift_search_system_prompt.txt&#034;<\/p>\n<p>\u4e0a\u9762\u6587\u4ef6\u6211\u4eec\u9700\u8981\u5173\u6ce8\u51e0\u4e2a\u5730\u65b9&#xff0c;\u4e00\u4e2a\u662fllm\u914d\u7f6e\u9879&#xff0c;\u4e00\u4e2a\u662fembeddings\u914d\u7f6e\u9879\u3002<\/p>\n<p>\u9996\u5148\u9488\u5bf9settings.yaml\u91cc\u9762\u7684llm\u914d\u7f6e\u4fee\u6539\u5982\u4e0b&#xff1a;<br \/>\n\u539f\u6587\u4ef6llm\u4ee3\u7801<\/p>\n<p>llm:<br \/>\n  api_key: ${GRAPHRAG_API_KEY} # set this in the generated .env file<br \/>\n  type: openai_chat # or azure_openai_chat<br \/>\n  model: gpt-4-turbo-preview<br \/>\n  model_supports_json: true # recommended if this is available for your model.<br \/>\n  # audience: &#034;https:\/\/cognitiveservices.azure.com\/.default&#034;<br \/>\n  # api_base: https:\/\/<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>instance<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>.openai.azure.com<br \/>\n  # api_version: 2024-02-15-preview<br \/>\n  # organization: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>organization_id<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n  # deployment_name: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>azure_model_deployment_name<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u4fee\u6539\u540ellm\u4ee3\u7801<\/p>\n<p>llm:<br \/>\n  api_key: ${GRAPHRAG_API_KEY} # \u53d6\u914d\u7f6e\u6587\u4ef6.env\u7684APIKey&#xff0c;\u4e0d\u8fdb\u884c\u4fee\u6539<br \/>\n  type: openai_chat # \u5f53\u524d\u53d6\u672c\u5730\u79c1\u6709\u5316\u90e8\u7f72\u7684DeepSeek 32B,DeepSeek\u5ef6\u7528openai\u534f\u8bae<br \/>\n  model: DeepSeek-R1-Distill-Qwen-32B # \u5f53\u524d\u6a21\u578b\u540d\u79f0\u66f4\u6362\u4e3a\u672c\u5730\u79c1\u5316\u90e8\u7f72\u7684deepseek 32B\u6a21\u578b\u540d\u79f0<br \/>\n  model_supports_json: true # recommended if this is available for your model.<br \/>\n  api_base: http:\/\/localhost:8001\/v1  # \u6dfb\u52a0\u672c\u5730\u5316\u6a21\u578b\u5bf9\u5916\u53d1\u5e03\u8c03\u7528\u7684\u5730\u5740,\u8be5\u5730\u5740\u586b\u5199\u81ea\u5df1\u90e8\u7f72\u7684\u5730\u5740\u5373\u53ef<br \/>\n  # audience: &#034;https:\/\/cognitiveservices.azure.com\/.default&#034;<br \/>\n  # api_base: https:\/\/<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>instance<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>.openai.azure.com<br \/>\n  # api_version: 2024-02-15-preview<br \/>\n  # organization: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>organization_id<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n  # deployment_name: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>azure_model_deployment_name<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u4fee\u6539\u540e\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035936-688998a855f3d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7b2c\u4e8c\u6b65\u9488\u5bf9settings.yaml\u91cc\u9762\u7684embeddings\u914d\u7f6e\u4fee\u6539\u5982\u4e0b&#xff1a;<br \/>\n\u539f\u6587\u4ef6embeddings\u7684\u4ee3\u7801<\/p>\n<p>embeddings:<br \/>\n  async_mode: threaded # or asyncio<br \/>\n  vector_store:<br \/>\n    type: lancedb<br \/>\n    db_uri: &#039;output\/lancedb&#039;<br \/>\n    container_name: default<br \/>\n    overwrite: true<br \/>\n  llm:<br \/>\n    api_key: ${GRAPHRAG_API_KEY}<br \/>\n    type: openai_embedding # or azure_openai_embedding<br \/>\n    model: text-embedding-3-small<br \/>\n    # api_base: https:\/\/<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>instance<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>.openai.azure.com<br \/>\n    # api_version: 2024-02-15-preview<br \/>\n    # audience: &#034;https:\/\/cognitiveservices.azure.com\/.default&#034;<br \/>\n    # organization: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>organization_id<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    # deployment_name: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>azure_model_deployment_name<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u4fee\u6539\u540eembeddings\u7684\u4ee3\u7801\u5982\u4e0b<\/p>\n<p>embeddings:<br \/>\n  async_mode: threaded # or asyncio<br \/>\n  vector_store:<br \/>\n    type: lancedb<br \/>\n    db_uri: &#039;output\/lancedb&#039;<br \/>\n    container_name: default<br \/>\n    overwrite: true<br \/>\n  llm:<br \/>\n    api_key: ollama # \u5f53\u524d\u5411\u91cf\u6a21\u578b\u4f7f\u7528\u7684\u662follama\u90e8\u7f72\u7684,ollama\u672a\u542f\u7528api_key,\u65b9\u4fbf\u8ba4\u77e5\u662f\u8c03\u7528\u672c\u5730ollama\u8fd0\u884c\u7684\u5411\u91cf\u6a21\u578b&#xff0c;\u8be5\u5904\u586b\u5199ollama<br \/>\n    type: openai_embedding # \u6a21\u578b\u5ef6\u7528openai\u7684\u5411\u91cf\u6a21\u578b\u534f\u8bae&#xff0c;\u8be5\u5904\u4e0d\u8fdb\u884c\u4fee\u6539<br \/>\n    model: nomic-embed-text  # \u672c\u9879\u76ee\u91c7\u7528\u7684\u5411\u91cf\u6a21\u578b\u540d\u79f0\u662fnomic-embed-text&#xff0c;\u8be5\u5904\u4fee\u6539\u4e3anomic-embed-text<br \/>\n    api_base: http:\/\/localhost:11434\/api # \u672c\u9879\u76ee\u8c03\u7528\u662f\u672c\u5730\u90e8\u7f72\u7684\u5411\u91cf\u6a21\u578b&#xff0c;\u8be5\u5730\u5740\u5730\u5740\u4fee\u6539\u6210\u672c\u5730\u90e8\u7f72\u63a8\u7406\u7684\u5730\u5740\u5373\u53ef<br \/>\n    # api_version: 2024-02-15-preview<br \/>\n    # audience: &#034;https:\/\/cognitiveservices.azure.com\/.default&#034;<br \/>\n    # organization: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>organization_id<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    # deployment_name: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>azure_model_deployment_name<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u4fee\u6539\u540e\u5982\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"2025-07-30qnjiyttbp14.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u4fee\u6539\u597d\u914d\u7f6e\u540e\u6309ctrl&#043;o\u4fdd\u5b58&#xff0c;\u4fdd\u5b58\u540e\u6309ctrl&#043;c\u9000\u51fa\u5373\u53ef\u3002<\/p>\n<p>5.\u5728minzheng\u76ee\u5f55\u4e0b\u521b\u5efainput\u6587\u4ef6\u5939&#xff0c;\u7528\u4e8e\u6784\u5efa\u77e5\u8bc6\u7684\u6587\u672c\u5185\u5bb9&#xff0c;\u672c\u9879\u76ee\u793a\u4f8b\u4e0a\u4f20\u5728\u6c11\u653f\u90e8\u4e0b\u8f7d\u7684\u201c\u6c11\u653f\u90e82024\u5e7411\u6708\u6587\u544a\u201d&#xff0c;\u7528\u4e8e\u6784\u5efa\u77e5\u8bc6\u5e93\u5185\u5bb9\u3002\u5177\u4f53\u8be6\u89c1\u4e0b\u56fe\u6240\u793a\u3002<br \/>\n<img decoding=\"async\" src=\"2025-07-30p2icha1pxk0.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n6.\u6784\u5efaGraphRAG\u7d22\u5f15&#xff0c;\u5728\u5f53\u524dgraphrag\u53ca\u4e0a\u9762\u5b89\u88c5\u7684\u73af\u5883\u4e0b\u6267\u884c\u6784\u5efa\u7d22\u5f15\u547d\u4ee4&#xff0c;\u7a0b\u5e8f\u4f1a\u6839\u636e\u4e0a\u9762\u914d\u7f6e\u6587\u4ef6\u81ea\u52a8\u8c03\u7528\u672c\u5730ollama\u53ca\u672c\u5730vllm\u7684\u5411\u91cf\u6a21\u578b\u53ca\u63a8\u7406\u6a21\u578b\u3002<\/p>\n<p>graphrag index <span class=\"token parameter variable\">&#8211;root<\/span> .\/minzheng <span class=\"token parameter variable\">&#8211;reporter<\/span> rich<\/p>\n<p>\u6267\u884c\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"2025-07-30plptwgdjnx5.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u6211\u63d0\u4f9b\u7684\u6570\u636e\u91cf\u4e0d\u5927&#xff0c;\u6267\u884c\u6574\u4e2a\u8fc7\u7a0b10\u5206\u949f\u4ee5\u5185\u5b8c\u6210\u3002<br \/>\n<img decoding=\"async\" src=\"2025-07-30n0fns4f55zh.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u4e0a\u56fe\u662f\u672c\u5730\u63a8\u7406\u6a21\u578b\u8fdb\u884c\u5b9e\u4f53\u53ca\u5173\u7cfb\u7684\u63d0\u53d6\u3002<\/p>\n<p>7.\u6784\u5efa\u5b8c\u6210\u7684GraphRAG\u7684\u793a\u4f8b\u9879\u76ee\u5185\u5bb9\u67e5\u8be2&#xff0c;\u4f8b\u5982&#xff1a;\u6211\u67e5\u8be2\u201c\u56f0\u5883\u513f\u7ae5\u201d\u53ca\u201c\u4e2d\u56fd\u798f\u5229\u5f69\u7968\u201d&#xff0c;\u770b\u77e5\u8bc6\u56fe\u8c31\u5982\u4f55\u51c6\u786e\u7684\u56de\u7b54\u6211\u3002<br \/>\n<img decoding=\"async\" src=\"2025-07-30smdnfxb1xpl.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-07-30anypnr5wt00.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u5269\u4e0b\u5927\u5bb6\u81ea\u5df1\u90e8\u7f72\u53ca\u6d4b\u8bd5\u5427&#xff01;\u5bf9\u4e86&#xff0c;\u5982\u679c\u4f60\u7684\u670d\u52a1\u5668GPU\u8d44\u6e90\u4e0d\u591f&#xff0c;\u53ef\u4ee5\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u4fee\u6539\u6210\u4f60\u5728\u7f51\u4e0a\u7533\u8bf7DEEPSEEK\u7684API\u5730\u5740\u53caKEY\u5373\u53ef&#xff0c;\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<p>llm:<br \/>\n  api_key: API_KEY # \u76f4\u63a5\u586b\u5199\u7533\u8bf7\u7684API_KEY,\u6216\u8005\u5728.env\u91cc\u9762\u4fee\u6539\u4e5f\u53ef\u4ee5<br \/>\n  type: openai_chat # \u5f53\u524d\u53d6\u672c\u5730\u79c1\u6709\u5316\u90e8\u7f72\u7684DeepSeek 32B,DeepSeek\u5ef6\u7528openai\u534f\u8bae<br \/>\n  model: deepseek-chat # DEEPSEEK\u4f7f\u7528\u6a21\u578b\u540d\u79f0 deepseek-chat<br \/>\n  model_supports_json: true # recommended if this is available for your model.<br \/>\n  api_base: https:\/\/api.deepseek.com  # Deepseek\u8c03\u7528\u7684\u5730\u5740,deepseek\u662f\u5ef6\u7528openai\u5730\u5740\u534f\u8bae&#xff0c;\u540e\u9762\u7684v1\/chat\/completions\u9ed8\u8ba4\u81ea\u52a8\u8865\u9f50<br \/>\n  # audience: &#034;https:\/\/cognitiveservices.azure.com\/.default&#034;<br \/>\n  # api_base: https:\/\/<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>instance<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>.openai.azure.com<br \/>\n  # api_version: 2024-02-15-preview<br \/>\n  # organization: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>organization_id<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n  # deployment_name: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>azure_model_deployment_name<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>8.\u4f7f\u7528APP\u6784\u5efaGraphRAG\u5bf9\u5916\u7684\u63a5\u53e3\u4ee3\u7801\u53ca\u793a\u4f8b\u3002<br \/>\n8.1.\u5bf9\u5916\u63a5\u53e3\u8def\u7531\u4ee3\u7801<\/p>\n<p><span class=\"token comment\">#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;#<\/span><br \/>\n<span class=\"token comment\">#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;#<\/span><br \/>\n<span class=\"token comment\">#           GraphRAG\u5bf9\u5916\u63a5\u53e3\u5e94\u7528V1.0-Allan.Fan 20250525<\/span><br \/>\n<span class=\"token comment\">#                    \u6a21\u578b\u67e5\u8be2\u6784\u5efa\u65b9\u6cd5\u5b9e\u73b0<\/span><br \/>\n<span class=\"token comment\">#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;#<\/span><br \/>\n<span class=\"token comment\">#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;#<\/span><br \/>\n<span class=\"token keyword\">import<\/span> json<br \/>\n<span class=\"token keyword\">from<\/span> datetime <span class=\"token keyword\">import<\/span> datetime<br \/>\n<span class=\"token keyword\">from<\/span> flask <span class=\"token keyword\">import<\/span> Blueprint<span class=\"token punctuation\">,<\/span> request<span class=\"token punctuation\">,<\/span> g<br \/>\n<span class=\"token keyword\">from<\/span> services<span class=\"token punctuation\">.<\/span>appquerymodeloutput_service <span class=\"token keyword\">import<\/span> get_appquerymodeloutput<br \/>\n<span class=\"token keyword\">from<\/span> flask_restx <span class=\"token keyword\">import<\/span> Api<span class=\"token punctuation\">,<\/span>Namespace<span class=\"token punctuation\">,<\/span> Resource<span class=\"token punctuation\">,<\/span> reqparse<\/p>\n<p>appquerymodeloutput_bp <span class=\"token operator\">&#061;<\/span> Blueprint<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;querymodel_bp&#039;<\/span><span class=\"token punctuation\">,<\/span> __name__<span class=\"token punctuation\">,<\/span> url_prefix<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\/app\/query\/model&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\napi <span class=\"token operator\">&#061;<\/span> Api<span class=\"token punctuation\">(<\/span>appquerymodeloutput_bp<span class=\"token punctuation\">,<\/span> doc<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\/doc&#039;<\/span><span class=\"token punctuation\">,<\/span> version<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;1.0&#039;<\/span><span class=\"token punctuation\">,<\/span> title<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\u6a21\u578b\u67e5\u8be2\u63a5\u53e3\u6587\u6863&#039;<\/span><span class=\"token punctuation\">,<\/span> description<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\u5173\u4e8e\u4f01\u4e1a\u6a21\u578b\u6587\u6863\u8bf4\u660e&#039;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><br \/>\n<span class=\"token comment\"># \u521b\u5efa\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4<\/span><br \/>\n<span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><br \/>\ndefault_ns <span class=\"token operator\">&#061;<\/span> Namespace<span class=\"token punctuation\">(<\/span><br \/>\n    name<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    path<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    description<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\u6a21\u578b\u67e5\u8be2\u63a5\u53e3\u6587\u6863&#034;<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><br \/>\napi<span class=\"token punctuation\">.<\/span>add_namespace<span class=\"token punctuation\">(<\/span>default_ns<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span><br \/>\n<span class=\"token comment\"># \u53c2\u6570\u89e3\u6790\u5668<\/span><br \/>\n<span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span><br \/>\nparser <span class=\"token operator\">&#061;<\/span> reqparse<span class=\"token punctuation\">.<\/span>RequestParser<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\nparser<span class=\"token punctuation\">.<\/span>add_argument<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;query&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">type<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">,<\/span> default<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;&#039;<\/span><span class=\"token punctuation\">,<\/span> required<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">,<\/span><br \/>\n                    <span class=\"token builtin\">help<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\u5411\u4f01\u4e1a\u6a21\u578b\u63d0\u51fa\u95ee\u9898&#039;<\/span><span class=\"token punctuation\">,<\/span> location<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;args&#039;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token decorator annotation punctuation\">&#064;appquerymodeloutput_bp<span class=\"token punctuation\">.<\/span>before_request<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">before_request<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    g<span class=\"token punctuation\">.<\/span>client_ip <span class=\"token operator\">&#061;<\/span> request<span class=\"token punctuation\">.<\/span>headers<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;X-Forwarded-For&#039;<\/span><span class=\"token punctuation\">,<\/span> request<span class=\"token punctuation\">.<\/span>remote_addr<span class=\"token punctuation\">)<\/span>   <\/p>\n<p><span class=\"token decorator annotation punctuation\">&#064;default_ns<span class=\"token punctuation\">.<\/span>route<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;\/output&#039;<\/span><span class=\"token punctuation\">,<\/span>methods<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;GET&#039;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name\">AppQueryModelOutput<\/span><span class=\"token punctuation\">(<\/span>Resource<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token decorator annotation punctuation\">&#064;default_ns<span class=\"token punctuation\">.<\/span>expect<\/span><span class=\"token punctuation\">(<\/span>parser<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;\u4f01\u4e1a\u6a21\u578b\u5e94\u7528&#034;&#034;&#034;<\/span><br \/>\n        args <span class=\"token operator\">&#061;<\/span> parser<span class=\"token punctuation\">.<\/span>parse_args<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> args<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;query&#039;<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#039;code&#039;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">400<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;msg&#039;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#039;\u63d0\u51fa\u95ee\u9898\u4e0d\u80fd\u4e3a\u7a7a&#039;<\/span><span class=\"token punctuation\">}<\/span><\/p>\n<p>        query <span class=\"token operator\">&#061;<\/span> args<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;query&#039;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n        <span class=\"token keyword\">print<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>datetime<span class=\"token punctuation\">.<\/span>now<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>strftime<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;%Y-%m-%d %H:%M:%S&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">  query: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>query<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> query<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;success&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token boolean\">False<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;message&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;\u63d0\u51fa\u95ee\u9898\u4e0d\u80fd\u4e3a\u7a7a!&#034;<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">400<\/span><br \/>\n        <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            istrue<span class=\"token punctuation\">,<\/span>querymodeloutput_data <span class=\"token operator\">&#061;<\/span> get_appquerymodeloutput<span class=\"token punctuation\">(<\/span>query<span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> istrue<span class=\"token punctuation\">:<\/span><br \/>\n                <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;success&#034;<\/span><span class=\"token punctuation\">:<\/span> istrue<span class=\"token punctuation\">,<\/span><span class=\"token string\">&#034;message&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;\u6a21\u578b\u8bf7\u6c42\u5904\u7406\u6210\u529f&#034;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#034;data&#034;<\/span><span class=\"token punctuation\">:<\/span> querymodeloutput_data<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">200<\/span><br \/>\n            <span class=\"token keyword\">else<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;success&#034;<\/span><span class=\"token punctuation\">:<\/span> istrue<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;message&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u6a21\u578b\u8bf7\u6c42\u5904\u7406\u5931\u8d25!&#034;<\/span><\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;data&#034;<\/span><span class=\"token punctuation\">:<\/span> querymodeloutput_data<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">200<\/span><br \/>\n        <span class=\"token keyword\">except<\/span>  Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;success&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token boolean\">False<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;message&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">500<\/span> <\/p>\n<p>8.2.GraphRAG\u83b7\u53d6\u67e5\u8be2\u95ee\u9898\u540e\u8fdb\u884c\u68c0\u7d22\u7684\u4e1a\u52a1\u4ee3\u7801\u3002<\/p>\n<p><span class=\"token comment\">#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;#<\/span><br \/>\n<span class=\"token comment\">#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;#<\/span><br \/>\n<span class=\"token comment\">#           GraphRAG\u5bf9\u5916\u63a5\u53e3\u5e94\u7528V1.0-Allan.Fan 20250525<\/span><br \/>\n<span class=\"token comment\">#                    \u6a21\u578b\u67e5\u8be2\u76f8\u5173API\u65b9\u6cd5\u5b9e\u73b0<\/span><br \/>\n<span class=\"token comment\">#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;#<\/span><br \/>\n<span class=\"token comment\">#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;#<\/span><br \/>\n<span class=\"token keyword\">import<\/span> subprocess<br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">get_appquerymodeloutput<\/span><span class=\"token punctuation\">(<\/span>query<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    result <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    taskoneoutput <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token string\">&#034;msg&#034;<\/span><span class=\"token punctuation\">:<\/span><span class=\"token boolean\">None<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token string\">&#034;count&#034;<\/span><span class=\"token punctuation\">:<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token string\">&#034;data&#034;<\/span><span class=\"token punctuation\">:<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        command <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;graphrag&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;query&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;&#8211;root&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;\/home\/allanfan\/code\/graphrag\/minzheng&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;&#8211;method&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;global&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;&#8211;query&#039;<\/span><span class=\"token punctuation\">,<\/span> query<span class=\"token punctuation\">]<\/span><br \/>\n        result <span class=\"token operator\">&#061;<\/span> subprocess<span class=\"token punctuation\">.<\/span>run<span class=\"token punctuation\">(<\/span>command<span class=\"token punctuation\">,<\/span> capture_output<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">,<\/span> text<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        taskoneoutput<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;data&#034;<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> result<span class=\"token punctuation\">.<\/span>stdout<br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">True<\/span><span class=\"token punctuation\">,<\/span>taskoneoutput<br \/>\n    <span class=\"token keyword\">except<\/span>  Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">False<\/span><span class=\"token punctuation\">,<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">)<\/span><\/p>\n<p>\u5907\u6ce8&#xff1a;\/home\/allanfan\/code\/graphrag\/minzheng\u8fd9\u4e2a\u5730\u5740\u662f\u4e0a\u9762\u6784\u5efa\u77e5\u8bc6\u56fe\u8c31\u5185\u5bb9\u7684\u5728\u670d\u52a1\u5668\u7684\u7edd\u5bf9\u5730\u5740&#xff0c;\u8bf7\u4fee\u6539\u6210\u81ea\u5df1\u7684\u670d\u52a1\u5668\u6784\u5efa\u7684\u9879\u76ee\u7edd\u5bf9\u5730\u5740\u5373\u53ef&#xff0c;\u4e0a\u9762\u662f\u6211\u793a\u4f8b\u9879\u76ee\u5728\u670d\u52a1\u5668\u7684\u7edd\u5bf9\u5730\u5740\u4f4d\u7f6e\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fGraphRAG\u4ece\u73af\u5883\u90e8\u7f72&#xff0c;\u52a0\u8f7d\u672c\u5730\u5411\u91cf\u6a21\u578b\u3001\u672c\u5730\u63a8\u7406\u6a21\u578b\u3001\u7b80\u5355\u7684\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u7b80\u5355\u7684\u5bf9\u5916API\u63a5\u53e3\u5f00\u53d1&#xff1b;\u5269\u4e0b\u6700\u590d\u6742\u7684\u5c31\u662f\u77e5\u8bc6\u56fe\u8c31\u7684\u5b9e\u4f53\u3001\u5173\u7cfb\u5982\u4f55\u6839\u636e\u4e1a\u52a1\u6784\u5efa&#xff0c;\u4ee5\u53ca\u68c0\u7d22\u7684\u6570\u636e\u53ec\u56de\u7387\u7ba1\u7406&#xff0c;\u68c0\u7d22\u6570\u636e\u901f\u5ea6\u53ca\u51c6\u786e\u7387\u7684\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa&#xff0c;\u8fd9\u4e2a\u662f\u9664\u6280\u672f\u4e4b\u5916\u8fd8\u8981\u7ed3\u5408\u4e1a\u52a1\u53bb\u6574\u5408\u53d1\u5c55\u3002\u5e0c\u671b\u4e0a\u9762\u7684GraphRAG\u80fd\u591f\u5728\u4e1a\u52a1\u4e2d\u5e2e\u52a9\u81f3\u5927\u5bb6&#xff1b;\u5982\u679c\u80fd\u591f\u5e2e\u52a9\u5230\u4f60\u4e00\u70b9&#xff0c;\u4e5f\u5e0c\u671b\u4f60\u591a\u652f\u6301\u652f\u6301\u6211&#xff0c;\u7ed9\u6211\u591a\u70b9\u51fb\u53ca\u6536\u85cf&#xff1b;\u4e5f\u671f\u671b\u4f60\u7684\u5173\u6ce8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e36\u6b21\uff0c\u6536\u85cf17\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u57284\u53614090\u670d\u52a1\u5668\u4e0a\u90e8\u7f72GraphRAG\u73af\u5883\u7684\u8fc7\u7a0b\u3002\u786c\u4ef6\u914d\u7f6e\u5305\u62ec\u53cc\u8def\u81f3\u5f3a\u91d1\u724c6148\u5904\u7406\u5668\u3001128GB\u5185\u5b58\u548c4\u57574090\u663e\u5361\u3002\u521b\u5efaPython3.10\u865a\u62df\u73af\u5883\u3001\u5b89\u88c5GraphRAG 0.5.0\u53ca\u76f8\u5173\u4f9d\u8d56\u5305\uff0c\u4ee5\u53ca\u4fee\u6539\u6e90\u4ee3\u7801\u4ee5\u652f\u6301\u672c\u5730ollama\u5411\u91cf\u6a21\u578b\u548cvllm\u63a8\u7406\u6a21\u578b\u3002\u91cd\u70b9\u8bf4\u660e\u4e86\u5982\u4f55\u4fee\u6539openai_embeddings_llm.py\u548cembedding.py\u6587\u4ef6\uff0c\u5c06\u539fOpenAI\u63a5\u53e3\u66ff\u6362\u4e3a\u672c\u5730ollama\u63a5\u53e3\uff0c\u5b9e\u73b0\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u548c\u672c\u5730\u5927\u6a21\u578b\u63a8\u7406\u7684\u65e0\u7f1d\u63a5\u5165\u3002\u9002\u7528\u4e8e\u9700\u8981\u6570\u636e\u4fdd\u5bc6\u7684\u4f01\u4e1a\u73af\u5883._graphrag 0.5.0<\/p>\n","protected":false},"author":2,"featured_media":48444,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[66,3651,346,347,126,4119,50,43,613],"topic":[],"class_list":["post-48464","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-ai","tag-deep-learning","tag-embedding","tag-llama","tag-ollama","tag-rag","tag-50","tag-43","tag-613"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528 - \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\/48464.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e36\u6b21\uff0c\u6536\u85cf17\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u57284\u53614090\u670d\u52a1\u5668\u4e0a\u90e8\u7f72GraphRAG\u73af\u5883\u7684\u8fc7\u7a0b\u3002\u786c\u4ef6\u914d\u7f6e\u5305\u62ec\u53cc\u8def\u81f3\u5f3a\u91d1\u724c6148\u5904\u7406\u5668\u3001128GB\u5185\u5b58\u548c4\u57574090\u663e\u5361\u3002\u521b\u5efaPython3.10\u865a\u62df\u73af\u5883\u3001\u5b89\u88c5GraphRAG 0.5.0\u53ca\u76f8\u5173\u4f9d\u8d56\u5305\uff0c\u4ee5\u53ca\u4fee\u6539\u6e90\u4ee3\u7801\u4ee5\u652f\u6301\u672c\u5730ollama\u5411\u91cf\u6a21\u578b\u548cvllm\u63a8\u7406\u6a21\u578b\u3002\u91cd\u70b9\u8bf4\u660e\u4e86\u5982\u4f55\u4fee\u6539openai_embeddings_llm.py\u548cembedding.py\u6587\u4ef6\uff0c\u5c06\u539fOpenAI\u63a5\u53e3\u66ff\u6362\u4e3a\u672c\u5730ollama\u63a5\u53e3\uff0c\u5b9e\u73b0\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u548c\u672c\u5730\u5927\u6a21\u578b\u63a8\u7406\u7684\u65e0\u7f1d\u63a5\u5165\u3002\u9002\u7528\u4e8e\u9700\u8981\u6570\u636e\u4fdd\u5bc6\u7684\u4f01\u4e1a\u73af\u5883._graphrag 0.5.0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/48464.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-30T03:59:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035918-6889989651256.png\" \/>\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=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/48464.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/48464.html\",\"name\":\"4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-30T03:59:38+00:00\",\"dateModified\":\"2025-07-30T03:59:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/48464.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/48464.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/48464.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528\"}]},{\"@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":"4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528 - \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\/48464.html","og_locale":"zh_CN","og_type":"article","og_title":"4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e36\u6b21\uff0c\u6536\u85cf17\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u57284\u53614090\u670d\u52a1\u5668\u4e0a\u90e8\u7f72GraphRAG\u73af\u5883\u7684\u8fc7\u7a0b\u3002\u786c\u4ef6\u914d\u7f6e\u5305\u62ec\u53cc\u8def\u81f3\u5f3a\u91d1\u724c6148\u5904\u7406\u5668\u3001128GB\u5185\u5b58\u548c4\u57574090\u663e\u5361\u3002\u521b\u5efaPython3.10\u865a\u62df\u73af\u5883\u3001\u5b89\u88c5GraphRAG 0.5.0\u53ca\u76f8\u5173\u4f9d\u8d56\u5305\uff0c\u4ee5\u53ca\u4fee\u6539\u6e90\u4ee3\u7801\u4ee5\u652f\u6301\u672c\u5730ollama\u5411\u91cf\u6a21\u578b\u548cvllm\u63a8\u7406\u6a21\u578b\u3002\u91cd\u70b9\u8bf4\u660e\u4e86\u5982\u4f55\u4fee\u6539openai_embeddings_llm.py\u548cembedding.py\u6587\u4ef6\uff0c\u5c06\u539fOpenAI\u63a5\u53e3\u66ff\u6362\u4e3a\u672c\u5730ollama\u63a5\u53e3\uff0c\u5b9e\u73b0\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u548c\u672c\u5730\u5927\u6a21\u578b\u63a8\u7406\u7684\u65e0\u7f1d\u63a5\u5165\u3002\u9002\u7528\u4e8e\u9700\u8981\u6570\u636e\u4fdd\u5bc6\u7684\u4f01\u4e1a\u73af\u5883._graphrag 0.5.0","og_url":"https:\/\/www.wsisp.com\/helps\/48464.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-30T03:59:38+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730035918-6889989651256.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/48464.html","url":"https:\/\/www.wsisp.com\/helps\/48464.html","name":"4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-30T03:59:38+00:00","dateModified":"2025-07-30T03:59:38+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/48464.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/48464.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/48464.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"4\u53614090\u670d\u52a1\u5668GraphRAG\u73af\u5883\u90e8\u7f72\u3001\u52a0\u8f7dollama\u5411\u91cf\u6a21\u578b\u53ca\u5411\u91cf\u77e5\u8bc6\u56fe\u8c31\u6784\u5efa\u3001\u52a0\u8f7dvllm\u672c\u5730DeepSeek 32B\u63a8\u7406\u6a21\u578b\u65e0\u7f1d\u63a5\u5165\u53caAPI\u63a5\u53e3\u8c03\u7528"}]},{"@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\/48464","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=48464"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/48464\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/48444"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=48464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=48464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=48464"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=48464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}