GraphRAG+本地部署模型

记录GraphRAG + 本地部署模型

GraphRAG 安装

非常的简单 跟着官方文档即可

LMStudio方案(失败)

没有成功

模型和embedding模型的端口一样都是到v1结尾的端口

模型名称 到GGUF结尾的文件夹

但是最后在关系汇总阶段出错,我怀疑是因为这个电脑的GPU不是英伟达显卡

OLlama方案(成功)

ollama部署

OLlmama和LMStudio属于是竞品关系

这次我把OLlama部署在了服务器

https://github.com/ollama/ollama

ollama常用命令

计算机上已下载的模型

1
ollama list

启动 Ollama

1
ollama serve

进程

1
ollama ps

Graphrag-Local-Ollama——rga和ollama适配后的项目

https://github.com/TheAiSingularity/graphrag-local-ollama

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
初始化目录
mkdir -p ./ragtest/input

复制示例输入
cp input/* ./ragtest/input

初始化配置文件
python -m graphrag.index --init --root ./ragtest

修改配置文件后,建立图索引
python -m graphrag.index --root ./ragtest

仅支持全局查询
python -m graphrag.query --root ./ragtest --method global "What is machinelearning?"


局部查询可以对项目进行进一步的修改

尝试记录

  • 配置 llama3 nojson maxToken:2000

    ❌ create_final_community_reports

  • 配置 llama3 json maxToken:2000

    🚀 All workflows completed successfully.

    但是仍然不知道为什么llama3 nojson为什么不行

Ollama modelfile自定义模型

先创建一个文件名xx.modelfile

然后填入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FROM llama3.1

# sets the temperature to 1 [higher is more creative, lower is more coherent]

PARAMETER temperature 0.3

# sets the context window size to 4096, this controls how many tokens the LLM can use as context to generate the next token

#PARAMETER num_ctx 4096



# sets a custom system message to specify the behavior of the chat assistant

#SYSTEM You are Mario from super mario bros, acting as an assistant.

运行命令创建模型

1
ollama create myllama3 --file myllama3.modelfile

可视化图文件

需要修改配置文件中的

可视化

在根目录创建脚本

1
2
3
4
from pygraphml import GraphMLParser
parser = GraphMLParser()
g = parser.parse("./graphrag-local-ollama/ragtest/output/***/artifacts/summarized_graph.graphml")
g.show()

但是我发现有更好的方案

https://noworneverev.github.io/graphrag-visualizer/

选择到output的节点文件夹即可

参考博客

https://developer.aliyun.com/article/1575047

不同模型的回答对比

qwen

Machine Learning refers to a subset of artificial intelligence that enables systems to learn and improve from experience without explicit programming [Data: Reports (1)]. It is primarily used for statistical analysis, data analysis, and prediction.

One type of machine learning algorithm, Convolutional Neural Networks (CNNs), are particularly effective in processing grid-like data such as images [Data: Reports (1)]. They are widely employed in various fields including Medical Imaging, Autonomous Vehicles, Natural Language Processing, Video Analysis, and Facial Recognition Systems.

In the field of Medical Imaging, CNNs have led to improved diagnostic accuracy and reduced human error by analyzing X-rays, MRIs, and CT scans [Data: Reports (1)]. In Autonomous Vehicles, CNNs are used for tasks like lane detection and obstacle recognition, which could significantly reduce accidents caused by human error, making roads safer [Data: Reports (1)].

However, concerns about privacy and security persist as autonomous vehicles collect vast amounts of data. Similarly, the use of CNNs in various applications raises privacy concerns due to the potential for mass surveillance [Data: Reports (+more)]. It is crucial to address these issues to ensure the responsible use of this technology.

llama3.1

:Machine Learning: A Subset of Artificial Intelligence

Machine learning is a subset of artificial intelligence (AI) that involves training algorithms on data to enable them to make predictions or decisions without being explicitly programmed.

Key Characteristics

Machine learning can be used for tasks such as image and speech recognition, natural language processing, and predictive analytics. It has several key characteristics:

  • Data-driven: Machine learning models are trained on large datasets to learn patterns and relationships.
  • Algorithmic: Machine learning algorithms are designed to make predictions or decisions based on the data they’ve been trained on.
  • Adaptive: Machine learning models can adapt to new data and improve their performance over time.

Applications

Machine learning has a wide range of applications, including:

  • Image recognition: Machine learning algorithms can be used to recognize objects in images, such as faces or products.
  • Speech recognition: Machine learning algorithms can be used to transcribe spoken language into text.
  • Predictive analytics: Machine learning algorithms can be used to make predictions about future events or trends.

Data References

Machine learning is a powerful tool for analyzing and making decisions based on data. Some relevant data references include:

  • Reports (1, 3)
  • Entities (35)

GraphRAG+本地部署模型
https://the-uyu.github.io/2024/09/12/记录-GraphRAG-本地部署模型/
作者
uyu
发布于
2024年9月12日
许可协议