使用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)
相关推荐
Hello.Reader16 小时前
双卡 A100 上如何给 Ollama 做轮询分发与健康检查,真正把吞吐跑满
ollama
凤山老林1 天前
Java 开发者零成本上手:用 Spring AI Alibaba + Ollama 本地跑通 DeepSeek 大模型
java·人工智能·ollama·deepseek·spring ai 阿里巴巴
诸神缄默不语2 天前
本地LLM部署工具(写给小白的LLM工具选型系列:第一篇)
llm·大规模预训练语言模型·vllm·ollama
福大大架构师每日一题3 天前
ollama v0.19.0 发布!Web 搜索插件上线、多模型兼容修复、MLX 与 KV 缓存全面优化,本地大模型体验再升级
缓存·ollama
AAA阿giao4 天前
打造你的 Git 提交 AI 神器:从零实现前后端分离的 Commit Message 生成器
react.js·express·ollama
村中少年5 天前
vscode如何添加ollama本地模型-实现token自由
vscode·llm·token·ollama·本地模型·qwen3
竹之却7 天前
【OpenClaw】云服务器端 openclaw 集成本地 Windows端 ollama 模型
windows·llama·ollama·openclaw·qwen3.5
加斯顿工程师7 天前
Windows系统使用Ollama本地化部署Qwen3.5-9B模型教程
windows·大模型·本地部署·ollama·qwen3.5
chenhua7 天前
openclaw基于飞书群聊中减少机器人大模型调用次数
飞书·ollama·群聊·本地小模型·多agent·openclaw
brucelee18610 天前
Debian 安装 Ollama 教程
debian·ollama·open claw