Open 18811449050 opened 2 months ago
Why does build_communities() report such an error?
The build_communities()
method in the GraphRAGStore
class is reporting an EmptyNetworkError
because the get_triplets()
method is returning an empty list. This indicates that no triplets are being retrieved from the graph store, leading to an empty NetworkX graph, which in turn causes the error when attempting to build communities.
Here are some potential reasons why get_triplets()
might be returning an empty list:
No Parameters Provided: The get_triplets()
method will return an empty list if none of the parameters (entity_names
, relation_names
, properties
, ids
) are provided. This is explicitly handled by the initial check in the method:
if not ids and not properties and not entity_names and not relation_names:
return []
No Matching Records: Even if parameters are provided, the method might still return an empty list if the provided parameters do not match any records in the database. For example, if the entity_names
, relation_names
, properties
, or ids
do not correspond to any existing nodes or relationships, the query will not return any results.
Database Issues: The warnings from the Neo4j DBMS server indicate that some property keys are not recognized. This could mean that the properties being queried do not exist in the database, leading to no results being returned.
To address this issue, you should:
Verify Parameters: Ensure that the parameters being passed to get_triplets()
are correct and match the data in your database.
Check Database Schema: Verify that the properties and labels being queried exist in the database. The warnings about unknown property keys suggest that there might be a mismatch between the expected schema and the actual data.
Debugging: Add logging or print statements to check the intermediate outputs and ensure that the data is being processed correctly. For example, you can print the parameters being passed to get_triplets()
and the results of the database queries.
By addressing these points, you should be able to identify why get_triplets()
is returning an empty list and resolve the EmptyNetworkError
in the build_communities()
method [1][2][3][4].
To continue talking to Dosu, mention @dosu.
I have the same problem. Have you solved it?
Bug Description
Note: There are more relationships that can be extracted from the text, but I have only provided two entity-relation triplets as per your request. Extracting paths from text: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [01:39<00:00, 9.92s/it] Generating embeddings: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1.07it/s] Generating embeddings: 0it [00:00, ?it/s] Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The procedure has a deprecated field. ('config' used by 'apoc.meta.graphSample' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: "CALL apoc.meta.graphSample() YIELD nodes, relationships RETURN nodes, [rel in relationships | {name:apoc.any.property(rel, 'type'), count: apoc.any.property(rel, 'count')}] AS relationships" index.property_graph_store: <main.GraphRAGStore object at 0x7f6b54528df0> Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: name)} {position: line: 6, column: 22, offset: 138} for query: "MATCH (e:
index.property_graph_store.build_communities()
File "/data1/mgl/llama_index_security_project/linshi_v1.py", line 190, in build_communities
community_hierarchical_clusters = hierarchical_leiden(
File "<@beartype(graspologic.partition.leiden.hierarchical_leiden) at 0x7f6b5879b940>", line 304, in hierarchical_leiden
File "/root/miniconda3/envs/llama_index_env1/lib/python3.9/site-packages/graspologic/partition/leiden.py", line 588, in hierarchical_leiden
hierarchical_clusters_native = gn.hierarchical_leiden(
leiden.EmptyNetworkError: EmptyNetworkError
__Entity__
) \n WITH e\n CALL {\n WITH e\n MATCH (e)-[r]->(t:__Entity__
)\n RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n e{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n t.name AS target_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n t{. , embedding: Null, name: Null} AS target_properties\n UNION ALL\n WITH e\n MATCH (e)<-[r]-(t:__Entity__
)\n RETURN t.name AS source_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n t{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n e.name AS target_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n e{. , embedding: Null, name: Null} AS target_properties\n }\n RETURN source_id, source_type, type, rel_properties, target_id, target_type, source_properties, target_properties" Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: name)} {position: line: 10, column: 22, offset: 417} for query: "MATCH (e:__Entity__
) \n WITH e\n CALL {\n WITH e\n MATCH (e)-[r]->(t:__Entity__
)\n RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n e{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n t.name AS target_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n t{. , embedding: Null, name: Null} AS target_properties\n UNION ALL\n WITH e\n MATCH (e)<-[r]-(t:__Entity__
)\n RETURN t.name AS source_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n t{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n e.name AS target_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n e{. , embedding: Null, name: Null} AS target_properties\n }\n RETURN source_id, source_type, type, rel_properties, target_id, target_type, source_properties, target_properties" Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: name)} {position: line: 15, column: 22, offset: 700} for query: "MATCH (e:__Entity__
) \n WITH e\n CALL {\n WITH e\n MATCH (e)-[r]->(t:__Entity__
)\n RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n e{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n t.name AS target_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n t{. , embedding: Null, name: Null} AS target_properties\n UNION ALL\n WITH e\n MATCH (e)<-[r]-(t:__Entity__
)\n RETURN t.name AS source_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n t{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n e.name AS target_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n e{. , embedding: Null, name: Null} AS target_properties\n }\n RETURN source_id, source_type, type, rel_properties, target_id, target_type, source_properties, target_properties" Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: name)} {position: line: 19, column: 22, offset: 979} for query: "MATCH (e:__Entity__
) \n WITH e\n CALL {\n WITH e\n MATCH (e)-[r]->(t:__Entity__
)\n RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n e{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n t.name AS target_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n t{. , embedding: Null, name: Null} AS target_properties\n UNION ALL\n WITH e\n MATCH (e)<-[r]-(t:__Entity__
)\n RETURN t.name AS source_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n t{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n e.name AS target_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n e{. , embedding: Null, name: Null} AS target_properties\n }\n RETURN source_id, source_type, type, rel_properties, target_id, target_type, source_properties, target_properties" 生成的三元组: [] Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: name)} {position: line: 6, column: 22, offset: 138} for query: "MATCH (e:__Entity__
) \n WITH e\n CALL {\n WITH e\n MATCH (e)-[r]->(t:__Entity__
)\n RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n e{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n t.name AS target_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n t{. , embedding: Null, name: Null} AS target_properties\n UNION ALL\n WITH e\n MATCH (e)<-[r]-(t:__Entity__
)\n RETURN t.name AS source_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n t{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n e.name AS target_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n e{. , embedding: Null, name: Null} AS target_properties\n }\n RETURN source_id, source_type, type, rel_properties, target_id, target_type, source_properties, target_properties" Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: name)} {position: line: 10, column: 22, offset: 417} for query: "MATCH (e:__Entity__
) \n WITH e\n CALL {\n WITH e\n MATCH (e)-[r]->(t:__Entity__
)\n RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n e{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n t.name AS target_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n t{. , embedding: Null, name: Null} AS target_properties\n UNION ALL\n WITH e\n MATCH (e)<-[r]-(t:__Entity__
)\n RETURN t.name AS source_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n t{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n e.name AS target_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n e{. , embedding: Null, name: Null} AS target_properties\n }\n RETURN source_id, source_type, type, rel_properties, target_id, target_type, source_properties, target_properties" Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: name)} {position: line: 15, column: 22, offset: 700} for query: "MATCH (e:__Entity__
) \n WITH e\n CALL {\n WITH e\n MATCH (e)-[r]->(t:__Entity__
)\n RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n e{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n t.name AS target_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n t{. , embedding: Null, name: Null} AS target_properties\n UNION ALL\n WITH e\n MATCH (e)<-[r]-(t:__Entity__
)\n RETURN t.name AS source_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n t{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n e.name AS target_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n e{. , embedding: Null, name: Null} AS target_properties\n }\n RETURN source_id, source_type, type, rel_properties, target_id, target_type, source_properties, target_properties" Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: name)} {position: line: 19, column: 22, offset: 979} for query: "MATCH (e:__Entity__
) \n WITH e\n CALL {\n WITH e\n MATCH (e)-[r]->(t:__Entity__
)\n RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n e{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n t.name AS target_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n t{. , embedding: Null, name: Null} AS target_properties\n UNION ALL\n WITH e\n MATCH (e)<-[r]-(t:__Entity__
)\n RETURN t.name AS source_id, [l in labels(t) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS source_type,\n t{. , embedding: Null, name: Null} AS source_properties,\n type(r) AS type,\n r{.} AS rel_properties,\n e.name AS target_id, [l in labels(e) WHERE NOT l IN ['Entity', 'Node'] | l][0] AS target_type,\n e{. , embedding: Null, name: Null} AS target_properties\n }\n RETURN source_id, source_type, type, rel_properties, target_id, target_type, source_properties, target_properties" Traceback (most recent call last): File "/data1/mgl/llama_index_security_project/linshi_v1.py", line 451, inVersion
stable
Steps to Reproduce
I checked the intermediate output. In the response_str in the parse_fn method, I found that there are entities and relationships, but in index.property_graph_store.get_triplets() it is empty. Why?
Relevant Logs/Tracbacks