使用ollama取代openai的api进行graphRAG失败记录

pip install ollama

pip install langchain_ollama

graph_documents = llm_transformer.convert_to_graph_documents(split_documents)

print(graph_documents)

偶尔会成功,但是大部分是失败的:

报错记录如下,暂时没想到好的办法:

python 复制代码
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Cell In[64], line 2
      1 # Transform documents to graph documents
----> 2 graph_documents = llm_transformer.convert_to_graph_documents(split_documents)
      3 print(graph_documents)

File D:\anaconda3\envs\graphRAG\lib\site-packages\langchain_experimental\graph_transformers\llm.py:762, in LLMGraphTransformer.convert_to_graph_documents(self, documents)
    750 def convert_to_graph_documents(
    751     self, documents: Sequence[Document]
    752 ) -> List[GraphDocument]:
    753     """Convert a sequence of documents into graph documents.
    754 
    755     Args:
   (...)
    760         Sequence[GraphDocument]: The transformed documents as graphs.
    761     """
--> 762     return [self.process_response(document) for document in documents]

File D:\anaconda3\envs\graphRAG\lib\site-packages\langchain_experimental\graph_transformers\llm.py:762, in <listcomp>(.0)
    750 def convert_to_graph_documents(
    751     self, documents: Sequence[Document]
    752 ) -> List[GraphDocument]:
    753     """Convert a sequence of documents into graph documents.
    754 
    755     Args:
   (...)
    760         Sequence[GraphDocument]: The transformed documents as graphs.
    761     """
--> 762     return [self.process_response(document) for document in documents]

File D:\anaconda3\envs\graphRAG\lib\site-packages\langchain_experimental\graph_transformers\llm.py:718, in LLMGraphTransformer.process_response(self, document)
    715     nodes_set.add((rel["tail"], rel["tail_type"]))
    717     source_node = Node(id=rel["head"], type=rel["head_type"])
--> 718     target_node = Node(id=rel["tail"], type=rel["tail_type"])
    719     relationships.append(
    720         Relationship(
    721             source=source_node, target=target_node, type=rel["relation"]
    722         )
    723     )
    724 # Create nodes list

File D:\anaconda3\envs\graphRAG\lib\site-packages\pydantic\v1\main.py:341, in BaseModel.__init__(__pydantic_self__, **data)
    339 values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
    340 if validation_error:
--> 341     raise validation_error
    342 try:
    343     object_setattr(__pydantic_self__, '__dict__', values)

ValidationError: 2 validation errors for Node
id
  none is not an allowed value (type=type_error.none.not_allowed)
type
  none is not an allowed value (type=type_error.none.not_allowed)
相关推荐
KG_LLM图谱增强大模型3 天前
突破AI助手成本壁垒:知识图谱思维架构让小模型实现大性能
人工智能·架构·大模型·知识图谱·graphrag
York·Zhang4 天前
Ollama:在本地运行大语言模型的利器
人工智能·语言模型·自然语言处理·ollama
大模型教程7 天前
30分钟内搞定!在本地电脑上部署属于你自己的大模型
llm·agent·ollama
血小溅8 天前
Spring Boot 整合 Spring AI:接入 DeepSeek 与 Ollama 调用大模型
后端·ollama·deepseek
KG_LLM图谱增强大模型9 天前
[Nature子刊]浙大SciToolAgent:用知识图谱驱动的科学智能体实现多工具集成
大模型·知识图谱·工具·科学研究·graphrag
KG_LLM图谱增强大模型17 天前
[ICAIS2025]探索LLM驱动的知识图谱构建:技术机制、方法对比与未来方向
人工智能·知识图谱·graphrag·知识图谱增强大模型
大模型教程21 天前
Windows系统本地知识库构建:Cherry Studio+Ollama
llm·agent·ollama
Qiuner21 天前
快速入门LangChain4j Ollama本地部署与阿里百炼请求大模型
语言模型·langchain·nlp·llama·ollama
applepie_max22 天前
GraphRAG本地部署 v2.7.0
python·rag·graphrag
景天科技苑22 天前
【AI智能体开发】什么是LLM?如何在本地搭建属于自己的Ai智能体?
人工智能·llm·agent·智能体·ai智能体·ollama·智能体搭建