使用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)
相关推荐
liwulin05061 天前
【OLLAMA】LangGrahp调用LLM WIKI
react·ollama·llm wiki
镰刀韭菜4 天前
2026 年 10 月 Mac 本地大模型:24GB / 64GB / 128GB 怎么选
mac·qwen·apple silicon·ollama·本地llm
Jasonakeke4 天前
Ollama 装好却拉不动模型?八成是这两种病,一种缺网一种缺显存
ai编程·ollama
goehou7 天前
两台 Mac 拼成推理池,加机器不加内存
mac·集群·ollama·本地推理
底层玩家老张12 天前
一次多跳查询的复盘:图不搬出库,GraphRAG 怎么落地
知识图谱·graphrag·ai数据库·语义层·数据库内核
武雄(小星Ai)12 天前
Ollama报llama-server binary not found排坑实录:服务活着引擎没了
人工智能·windows·大模型·ollama·排坑
goehou13 天前
Ollama 的流式接口不是 SSE,客户端要改三处
sse·ollama·流式输出·客户端开发
n1121219 天前
Ollama 接 Open WebUI 中文界面:我踩的 4 个坑
云原生·eureka·ollama·本地大模型·open webui·私有部署·中文界面
一枕槐安48720 天前
开源大模型 Llama3 本地部署全过程,Ollama 上手
开源·本地部署·大模型推理·ollama·llama3·modelfile
死磕音视频22 天前
Open WebUI 入门:用 Docker 装上本地对话界面并连接 Ollama
docker·ollama·本地大模型·open webui