使用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)
相关推荐
i查拉图斯特拉如是21 小时前
搭建本地大模型知识库
人工智能·ai·大模型·知识库·ollama
小股虫1 天前
SillyTavern使用本地大模型写故事实操手册
人工智能·ai写作·ollama·本地大模型·sillytavern
runfarther2 天前
Windows下使用源码和Conda搭建GraphRAG指南
windows·conda·graphrag
天命码喽c2 天前
GraphRAG-2.7.0整合Milvus-2.5.1
开发语言·python·milvus·graphrag
七夜zippoe4 天前
使用Ollama在消费级硬件上运行大模型:从环境配置到企业级实战
性能优化·大模型·模型量化·ollama
互联网老欣5 天前
2025年保姆级教程:阿里云服务器部署Dify+Ollama,打造专属AI应用平台
服务器·阿里云·ai·云计算·dify·ollama·deepseek
wuli_滔滔7 天前
Qwen2.5、Llama 3.1轻量模型本地化部署指南:从环境配置到企业级实战
vllm·ollama·qwen2.5·llama 3.1
KG_LLM图谱增强大模型8 天前
[经典之作]大语言模型与知识图谱的融合:通往智能未来的路线图
人工智能·大模型·知识图谱·graphrag·本体论·图谱增强大模型
重整旗鼓~8 天前
2.LangChain4j+springboot+大模型整合
openai·springboot·ollama·langchain4j
用什么都重名9 天前
设置 Ollama 容器自动重启和模型自动加载的方法
人工智能·ollama·自加载