使用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)
相关推荐
大模型真好玩4 天前
大模型训练全流程实战指南实战篇(十四)——网络安全大模型数据获取
人工智能·ollama·deepseek
蜡台4 天前
本地搭建 AI 大模型完整实战指南(2026)
人工智能·ollama
lee_curry7 天前
Dify+Ollama私有化部署方案
ai大模型·dify·ollama
蛋先生DX7 天前
大模型本地部署神器的瘦身进阶原理,就这两招?
llm·llama·ollama
O。O蛋黄酥啊7 天前
GraphRAG 和 LightRAG 详解与对比
人工智能·python·算法·rag·graphrag·lightrag
geminigoth8 天前
LangChain1.2学习第二章—— 调用大模型
ollama·本地部署大模型·deepseek接口·qwen接口·langchain调用大模型·阻塞大模型接口·非阻塞大模型接口
weixin_471383038 天前
25 Ollama 本地部署
ollama
FriendshipT8 天前
DeepSeek Harness 使用 Ollama 本地部署的 AI 大模型(以Qwen3.8-27B为例)
人工智能·pytorch·深度学习·ollama·deepseek
uncle_ll9 天前
多模态大模型视听生成本地实战
llm·文生图·文生视频·多模态·ollama
Moon上有月亮10 天前
Ollama 完全指南:本地大语言模型的“开箱即用”方案
人工智能·语言模型·自然语言处理·ollama