Inserting a multi-part document results in duplicate nodes and edges
I want to convert a long document into a Lightrage knowledge base. If I convert the entire document directly, one error will lead to a total failure. For the purpose of risk control, the document is divided into multiple parts and insert is performed separately. From the result data, it is found that there are a lot of duplications in nodes and edges.
After investigation, the reason is in the relevant code below.
LightRAG will merge nodes and edges with the same name when executing insert; but this is only valid for the same execution of _process_single_content. If you insert multiple documents like I did, the results will not be merged.
https://github.com/HKUDS/LightRAG/blob/874f3b392b959877756bf4828d698fcb53b9c7c9/lightrag/operate.py#L391
@jin38324 Hi, have you solved this issue? I want to process multiple documents individually and merge the duplicated nodes or edges into one knowledge graph.
@jin38324 Hi, have you solved this issue? I want to process multiple documents individually and merge the duplicated nodes or edges into one knowledge graph.
I dug deeper into the code and found that the problem was not from _merge_nodes_then_upsert.
The problem was caused by the data storage part from kg, which set too strict constraints when trying to get existing objects, resulting in the inability to find existing objects, so an insert was performed.
So, if you use the default storage, there should be no problem.
The problem was not from _merge_nodes_then_upsert. The problem was caused by the data storage part from kg, which set too strict constraints when trying to get existing objects, resulting in the inability to find existing objects, so an insert was performed.
Hi @jin38324 I'm using Neo4j as my graph database and working with large documents that need to be split and processed. I wanted to know: Will similar entities and relationships be merged automatically, or do I need to configure something for that? Also, if for default LightrAG storage, it handle merging of entities across multiple documents automatically right? Could you please explain how this works?