graphrag+ollama+xinference实战部署

一、graphrag安装

conda create -n graphrag python=3.11
pip install graphrag
pip install marker-pdf
pip install ocrmypdf
pip install bs4
pip install re
pip install markdown

二、xinference安装及模型导入

1.xinference安装

conda create -n xinference python=3.11
pip install "xinference[all]" -i https://pypi.tuna.tsinghua.edu.cn/simple
# 启动命令
xinference-local

2.模型导入
进入前端页面,将本地模型转化为xinference可调用的embedding模型
在这里插入图片描述

三、ollama模型导入

ollama show --modelfile qwen2 > Modelfile

在这里插入图片描述
将导出后的Modelfile加上上述一行,增强模型的上下文能力

ollama create -f Modelfile qwen2:ctx32k

四、graphrag调用

1.测试示例

mkdir -p ./ragtest/input
curl https://www.gutenberg.org/cache/epub/24022/pg24022.txt > ./ragtest/input/book.txt
python -m graphrag.index --init --root ./ragtest

进行到此处之后ragtest文件夹下会生成output文件夹,更改其中settings.yaml中的模型配置
在这里插入图片描述

python -m graphrag.index --root ./ragtest
# 问答代码
python -m graphrag.query \
--root ./ragtest \
--method local \
"Who is Scrooge, and what are his main relationships?"

2.使用自己的文件

export HF_ENDPOINT=https://hf-mirror.com
#pdf转md
marker_single ./test.pdf ./pdf_txt --batch_multiplier 2 --max_pages 60 --langs English
#md转text
python markdown_to_text.py pdf_txt/test/test.md test.txt
mkdir -p ./ragpdf/input
cp test.txt ./ragpdf/input
python -m graphrag.index --init --root ./ragpdf
python -m graphrag.index --root ./ragpdf

五、离线化pdf转md服务

1.下载下图中模型对环境中在线模型路径进行离线化
在这里插入图片描述
2.对环境中对于的在线模型路径进行修改
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值