GraphRAG 1.0重磅升级!颠覆传统RAG!DRIFT搜索+Update命令!整合LM Studio本地大模型实现高效RAG!MarkItDown将PDF转为markdown!性能提升3倍

AI超元域
7 min readDec 20, 2024

--

🔥🔥🔥本篇笔记所对应的视频:https://youtu.be/GRZ2th6s7uY

✅突破传统RAG限制!整合本地大模型实现高效RAG,解析微软最新知识图谱检索技术,详解GraphRAG 1.0+本地大模型部署方案,整合MarkItDown实现PDF智能问答

✅本期视频详细演示了如何使用GraphRAG 1.0结合本地开源大模型和嵌入模型,快速实现检索增强生成:

安装GraphRAG

git clone <https://github.com/microsoft/graphrag.git>
cd graphragpip install .

GGUF

https://huggingface.co/nomic-ai/nomic-embed-text-v1.5-GGUF

llama.cpp

brew install llama.cpp
llama-server -m /Users/charlesqin/Downloads/nomic-embed-text-v1.5.Q5_K_M.gguf --embedding -c 512 -ngl 1llama-server -m /Users/charlesqin/Downloads/nomic-embed-text-v1.5.Q5_K_M.gguf --embedding --pooling cls -ub 8192# model: nomic-embed-text-v1.5# api_base: <http://127.0.0.1:8080/v1>### test command
curl -X POST <http://localhost:8080/embedding> -d '{"content": "Your text here"}'
# LLM
llama-server -m /Users/charlesqin/Downloads/Phi-3.1-mini-128k-instruct-Q5_K_M.gguf --port 8080
#<http://localhost:8080/v1># test api
curl <http://localhost:11434/v1/chat/completions> \\
-H "Content-Type: application/json" \\
-d '{
"model": "mistral-nemo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'

MarkItDown

MarkItDown是一个功能强大的文件格式转换工具,可以将多种格式的文件转换为Markdown格式。

支持的输入格式

  • PowerPoint/PPTX文件
  • Excel/XLSX文件
  • Word/DOCX文件
  • 图片(支持EXIF元数据和OCR识别)
  • 音频(支持EXIF元数据和语音转写)
  • HTML(特别支持Wikipedia等网站)
  • 其他文本格式如CSV、JSON、XML等

智能转换能力

  • 对于图片文件,使用AI进行OCR识别和内容理解
  • 对于音频文件,可以通过AI进行语音转写
  • 支持通过大语言模型对图片内容进行描述
# 安装
pip install markitdown
# zhuan
markitdown GPT.pdf > ./ragtest/input/book.txt

🔥🔥🔥如有问题,请联系我的徽信 stoeng

🔥🔥🔥本项目代码由AI超元域频道制作,观看更多大模型微调视频请访问我的频道⬇

👉👉👉我的哔哩哔哩频道

👉👉👉我的YouTube频道

**👉👉👉我的开源项目 https://github.com/win4r/AISuperDomain**

充值openai api key或者ChatGPT会员可以使用wildcard虚拟卡充值。wildcard官方链接:

https://bewildcard.com/i/VLM

wildcard注册教程和充值API教程(国内打开速度快):

https://mp.weixin.qq.com/s?__biz=MzU0NDc2MzQ3MA==&mid=2247484020&idx=1&sn=fee448a207cbf3b4ccda8a775f4fe946&chksm=fb767955cc01f043b9e4a5ae926c2e68cefc0ee12af9df715eb632a90003784c45e2108470f1#rd

wildcard注册教程和充值API教程(海外打开速度快):

**https://stoeng.medium.com/保姆级教程-通过wildcard虚拟信用卡订阅chatgpt-claude会员和api-百分百可用-a2865a18df01**

GraphRAG

cd ../
mkdir -p ./ragtest/inputgraphrag init --root ./ragtestgraphrag index --root ./ragtest
graphrag query \\
--root ./ragtest \\
--method local \\
--query "Provide some examples of the Self-Consistency Prompt?"
graphrag query \\
--root ./ragtest \\
--method drift \\
--query "Provide some examples of the Seed-word Prompt?"
graphrag query \\
--root ./ragtest \\
--method local \\
--query "show me some examples of the Instructions Prompt Technique"
graphrag query \\
--root ./ragtest \\
--method global \\
--query "Provide some examples of the Seed-word Prompt?"

update

graphrag update \\
--config PATH \\ # Path to your configuration file
--root PATH \\ # Project root directory (defaults to current directory '.')
--verbose \\ # Enable verbose logging (default is --no-verbose)
--memprofile \\ # Enable memory profiling (default is --no-memprofile)
--logger [rich|print|none] \\ # Choose logger type (default is 'rich')
--cache \\ # Use LLM cache (default is --cache)
--skip-validation \\ # Skip preflight validation (default is --no-skip-validation)
--output PATH # Directory for output (overrides storage.base_dir in config)
graphrag update --config ragtest/settings.yaml --root . --verbose --memprofile --logger print --cache --skip-validation --output ragtest/output

--

--

No responses yet