75% 成本和时间削减:优化微软 GraphRAG 索引的秘密
75% 成本和时间削减:优化微软 GraphRAG 索引的秘密
2024年9月4日修改
作者:还就可 | 深入LLM Agent应用开发
书接上回《 实战微软新一代RAG:GraphRAG强大的全局理解能力,碾压朴素RAG? 》,想必大家都知道我最近在测试GraphRAG,由于其惊人的理解能力,我一直在探索。当然遇到的问题也比较多,比如community_reports不生效,tokens per minute和requests per minute不生效,全局搜索经常JSONDecodeError,以及高昂的成本和时间。这4个问题,我提交了4个PR去修复。本篇将围绕这4个问题和PR说明,最主要的是如何大幅降低成本和时间进行说明,修改很简单,但是精度上升了。
1. 社区报告配置失效
因为社区报告通常总结内容较大,如果配置的全局llm的context windows较小的话,在community reports阶段可能会失败。因此我在settings.yaml中尝试配置覆盖全局llm。
代码块
community_report:
llm:
api_key: ${GROQ_API_KEY}
type: openai_chat # or azure_openai_chat
model: qwen2:72b
model_supports_json: false # recommended if this is available for your model.
api_base: http://localhost:11434/v1
max_tokens: 32768
concurrent_requests: 1 # the number of parallel inflight requests that may be made
tokens_per_minute: 15000 # set a leaky bucket throttle
requests_per_minute: 30 # set a leaky bucket throttle
top_p: 0.99
## parallelization: override the global parallelization settings for this task
## async_mode: override the global async_mode settings for this task
prompt: "prompts/community_report.txt"
max_length: 2000
max_input_length: 8000
这个配置之所以不生效是因为代码中其实采用的community_reports,而配置中缺少s。因此修改生成模板的代码,即可通过 PR [1] ,此PR已经被合并,拉取主分支使用即可。
2. TPM和RPM失效
当你如上面文档配置全局每秒的每分钟最大Token数量和每分钟最大请求时候,也会发现不生效。原因是代码中其实读取的变量是tpm和rpm,通过 PR [2] 可以修复,但是这个被其他人提前修复,因此被关闭了,拉取主分支使用即可。
附件不支持打印
加载失败,