From bcd5898d1ede05778f4da22931afb7c36a4151c2 Mon Sep 17 00:00:00 2001 From: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:35:09 +0200 Subject: [PATCH] Added fixes for both neo4j and networkx --- cognee/api/v1/cognify/cognify.py | 299 +- .../databases/graph/graph_db_interface.py | 6 + .../databases/graph/neo4j_driver/adapter.py | 50 +- .../databases/graph/networkx/adapter.py | 33 + .../cognify/graph/add_classification_nodes.py | 5 +- .../cognify/graph/add_node_connections.py | 188 +- .../modules/cognify/graph/add_propositions.py | 20 +- .../cognify/graph/add_summary_nodes.py | 4 - cognee/modules/cognify/graph/create.py | 168 +- .../search/vector/search_similarity.py | 12 +- cognee/utils.py | 70 + notebooks/full_run.ipynb | 7464 ++++++++++++++++- 12 files changed, 7825 insertions(+), 494 deletions(-) diff --git a/cognee/api/v1/cognify/cognify.py b/cognee/api/v1/cognify/cognify.py index 303985af3..c85178b0a 100644 --- a/cognee/api/v1/cognify/cognify.py +++ b/cognee/api/v1/cognify/cognify.py @@ -9,7 +9,7 @@ from cognee.modules.cognify.llm.summarize_content import summarize_content from cognee.modules.cognify.graph.add_summary_nodes import add_summary_nodes from cognee.modules.cognify.graph.add_node_connections import group_nodes_by_layer, graph_ready_output, \ - connect_nodes_in_graph, extract_node_descriptions + connect_nodes_in_graph from cognee.modules.cognify.graph.add_propositions import append_to_graph from cognee.modules.cognify.llm.resolve_cross_graph_references import resolve_cross_graph_references from cognee.modules.cognify.vector.add_propositions import add_propositions @@ -87,128 +87,159 @@ async def cognify(datasets: Union[str, List[str]] = None, graph_data_model: obje return graphs[0] async def process_text(input_text: str, file_metadata: dict): - print(f"Processing document ({file_metadata['id']})") - - classified_categories = [] - - print("WE ARE HERE") - - try: - # Classify the content into categories - classified_categories = await classify_into_categories( - input_text, - "classify_content.txt", - infrastructure_config.get_config()["classification_model"] - ) - file_metadata["categories"] = list(map(lambda category: category["layer_name"], classified_categories)) - except Exception as e: - print(e) - raise e - - try: - # Classify the content into categories - content_summary = await summarize_content( - input_text, - "summarize_content.txt", - SummarizedContent - ) - file_metadata["summary"] = content_summary["summary"] - file_metadata["description"] = content_summary["description"] - except Exception as e: - print(e) - raise e - - try: - # Classify the content into categories - content_labels = await label_content( - input_text, - "label_content.txt", - infrastructure_config.get_config()["labeling_model"] - ) - file_metadata["content_labels"] = content_labels["content_labels"] - except Exception as e: - print(e) - raise e + # print(f"Processing document ({file_metadata['id']})") + # + # classified_categories = [] + # + # print("WE ARE HERE") + # + # try: + # # Classify the content into categories + # classified_categories = await classify_into_categories( + # input_text, + # "classify_content.txt", + # infrastructure_config.get_config()["classification_model"] + # ) + # file_metadata["categories"] = list(map(lambda category: category["layer_name"], classified_categories)) + # except Exception as e: + # print(e) + # raise e + # + # try: + # # Classify the content into categories + # content_summary = await summarize_content( + # input_text, + # "summarize_content.txt", + # SummarizedContent + # ) + # file_metadata["summary"] = content_summary["summary"] + # file_metadata["description"] = content_summary["description"] + # except Exception as e: + # print(e) + # raise e + # + # try: + # # Classify the content into categories + # content_labels = await label_content( + # input_text, + # "label_content.txt", + # infrastructure_config.get_config()["labeling_model"] + # ) + # file_metadata["content_labels"] = content_labels["content_labels"] + # except Exception as e: + # print(e) + # raise e graph_client = await get_graph_client(infrastructure_config.get_config()["graph_engine"]) - - - await add_document_node(graph_client, f"DefaultGraphModel_{USER_ID}", file_metadata) - print(f"Document ({file_metadata['id']}) categorized: {file_metadata['categories']}") - - cognitive_layers = await content_to_cog_layers( - classified_categories[0], - response_model = infrastructure_config.get_config()["congitive_layer_model"] - ) - - cognitive_layers = [layer_subgroup.name for layer_subgroup in cognitive_layers.cognitive_layers] - import tracemalloc - - tracemalloc.start() - - - async def generate_graph_per_layer(text_input: str, layers: List[str], response_model: KnowledgeGraph = KnowledgeGraph): - generate_graphs_awaitables = [generate_graph(text_input, "generate_graph_prompt.txt", {"layer": layer}, response_model) for layer in - layers] - - return await asyncio.gather(*generate_graphs_awaitables) - - # Run the async function for each set of cognitive layers - layer_graphs = await generate_graph_per_layer(input_text, cognitive_layers) - - print("Layer graphs generated %s", layer_graphs) - - print(f"Document ({file_metadata['id']}) layer graphs created") - - - await add_classification_nodes(graph_client,f"DOCUMENT_{file_metadata['id']}", classified_categories[0]) - - await add_summary_nodes(graph_client,f"DOCUMENT_{file_metadata['id']}", {"summary": file_metadata["summary"]}) - - await add_label_nodes(graph_client,f"DOCUMENT_{file_metadata['id']}", {"content_labels": file_metadata["content_labels"]}) - - await append_to_graph(graph_client, layer_graphs, classified_categories[0]) - - print(f"Document ({file_metadata['id']}) layers connected") - - print("Document categories, summaries and metadata are: ", str(classified_categories)) - - print("Document metadata is: ", str(file_metadata)) - - + # + # + # await add_document_node(graph_client, f"DefaultGraphModel_{USER_ID}", file_metadata) + # print(f"Document ({file_metadata['id']}) categorized: {file_metadata['categories']}") + # + # cognitive_layers = await content_to_cog_layers( + # classified_categories[0], + # response_model = infrastructure_config.get_config()["congitive_layer_model"] + # ) + # + # cognitive_layers = [layer_subgroup.name for layer_subgroup in cognitive_layers.cognitive_layers] + # import tracemalloc + # + # tracemalloc.start() + # + # + # async def generate_graph_per_layer(text_input: str, layers: List[str], response_model: KnowledgeGraph = KnowledgeGraph): + # generate_graphs_awaitables = [generate_graph(text_input, "generate_graph_prompt.txt", {"layer": layer}, response_model) for layer in + # layers] + # + # return await asyncio.gather(*generate_graphs_awaitables) + # + # # Run the async function for each set of cognitive layers + # layer_graphs = await generate_graph_per_layer(input_text, cognitive_layers) + # + # print("Layer graphs generated %s", layer_graphs) + # + # print(f"Document ({file_metadata['id']}) layer graphs created") + # + # + # base_node_for_graph = await add_classification_nodes(graph_client,f"DOCUMENT_{file_metadata['id']}", classified_categories[0]) + # + # await add_summary_nodes(graph_client,f"DOCUMENT_{file_metadata['id']}", {"summary": file_metadata["summary"]}) + # + # await add_label_nodes(graph_client,f"DOCUMENT_{file_metadata['id']}", {"content_labels": file_metadata["content_labels"]}) + # + # await append_to_graph(graph_client, layer_graphs, classified_categories[0]) + # + # print(f"Document ({file_metadata['id']}) layers connected") + # + # print("Document categories, summaries and metadata are: ", str(classified_categories)) + # + # print("Document metadata is: ", str(file_metadata)) + # + # print("Base nodes for a graph : ", base_node_for_graph) + # + # base_node_for_graph = 'LLM_CLASSIFICATION_LAYER_Research papers and academic publications_DOCUMENT_062c22df-d99b-599f-90cd-2d325c8bcf69' + # # + # # base_node_for_graph ='LLM_CLASSIFICATION_LAYER_Research papers and academic publications_DOCUMENT_062c22df-d99b-599f-90cd-2d325c8bcf69' + # + # node_descriptions = await graph_client.extract_node_description(base_node_for_graph) + # + # # print("Node descriptions are: ", str(node_descriptions)) + # + # # + # # + # # graph = graph_client.graph + # # + # # node_descriptions = await extract_node_descriptions(base_node_for_graph) + # # + # nodes_by_layer = await group_nodes_by_layer(node_descriptions) + # + # # print("HERE ARE THE NODES BY LAYER", nodes_by_layer) + # # + # unique_layers = nodes_by_layer.keys() + # + # try: + # vector_engine = infrastructure_config.get_config()["vector_engine"] + # + # for layer in unique_layers: + # await vector_engine.create_collection(layer) + # except Exception as e: + # print(e) + # + # await add_propositions(nodes_by_layer) + # # + # results = await resolve_cross_graph_references(nodes_by_layer) + # # + # relationships = graph_ready_output(results) + # print("RELATIONSHIPS", str(relationships)[:3000]) # await graph_client.load_graph_from_file() - - graph = graph_client.graph - - node_descriptions = await extract_node_descriptions(graph.nodes(data = True)) - - nodes_by_layer = await group_nodes_by_layer(node_descriptions) - - unique_layers = nodes_by_layer.keys() - - try: - vector_engine = infrastructure_config.get_config()["vector_engine"] - - for layer in unique_layers: - await vector_engine.create_collection(layer) - except Exception as e: - print(e) - - await add_propositions(nodes_by_layer) - - results = await resolve_cross_graph_references(nodes_by_layer) - - relationships = graph_ready_output(results) - # print(relationships) - await graph_client.load_graph_from_file() - - graph = graph_client.graph - - connect_nodes_in_graph(graph, relationships) - - print(f"Document ({file_metadata['id']}) processed") - - return graph + # + # graph = graph_client.graph + relationships = { + 'SSiKOqSiaGySGeumaeSueGmGOCyyGOKKWmeQ': [ + { + 'collection_id': 'SSiKOqSiaGySGeumaeSueGmGOCyyGOKKWmeQ', + 'searched_node_id': 'f8bc9327-df8d-4b15-bf99-7717688a8140', + 'score': 1.0, + 'score_metadata': {'text': 'A computer that takes advantage of quantum mechanical phenomena'}, + 'original_id_for_search': 'e8d509ee-9233-4e6c-9e6b-6ed9e9cbbc20' + }, + { + 'collection_id': 'SSiKOqSiaGySGeumaeSueGmGOCyyGOKKWmeQ', + 'searched_node_id': '30ad4c83-9ec6-444a-b0a5-42029ef843c5', + 'score': 1.0, + 'score_metadata': {'text': 'Phenomena exhibited by physical matter at small scales, showing properties of both particles and waves'}, + 'original_id_for_search': '851d7f0f-5e9d-414d-9cb1-48b616c3f0d5' + }, + # Additional relationships as needed + ] + # Additional collections as needed +} + + await connect_nodes_in_graph(graph_client, relationships) + # + # print(f"Document ({file_metadata['id']}) processed") + + # return graph @@ -218,7 +249,7 @@ async def main(): infrastructure_config.set_config({ - "graph_engine": GraphDBType.NEO4J + "graph_engine": GraphDBType.NETWORKX }) # print(infrastructure_config.get_config()) text_1 = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena. @@ -229,20 +260,22 @@ async def main(): In principle, a non-quantum (classical) computer can solve the same computational problems as a quantum computer, given enough time. Quantum advantage comes in the form of time complexity rather than computability, and quantum complexity theory shows that some quantum algorithms for carefully selected tasks require exponentially fewer computational steps than the best known non-quantum algorithms. Such tasks can in theory be solved on a large-scale quantum computer whereas classical computers would not finish computations in any reasonable amount of time. However, quantum speedup is not universal or even typical across computational tasks, since basic tasks such as sorting are proven to not allow any asymptotic quantum speedup. Claims of quantum supremacy have drawn significant attention to the discipline, but are demonstrated on contrived tasks, while near-term practical use cases remain limited. """ dataset_name = "explanations" - from cognee.api.v1.add.add import add - await add( - [ - text_1 - - ], - dataset_name - ) + # from cognee.api.v1.add.add import add + # await add( + # [ + # text_1 + # + # ], + # dataset_name + # ) graph = await cognify(datasets=dataset_name) - # graph_client = await get_graph_client(GraphDBType.NEO4J) - # from cognee.utils import render_graph - # graph_url = await render_graph(graph_client.graph) - # print(graph_url) + if infrastructure_config.get_config()["graph_engine"] == GraphDBType.NETWORKX: + + graph_client = await get_graph_client(GraphDBType.NETWORKX) + from cognee.utils import render_graph + graph_url = await render_graph(graph_client.graph) + print(graph_url) asyncio.run(main()) \ No newline at end of file diff --git a/cognee/infrastructure/databases/graph/graph_db_interface.py b/cognee/infrastructure/databases/graph/graph_db_interface.py index 38fb35b9c..676105d3e 100644 --- a/cognee/infrastructure/databases/graph/graph_db_interface.py +++ b/cognee/infrastructure/databases/graph/graph_db_interface.py @@ -43,6 +43,12 @@ async def delete_node( id: str ): raise NotImplementedError + @abstractmethod + async def extract_node( + self, + id: str + ): raise NotImplementedError + """ CRUD operations on graph edges """ diff --git a/cognee/infrastructure/databases/graph/neo4j_driver/adapter.py b/cognee/infrastructure/databases/graph/neo4j_driver/adapter.py index c5ffa05fd..e420c758a 100644 --- a/cognee/infrastructure/databases/graph/neo4j_driver/adapter.py +++ b/cognee/infrastructure/databases/graph/neo4j_driver/adapter.py @@ -52,7 +52,8 @@ async def add_node(self, id: str, **kwargs): serialized_properties = {k: json.dumps(v) if isinstance(v, (dict, list)) else v for k, v in kwargs.items()} - serialized_properties['name'] = node_id + if 'name' not in serialized_properties: + serialized_properties['name'] = node_id serialized_properties['created_at'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S") serialized_properties['updated_at'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S") @@ -79,6 +80,47 @@ async def create_base_model_from_pydantic_object(self, id: str, pydantic_object: + async def extract_node_description(self, id: str): + """Extract node from the graph if it doesn't already exist, with given properties.""" + query= f""" MATCH (n)-[r]->(m) + WHERE n.node_id = '{id}' + AND NOT m.node_id CONTAINS 'DOCUMENT' + AND m.layer_decomposition_uuid IS NOT NULL + RETURN m + + """ + result = await self.query(query) + await self.close() + descriptions = [] + for node in result: + # Assuming 'm' is a consistent key in your data structure + attributes = node.get('m', {}) + + # Ensure all required attributes are present + if all(key in attributes for key in ['description', 'unique_id', 'layer_uuid', 'layer_decomposition_uuid']): + descriptions.append({ + "node_id": attributes["unique_id"], + "description": attributes["description"], + "layer_uuid": attributes["layer_uuid"], + "layer_decomposition_uuid": attributes["layer_decomposition_uuid"] + }) + + return descriptions + + + + async def extract_node(self, id: str): + """Extract node from the graph if it doesn't already exist, with given properties.""" + query= f""" MATCH(n) + WHERE + ID(n) = {id} + RETURN n""" + result = await self.query(query) + await self.close() + return result + + + async def delete_node(self, id: str): node_id = id.replace(":", "_") @@ -105,7 +147,7 @@ async def add_edge(self, from_node: str, to_node: str, relationship_type: str, * if not filtered_properties: query = ( f"MATCH (a:`{from_node}` {{node_id: $from_node}}), (b:`{to_node}` {{node_id: $to_node}}) " - f"MERGE (a)-[r:{relationship_type}]->(b) " + f"MERGE (a)-[r:`{relationship_type}`]->(b) " "RETURN r" ) params = {'from_node': from_node, 'to_node': to_node} @@ -116,7 +158,7 @@ async def add_edge(self, from_node: str, to_node: str, relationship_type: str, * set_clause = ', '.join(f'r.{k} = ${k}' for k in filtered_properties.keys()) query = ( f"MATCH (a:`{from_node}` {{node_id: $from_node}}), (b:`{to_node}` {{node_id: $to_node}}) " - f"MERGE (a)-[r:{relationship_type}]->(b) " + f"MERGE (a)-[r:`{relationship_type}`]->(b) " f"SET {set_clause} " "RETURN r" ) @@ -134,7 +176,7 @@ async def filter_nodes(self, search_node, search_criteria, **kwargs): """Asynchronously filter nodes in the graph based on the given properties.""" query = f""" MATCH (d) - WHERE d.{search_node} CONTAINS '{search_criteria}' + WHERE d.node_id CONTAINS '{search_criteria}' RETURN d""" diff --git a/cognee/infrastructure/databases/graph/networkx/adapter.py b/cognee/infrastructure/databases/graph/networkx/adapter.py index d1494e058..d9dd888ff 100644 --- a/cognee/infrastructure/databases/graph/networkx/adapter.py +++ b/cognee/infrastructure/databases/graph/networkx/adapter.py @@ -67,6 +67,39 @@ async def delete_node(self, id: str) -> None: self.graph.remove_node(id) await self.save_graph_to_file(self.filename) + async def extract_node_description(self, node_string_id): + descriptions = [] + + if self.graph.has_node(node_string_id): + # Get the attributes of the node + for neighbor in self.graph.neighbors(node_string_id): + # Get the attributes of the neighboring node + attributes = self.graph.nodes[neighbor] + + # Ensure all required attributes are present before extracting description + if all(key in attributes for key in + ['description', 'unique_id', 'layer_uuid', 'layer_decomposition_uuid']): + descriptions.append({ + "node_id": attributes["unique_id"], + "description": attributes["description"], + "layer_uuid": attributes["layer_uuid"], + "layer_decomposition_uuid": attributes["layer_decomposition_uuid"] + }) + + return descriptions + + + async def extract_node(self, node_string_id): + + + if self.graph.has_node(node_string_id): + # Get the attributes of the node + attributes = self.graph.nodes[node_string_id] + + print(attributes) + + return attributes + async def save_graph_to_file(self, file_path: str=None) -> None: """Asynchronously save the graph to a file in JSON format.""" diff --git a/cognee/modules/cognify/graph/add_classification_nodes.py b/cognee/modules/cognify/graph/add_classification_nodes.py index 0dc0e090f..0e322def1 100644 --- a/cognee/modules/cognify/graph/add_classification_nodes.py +++ b/cognee/modules/cognify/graph/add_classification_nodes.py @@ -6,10 +6,11 @@ async def add_classification_nodes(graph_client, document_id, classification_dat data_type = classification_data["data_type"] layer_name = classification_data["layer_name"] + classification_data["name"] =f"LLM_CLASSIFICATION_LAYER_{data_type}" # Create the layer classification node ID - layer_classification_node_id = f"LLM_LAYER_CLASSIFICATION_{data_type}_{document_id}" + layer_classification_node_id = f"LLM_CLASSIFICATION_LAYER_{data_type}_{document_id}" # Add the node to the graph, unpacking the node data from the dictionary await graph_client.add_node(layer_classification_node_id, **classification_data) @@ -26,4 +27,4 @@ async def add_classification_nodes(graph_client, document_id, classification_dat # Link the detailed classification node to the layer classification node await graph_client.add_edge(layer_classification_node_id, detailed_classification_node_id, relationship_type = "contains_analysis") - return True + return detailed_classification_node_id diff --git a/cognee/modules/cognify/graph/add_node_connections.py b/cognee/modules/cognify/graph/add_node_connections.py index 5f3f9d578..b6cb902dc 100644 --- a/cognee/modules/cognify/graph/add_node_connections.py +++ b/cognee/modules/cognify/graph/add_node_connections.py @@ -1,21 +1,26 @@ - +from cognee.infrastructure import infrastructure_config from cognee.infrastructure.databases.graph.get_graph_client import get_graph_client from cognee.shared.data_models import GraphDBType -async def extract_node_descriptions(node): - descriptions = [] - - for node_id, attributes in node: - if "description" in attributes and "unique_id" in attributes: - descriptions.append({ - "node_id": attributes["unique_id"], - "description": attributes["description"], - "layer_uuid": attributes["layer_uuid"], - "layer_decomposition_uuid": attributes["layer_decomposition_uuid"] - }) - - return descriptions +# async def extract_node_descriptions(node): +# descriptions = [] +# +# if G.has_node(node_id): +# # Get the attributes of the node +# attributes = G.nodes[node_id] +# +# +# for node_id, attributes in node: +# if "description" in attributes and "unique_id" in attributes: +# descriptions.append({ +# "node_id": attributes["unique_id"], +# "description": attributes["description"], +# "layer_uuid": attributes["layer_uuid"], +# "layer_decomposition_uuid": attributes["layer_decomposition_uuid"] +# }) +# +# return descriptions async def group_nodes_by_layer(node_descriptions): @@ -29,56 +34,115 @@ async def group_nodes_by_layer(node_descriptions): grouped_data[uuid].append(item) + print("GROUPED DATA", grouped_data) + return grouped_data -def connect_nodes_in_graph(graph: object, relationship_dict: dict, score_treshold:float=None): - """ - For each relationship in relationship_dict, check if both nodes exist in the graph based on node attributes. - If they do, create a connection (edge) between them. - - :param graph: A NetworkX graph object - :param relationship_dict: A dictionary containing relationships between nodes - """ - if score_treshold is None: - score_treshold = 0.9 - for id, relationships in relationship_dict.items(): + +async def get_node_by_unique_id(graph, unique_id): + # Iterate through all nodes and their attributes in the graph + for node, attrs in graph.nodes(data=True): + # Check if the current node's attributes contain the unique_id we're looking for + if attrs.get('unique_id') == unique_id: + return node # Return the node (identifier) if found + return None + +async def connect_nodes_in_graph(graph, relationship_dict, score_threshold=0.9): + if not graph or not relationship_dict: + return graph + + for _, relationships in relationship_dict.items(): for relationship in relationships: - searched_node_attr_id = relationship["searched_node_id"] - score_attr_id = relationship["original_id_for_search"] - score = relationship["score"] - - if score> score_treshold: - # Initialize node keys for both searched_node and score_node - searched_node_key, score_node_key = None, None - - # Find nodes in the graph that match the searched_node_id and score_id from their attributes - for node, attrs in graph.nodes(data = True): - if "unique_id" in attrs: # Ensure there is an "id" attribute - if attrs["unique_id"] == searched_node_attr_id: - searched_node_key = node - elif attrs["unique_id"] == score_attr_id: - score_node_key = node - - # If both nodes are found, no need to continue checking other nodes - if searched_node_key and score_node_key: - break - - # Check if both nodes were found in the graph - if searched_node_key is not None and score_node_key is not None: - # print(f"Connecting {searched_node_key} to {score_node_key}") - # If both nodes exist, create an edge between them - # You can customize the edge attributes as needed, here we use "score" as an attribute - graph.add_edge( - searched_node_key, - score_node_key, - weight = score, - score_metadata = relationship.get("score_metadata") - ) - else: - pass + if relationship['score'] > score_threshold: + + # For NetworkX + if infrastructure_config.get_config()["graph_engine"] == GraphDBType.NETWORKX: + + searched_node_id_found = await get_node_by_unique_id(graph.graph, relationship['searched_node_id']) + + + original_id_for_search_found = await get_node_by_unique_id(graph.graph, relationship['original_id_for_search']) + + + if searched_node_id_found and original_id_for_search_found: + print("NETWORKX adding edgedsadas", searched_node_id_found, original_id_for_search_found) + await graph.add_edge( + relationship['searched_node_id'], + relationship['original_id_for_search'], + weight=relationship['score'], + score_metadata=relationship.get('score_metadata', {}) + ) + # For Neo4j + elif infrastructure_config.get_config()["graph_engine"] == GraphDBType.NEO4J: + # Neo4j specific logic to add an edge + # This is just a placeholder, replace it with actual Neo4j logic + await graph.query(f"""MATCH (a), (b) WHERE a.id = {relationship['searched_node_id']} AND b.id = {relationship['original_id_for_search']} + CREATE (a)-[:CONNECTED {{weight:{relationship['score']}}}]->(b)""") return graph +# async def connect_nodes_in_graph(graph=None, relationship_dict: dict=None, score_treshold:float=None): +# """ +# For each relationship in relationship_dict, check if both nodes exist in the graph based on node attributes. +# If they do, create a connection (edge) between them. +# +# :param graph: A NetworkX graph object +# :param relationship_dict: A dictionary containing relationships between nodes +# """ +# if score_treshold is None: +# score_treshold = 0.9 +# for id, relationships in relationship_dict.items(): +# for relationship in relationships: +# searched_node_attr_id = relationship["searched_node_id"] +# score_attr_id = relationship["original_id_for_search"] +# score = relationship["score"] +# +# if score> score_treshold: +# # Initialize node keys for both searched_node and score_node +# searched_node_key, score_node_key = None, None +# +# # Find nodes in the graph that match the searched_node_id and score_id from their attributes +# +# if infrastructure_config.get_config()["graph_engine"] == GraphDBType.NETWORKX: +# searched_node_key = await graph.extract_node(node_string_id=searched_node_attr_id) +# print("NETWORKX SEARCHED NODE KEY", searched_node_key) +# score_node_key = await graph.extract_node(node_string_id=searched_node_attr_id) +# print("NETWORKX SCORE NODE KEY", score_node_key) +# +# elif infrastructure_config.get_config()["graph_engine"] == GraphDBType.NEO4J: +# searched_node_key = await graph.extract_node(node_string_id=searched_node_attr_id) +# print("NEO4J SEARCHED NODE KEY", searched_node_key) +# score_node_key = await graph.extract_node(node_string_id=searched_node_attr_id) +# print("NEO4J SCORE NODE KEY", score_node_key) +# +# +# # for node, attrs in graph.nodes(data = True): +# # if "unique_id" in attrs: # Ensure there is an "id" attribute +# # if attrs["unique_id"] == searched_node_attr_id: +# # searched_node_key = node +# # elif attrs["unique_id"] == score_attr_id: +# # score_node_key = node +# +# # If both nodes are found, no need to continue checking other nodes +# if searched_node_key and score_node_key: +# break +# +# # Check if both nodes were found in the graph +# if searched_node_key is not None and score_node_key is not None: +# # print(f"Connecting {searched_node_key} to {score_node_key}") +# # If both nodes exist, create an edge between them +# # You can customize the edge attributes as needed, here we use "score" as an attribute +# graph.add_edge( +# searched_node_key, +# score_node_key, +# weight = score, +# score_metadata = relationship.get("score_metadata") +# ) +# else: +# pass +# +# return graph + def graph_ready_output(results): relationship_dict = {} @@ -119,10 +183,10 @@ async def main(): # if 'd0bd0f6a-09e5-4308-89f6-400d66895126' in nodes: # print(nodes) - - relationships = {'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah': [{'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'd0bd0f6a-09e5-4308-89f6-400d66895126', 'score': 1.0, 'score_metadata': {'text': 'Pravilnik o izmenama i dopunama Pravilnika o sadržini, načinu i postupku izrade i način vršenja kontrole tehničke dokumentacije prema klasi i nameni objekata'}, 'original_id_for_search': '2801f7b5-55bf-499b-9843-97d48f8e067a'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'd0bd0f6a-09e5-4308-89f6-400d66895126', 'score': 0.1648828387260437, 'score_metadata': {'text': 'Zakon o planiranju i izgradnji'}, 'original_id_for_search': '57966b55-33e2-4eae-a7fa-2f0237643bbe'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'd0bd0f6a-09e5-4308-89f6-400d66895126', 'score': 0.12986786663532257, 'score_metadata': {'text': 'Službeni glasnik RS, broj 77/2015'}, 'original_id_for_search': '0f626d48-4441-43c1-9060-ea7e54f6d8e2'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'c9b9a460-c64a-4e2e-a4d6-aa5b3769274b', 'score': 1.0, 'score_metadata': {'text': 'Službeni glasnik RS, broj 77/2015'}, 'original_id_for_search': '0f626d48-4441-43c1-9060-ea7e54f6d8e2'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'c9b9a460-c64a-4e2e-a4d6-aa5b3769274b', 'score': 0.07603412866592407, 'score_metadata': {'text': 'Prof. dr Zorana Mihajlović'}, 'original_id_for_search': '5d064a62-3cd6-4895-9f60-1a0d8bc299e8'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'c9b9a460-c64a-4e2e-a4d6-aa5b3769274b', 'score': 0.07226034998893738, 'score_metadata': {'text': 'Ministar građevinarstva, saobraćaja i infrastrukture'}, 'original_id_for_search': 'f5d052ca-c4a0-490e-a3ac-d8ad522dea83'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'bbd6d2d6-e673-4b59-a50c-516972a9d0de', 'score': 0.5, 'score_metadata': {'text': 'Pravilnik o izmenama i dopunama Pravilnika o sadržini, načinu i postupku izrade i način vršenja kontrole tehničke dokumentacije prema klasi i nameni objekata'}, 'original_id_for_search': '2801f7b5-55bf-499b-9843-97d48f8e067a'}]} - - connect_nodes_in_graph(graph, relationships) + # + # relationships = {'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah': [{'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'd0bd0f6a-09e5-4308-89f6-400d66895126', 'score': 1.0, 'score_metadata': {'text': 'Pravilnik o izmenama i dopunama Pravilnika o sadržini, načinu i postupku izrade i način vršenja kontrole tehničke dokumentacije prema klasi i nameni objekata'}, 'original_id_for_search': '2801f7b5-55bf-499b-9843-97d48f8e067a'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'd0bd0f6a-09e5-4308-89f6-400d66895126', 'score': 0.1648828387260437, 'score_metadata': {'text': 'Zakon o planiranju i izgradnji'}, 'original_id_for_search': '57966b55-33e2-4eae-a7fa-2f0237643bbe'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'd0bd0f6a-09e5-4308-89f6-400d66895126', 'score': 0.12986786663532257, 'score_metadata': {'text': 'Službeni glasnik RS, broj 77/2015'}, 'original_id_for_search': '0f626d48-4441-43c1-9060-ea7e54f6d8e2'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'c9b9a460-c64a-4e2e-a4d6-aa5b3769274b', 'score': 1.0, 'score_metadata': {'text': 'Službeni glasnik RS, broj 77/2015'}, 'original_id_for_search': '0f626d48-4441-43c1-9060-ea7e54f6d8e2'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'c9b9a460-c64a-4e2e-a4d6-aa5b3769274b', 'score': 0.07603412866592407, 'score_metadata': {'text': 'Prof. dr Zorana Mihajlović'}, 'original_id_for_search': '5d064a62-3cd6-4895-9f60-1a0d8bc299e8'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'c9b9a460-c64a-4e2e-a4d6-aa5b3769274b', 'score': 0.07226034998893738, 'score_metadata': {'text': 'Ministar građevinarstva, saobraćaja i infrastrukture'}, 'original_id_for_search': 'f5d052ca-c4a0-490e-a3ac-d8ad522dea83'}, {'collection_id': 'SuaGeKyKWKWyaSeiqWeWaSyuSKqieSamiyah', 'searched_node_id': 'bbd6d2d6-e673-4b59-a50c-516972a9d0de', 'score': 0.5, 'score_metadata': {'text': 'Pravilnik o izmenama i dopunama Pravilnika o sadržini, načinu i postupku izrade i način vršenja kontrole tehničke dokumentacije prema klasi i nameni objekata'}, 'original_id_for_search': '2801f7b5-55bf-499b-9843-97d48f8e067a'}]} + # + # connect_nodes_in_graph(graph, relationships) from cognee.utils import render_graph diff --git a/cognee/modules/cognify/graph/add_propositions.py b/cognee/modules/cognify/graph/add_propositions.py index 7fa255854..151bca173 100644 --- a/cognee/modules/cognify/graph/add_propositions.py +++ b/cognee/modules/cognify/graph/add_propositions.py @@ -39,26 +39,34 @@ async def add_propositions(graph_client, # Mapping from old node IDs to new node IDs node_id_mapping = {} + + # Add nodes from the Pydantic object for node in new_data.nodes: unique_node_id = uuid.uuid4() new_node_id = f"{node.description} - {str(layer_uuid)} - {str(layer_decomposition_uuid)} - {str(unique_node_id)}" + from cognee.utils import extract_pos_tags, extract_named_entities, extract_sentiment_vader + + extract_pos_tags = await extract_pos_tags(node.description) + extract_named_entities = await extract_named_entities(node.description) + extract_sentiment = await extract_sentiment_vader(node.description) + await graph_client.add_node( new_node_id, + name = node.description, description=node.description, layer_uuid=str(layer_uuid), layer_description=str(layer_description), layer_decomposition_uuid=str(layer_decomposition_uuid), unique_id=str(unique_node_id), + pos_tags =extract_pos_tags, + named_entities = extract_named_entities, + sentiment = extract_sentiment, type='detail' ) - print("HERE IS LAYER NODE ID", layer_node_id) - - print("HERE IS NEW NODE ID", new_node_id) - await graph_client.add_edge(layer_node_id, new_node_id, relationship_type='detail') # Store the mapping from old node ID to new node ID @@ -70,15 +78,15 @@ async def add_propositions(graph_client, source_node_id = node_id_mapping.get(edge.source) target_node_id = node_id_mapping.get(edge.target) + if source_node_id and target_node_id: - await graph_client.add_edge(source_node_id, target_node_id, relationship_type='connects') + await graph_client.add_edge(source_node_id, target_node_id, relationship_type=edge.description) else: print(f"Could not find mapping for edge from {edge.source} to {edge.target}") async def append_to_graph(graph_client, layer_graphs, required_layers): # Generate a UUID for the overall layer layer_uuid = uuid.uuid4() - print("EXAMPLE OF LAYER GRAPHS", required_layers) # Extract category name from required_layers data data_type = required_layers["data_type"] diff --git a/cognee/modules/cognify/graph/add_summary_nodes.py b/cognee/modules/cognify/graph/add_summary_nodes.py index 72ad71da3..b637a6ca3 100644 --- a/cognee/modules/cognify/graph/add_summary_nodes.py +++ b/cognee/modules/cognify/graph/add_summary_nodes.py @@ -3,10 +3,6 @@ async def add_summary_nodes(graph_client,document_id, classification_data): - # graph_client = get_graph_client(GraphDBType.NETWORKX) - # - # await graph_client.load_graph_from_file() - # Create the layer classification node ID layer_classification_node_id = f"LLM_LAYER_SUMMARY_{document_id}" diff --git a/cognee/modules/cognify/graph/create.py b/cognee/modules/cognify/graph/create.py index 1567c80fa..6f645cd68 100644 --- a/cognee/modules/cognify/graph/create.py +++ b/cognee/modules/cognify/graph/create.py @@ -71,29 +71,21 @@ async def process_attribute(graph_client, parent_id: Optional[str], attribute: s created_node_ids = [] if isinstance(value, BaseModel): node_id = await generate_node_id(value) - - # print("HERE IS THE NODE ID", node_id) - node_data = value.model_dump() # Use the specified default relationship for the edge between the parent node and the current node - - - created_node_id = await add_node(graph_client, parent_id, node_id, node_data) - print("fhdhfdshf", created_node_id) + created_node_ids.append(created_node_id) # await add_edge(graph_client, parent_id, node_id, node_data, relationship_data,created_node_ids) # Recursively process nested attributes to ensure all nodes and relationships are added to the graph for sub_attr, sub_val in value.__dict__.items(): # Access attributes and their values directly - # print("HERE IS THE SUB ATTR", sub_attr) - # print("HERE IS THE SUB VAL", sub_val) out = await process_attribute(graph_client, node_id, sub_attr, sub_val) - print("OU2222T", out) + created_node_ids.extend(out) elif isinstance(value, list) and all(isinstance(item, BaseModel) for item in value): @@ -110,7 +102,6 @@ async def process_attribute_edge(graph_client, parent_id: Optional[str], attribu if isinstance(value, BaseModel): node_id = await generate_node_id(value) - # print("HERE IS THE NODE ID", node_id) node_data = value.model_dump() relationship_data = {} @@ -119,8 +110,6 @@ async def process_attribute_edge(graph_client, parent_id: Optional[str], attribu # Recursively process nested attributes to ensure all nodes and relationships are added to the graph for sub_attr, sub_val in value.__dict__.items(): # Access attributes and their values directly - # print("HERE IS THE SUB ATTR", sub_attr) - # print("HERE IS THE SUB VAL", sub_val) await process_attribute_edge(graph_client, node_id, sub_attr, sub_val, created_node_ids) @@ -141,22 +130,15 @@ async def create_dynamic(graph_model, graph_client) : root_id = root_id.replace(":", "_") - - # print(f"Adding root node with ID: {root_id}") - # print(f"Node data: {node_data}") - - _ = node_data.pop("node_id", None) created_node_ids = [] - print("ROOT ID", root_id) out = await graph_client.add_node(root_id, **node_data) created_node_ids.append(out) for attribute_name, attribute_value in graph_model: # print("ATTRIB NAME", attribute_name) # print("ATTRIB VALUE", attribute_value) ids = await process_attribute(graph_client, root_id, attribute_name, attribute_value) - print("IDS", ids) created_node_ids.extend(ids) flattened_and_deduplicated = list({ @@ -166,18 +148,9 @@ async def create_dynamic(graph_model, graph_client) : for item in sublist # Iterate over items in the sublist }.values()) - print("OOOOO", flattened_and_deduplicated) - - for attribute_name, attribute_value in graph_model: - # print("ATTRIB NAME", attribute_name) - # print("ATTRIB VALUE", attribute_value) ids = await process_attribute_edge(graph_client, root_id, attribute_name, attribute_value, flattened_and_deduplicated) - - - - return graph_client @@ -189,143 +162,6 @@ async def create_semantic_graph(graph_model_instance, graph_client): -# if __name__ == "__main__": -# import asyncio - -# # Assuming all necessary imports and GraphDBType, get_graph_client, Document, DocumentType, etc. are defined - -# # Initialize the graph client -# graph_client = get_graph_client(GraphDBType.NETWORKX) - -# # Define a GraphModel instance with example data -# graph_model_instance = DefaultGraphModel( -# id="user123", -# documents=[ -# Document( -# doc_id="doc1", -# title="Document 1", -# summary="Summary of Document 1", -# content_id="content_id_for_doc1", -# doc_type=DocumentType(type_id="PDF", description="Portable Document Format"), -# categories=[ -# Category(category_id="finance", name="Finance", default_relationship=Relationship(type="belongs_to")), -# Category(category_id="tech", name="Technology", default_relationship=Relationship(type="belongs_to")) -# ], -# default_relationship=Relationship(type="has_document") -# ), -# Document( -# doc_id="doc2", -# title="Document 2", -# summary="Summary of Document 2", -# content_id="content_id_for_doc2", -# doc_type=DocumentType(type_id="TXT", description="Text File"), -# categories=[ -# Category(category_id="health", name="Health", default_relationship=Relationship(type="belongs_to")), -# Category(category_id="wellness", name="Wellness", default_relationship=Relationship(type="belongs_to")) -# ], -# default_relationship=Relationship(type="has_document") -# ) -# ], -# user_properties=UserProperties( -# custom_properties={"age": "30"}, -# location=UserLocation(location_id="ny", description="New York", default_relationship=Relationship(type="located_in")) -# ), -# default_fields={ -# "created_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), -# "updated_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S") -# } -# ) - -# # Run the graph creation asynchronously -# G = asyncio.run(create_semantic_graph(graph_model_instance, graph_client)) - -# # Optionally, here you can add more nodes, edges, or perform other operations on the graph G - -# async def create_semantic_graph( -# ): -# graph_type = GraphDBType.NETWORKX -# -# # Call the get_graph_client function with the selected graph type -# graph_client = get_graph_client(graph_type) -# -# print(graph_client) -# -# await graph_client.load_graph_from_file() -# # -# # -# # -# # b = await graph_client.add_node("23ds", { -# # "username": "exampleUser", -# # "email": "user@example.com" -# # }) -# # -# # await graph_client.save_graph_to_file(b) -# graph_model_instance = DefaultGraphModel( -# id="user123", -# documents=[ -# Document( -# doc_id="doc1", -# title="Document 1", -# summary="Summary of Document 1", -# content_id="content_id_for_doc1", # Assuming external content storage ID -# doc_type=DocumentType(type_id="PDF", description="Portable Document Format"), -# categories=[ -# Category(category_id="finance", name="Finance", -# default_relationship=Relationship(type="belongs_to")), -# Category(category_id="tech", name="Technology", -# default_relationship=Relationship(type="belongs_to")) -# ], -# default_relationship=Relationship(type='has_document') -# ), -# Document( -# doc_id="doc2", -# title="Document 2", -# summary="Summary of Document 2", -# content_id="content_id_for_doc2", -# doc_type=DocumentType(type_id="TXT", description="Text File"), -# categories=[ -# Category(category_id="health", name="Health", default_relationship=Relationship(type="belongs_to")), -# Category(category_id="wellness", name="Wellness", -# default_relationship=Relationship(type="belongs_to")) -# ], -# default_relationship=Relationship(type='has_document') -# ) -# ], -# user_properties=UserProperties( -# custom_properties={"age": "30"}, -# location=UserLocation(location_id="ny", description="New York", -# default_relationship=Relationship(type='located_in')) -# ), -# default_fields={ -# 'created_at': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), -# 'updated_at': datetime.now().strftime("%Y-%m-%d %H:%M:%S") -# } -# ) -# -# G = await create_dynamic(graph_model_instance, graph_client) -# -# # print("Nodes and their data:") -# # for node, data in G.graph.nodes(data=True): -# # print(node, data) -# # -# # # Print edges with their data -# # print("\nEdges and their data:") -# # for source, target, data in G.graph.edges(data=True): -# # print(f"{source} -> {target} {data}") -# # print(G) -# -# -# -# -# -# -# -# -# -# -# # return await graph_client.create( user_id = user_id, custom_user_properties=custom_user_properties, required_layers=required_layers, default_fields=default_fields, existing_graph=existing_graph) -# -# # if __name__ == "__main__": # import asyncio # diff --git a/cognee/modules/search/vector/search_similarity.py b/cognee/modules/search/vector/search_similarity.py index f8b141410..33739d8bc 100644 --- a/cognee/modules/search/vector/search_similarity.py +++ b/cognee/modules/search/vector/search_similarity.py @@ -1,10 +1,16 @@ -from cognee.modules.cognify.graph.add_node_connections import extract_node_descriptions + from cognee.infrastructure import infrastructure_config +from cognee.infrastructure.databases.graph.get_graph_client import get_graph_client + + +async def search_similarity(query: str, graph, other_param: str = None, node_descriptions: list = None): + base_node_for_graph = "LLM_CLASSIFICATION_LAYER_" ### TO FIX + graph_db_type = infrastructure_config.get_config()["graph_engine"] + graph_client = await get_graph_client(graph_db_type) -async def search_similarity(query: str, graph, other_param: str = None): - node_descriptions = await extract_node_descriptions(graph.nodes(data = True)) + node_descriptions = await graph_client.extract_node_description(base_node_for_graph) unique_layer_uuids = set(node["layer_decomposition_uuid"] for node in node_descriptions) diff --git a/cognee/utils.py b/cognee/utils.py index de28229c6..71fbc7dfb 100644 --- a/cognee/utils.py +++ b/cognee/utils.py @@ -4,6 +4,8 @@ import graphistry import pandas as pd import matplotlib.pyplot as plt +from nltk.sentiment import SentimentIntensityAnalyzer + def get_document_names(doc_input): """ @@ -128,9 +130,16 @@ async def render_graph(graph): # Convert the NetworkX graph to a Pandas DataFrame representing the edge list edges = nx.to_pandas_edgelist(graph) + # nodes = pd.DataFrame.from_dict(dict(graph.nodes(data=True)), orient='index') + # + # df['named_entities'] = df['named_entities'].apply(lambda x: x if isinstance(x, list) else [x]) # Visualize the graph using Graphistry plotter = graphistry.edges(edges, "source", "target") + # .nodes(nodes, 'index')) + + # Bind the 'name' column as the node label + # plotter = plotter.bind(node='index', point_title='name') # Visualize the graph (this will open a URL in your default web browser) url = plotter.plot(render = False, as_files = True) @@ -176,4 +185,65 @@ async def render_graph(graph): # # Visualize the graph (this will open a URL in your default web browser) # url = plotter.plot(render=False, as_files=True) # print(f"Graph is visualized at: {url}") +import nltk +from nltk.tokenize import word_tokenize +from nltk.tag import pos_tag +from nltk.chunk import ne_chunk + +# Ensure that the necessary NLTK resources are downloaded +nltk.download('maxent_ne_chunker') +nltk.download('words') + +# The sentence you want to tag and recognize entities in +sentence = "Apple Inc. is an American multinational technology company headquartered in Cupertino, California." + + +async def extract_pos_tags(sentence): + """Extract Part-of-Speech (POS) tags for words in a sentence.""" + # Tokenize the sentence into words + tokens = word_tokenize(sentence) + + # Tag each word with its corresponding POS tag + pos_tags = pos_tag(tokens) + + return pos_tags + + +async def extract_named_entities(sentence): + """Extract Named Entities from a sentence.""" + # Tokenize the sentence into words + tokens = word_tokenize(sentence) + + # Perform POS tagging on the tokenized sentence + tagged = pos_tag(tokens) + + # Perform Named Entity Recognition (NER) on the tagged tokens + entities = ne_chunk(tagged) + + return entities + +nltk.download('vader_lexicon') + +async def extract_sentiment_vader(text): + """ + Analyzes the sentiment of a given text using the VADER Sentiment Intensity Analyzer. + + Parameters: + text (str): The text to analyze. + + Returns: + dict: A dictionary containing the polarity scores for the text. + """ + # Initialize the VADER Sentiment Intensity Analyzer + sia = SentimentIntensityAnalyzer() + + # Obtain the polarity scores for the text + polarity_scores = sia.polarity_scores(text) + + return polarity_scores + +if __name__ == "__main__": + sample_text = "I love sunny days, but I hate the rain." + sentiment_scores = extract_sentiment_vader(sample_text) + print("Sentiment analysis results:", sentiment_scores) diff --git a/notebooks/full_run.ipynb b/notebooks/full_run.ipynb index b754f83e7..7995f1d0a 100644 --- a/notebooks/full_run.ipynb +++ b/notebooks/full_run.ipynb @@ -1,119 +1,7355 @@ { - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "id": "aa4e881d", - "metadata": {}, - "outputs": [], - "source": [ - "from os import path\n", - "from cognee import config, prune\n", - "\n", - "data_directory_path = path.abspath(\"../.data\")\n", - "config.data_root_directory(data_directory_path)\n", - "\n", - "cognee_directory_path = path.abspath(\"../.cognee_system\")\n", - "config.system_root_directory(cognee_directory_path)\n", - "\n", - "await prune.prune_system()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "38135bf7", - "metadata": {}, - "outputs": [], - "source": [ - "from os import path\n", - "import cognee\n", - "\n", - "\n", - "dataset_name = \"explanations\"\n", - "await cognee.add([path.abspath(\"../.test_data/Natural language processing.txt\")], dataset_name)\n", - "\n", - "\n", - "dataset_name = \"short_stories\"\n", - "# data_directory_path is defined above\n", - "await cognee.add(\"data://\" + data_directory_path, dataset_name)\n", - "\n", - "text_1 = \"\"\"A quantum computer is a computer that takes advantage of quantum mechanical phenomena.\n", - "At small scales, physical matter exhibits properties of both particles and waves, and quantum computing leverages this behavior, specifically quantum superposition and entanglement, using specialized hardware that supports the preparation and manipulation of quantum states.\n", - "Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster (with respect to input size scaling) than any modern \"classical\" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the technology is largely experimental and impractical, with several obstacles to useful applications. Moreover, scalable quantum computers do not hold promise for many practical tasks, and for many important tasks quantum speedups are proven impossible.\n", - "The basic unit of information in quantum computing is the qubit, similar to the bit in traditional digital electronics. Unlike a classical bit, a qubit can exist in a superposition of its two \"basis\" states. When measuring a qubit, the result is a probabilistic output of a classical bit, therefore making quantum computers nondeterministic in general. If a quantum computer manipulates the qubit in a particular way, wave interference effects can amplify the desired measurement results. The design of quantum algorithms involves creating procedures that allow a quantum computer to perform calculations efficiently and quickly.\n", - "Physically engineering high-quality qubits has proven challenging. If a physical qubit is not sufficiently isolated from its environment, it suffers from quantum decoherence, introducing noise into calculations. Paradoxically, perfectly isolating qubits is also undesirable because quantum computations typically need to initialize qubits, perform controlled qubit interactions, and measure the resulting quantum states. Each of those operations introduces errors and suffers from noise, and such inaccuracies accumulate.\n", - "In principle, a non-quantum (classical) computer can solve the same computational problems as a quantum computer, given enough time. Quantum advantage comes in the form of time complexity rather than computability, and quantum complexity theory shows that some quantum algorithms for carefully selected tasks require exponentially fewer computational steps than the best known non-quantum algorithms. Such tasks can in theory be solved on a large-scale quantum computer whereas classical computers would not finish computations in any reasonable amount of time. However, quantum speedup is not universal or even typical across computational tasks, since basic tasks such as sorting are proven to not allow any asymptotic quantum speedup. Claims of quantum supremacy have drawn significant attention to the discipline, but are demonstrated on contrived tasks, while near-term practical use cases remain limited.\n", - "\"\"\"\n", - "\n", - "text_2 = \"\"\"A large language model (LLM) is a language model notable for its ability to achieve general-purpose language generation and other natural language processing tasks such as classification. LLMs acquire these abilities by learning statistical relationships from text documents during a computationally intensive self-supervised and semi-supervised training process. LLMs can be used for text generation, a form of generative AI, by taking an input text and repeatedly predicting the next token or word.\n", - "LLMs are artificial neural networks. The largest and most capable, as of March 2024, are built with a decoder-only transformer-based architecture while some recent implementations are based on other architectures, such as recurrent neural network variants and Mamba (a state space model).\n", - "Up to 2020, fine tuning was the only way a model could be adapted to be able to accomplish specific tasks. Larger sized models, such as GPT-3, however, can be prompt-engineered to achieve similar results.[6] They are thought to acquire knowledge about syntax, semantics and \"ontology\" inherent in human language corpora, but also inaccuracies and biases present in the corpora.\n", - "Some notable LLMs are OpenAI's GPT series of models (e.g., GPT-3.5 and GPT-4, used in ChatGPT and Microsoft Copilot), Google's PaLM and Gemini (the latter of which is currently used in the chatbot of the same name), xAI's Grok, Meta's LLaMA family of open-source models, Anthropic's Claude models, Mistral AI's open source models, and Databricks' open source DBRX.\n", - "\"\"\"\n", - "\n", - "dataset_name = \"explanations\"\n", - "await cognee.add(\n", - " [\n", - " text_1,\n", - " text_2\n", - " ],\n", - " dataset_name\n", - ")\n", - "\n", - "graph = await cognee.cognify(dataset_name)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "44603a2a", - "metadata": {}, - "outputs": [], - "source": [ - "import cognee\n", - "\n", - "print(cognee.datasets.list_datasets())\n", - "\n", - "explanations = cognee.datasets.query_data('explanations')\n", - "print(len(explanations), explanations)\n", - "\n", - "stories = cognee.datasets.query_data('short_stories')\n", - "print(len(stories), stories)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a81b2bce", - "metadata": {}, - "outputs": [], - "source": [ - "from cognee.utils import render_graph\n", - "\n", - "await render_graph(graph)" - ] + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "aa4e881d", + "metadata": { + "ExecuteTime": { + "end_time": "2024-04-02T07:24:36.813643Z", + "start_time": "2024-04-02T07:24:33.882814Z" } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.8" + }, + "outputs": [], + "source": [ + "from os import path\n", + "from cognee import config, prune\n", + "\n", + "data_directory_path = path.abspath(\"../.data\")\n", + "config.data_root_directory(data_directory_path)\n", + "\n", + "cognee_directory_path = path.abspath(\"../.cognee_system\")\n", + "config.system_root_directory(cognee_directory_path)\n", + "\n", + "await prune.prune_system()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "38135bf7", + "metadata": { + "ExecuteTime": { + "start_time": "2024-04-02T07:24:36.815938Z" + } + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/vasa/Projects/cognee/.venv/lib/python3.11/site-packages/dlt/common/configuration/container.py:94: DeprecationWarning: currentThread() is deprecated, use current_thread() instead\n", + " if m := re.match(r\"dlt-pool-(\\d+)-\", threading.currentThread().getName()):\n", + "/Users/vasa/Projects/cognee/.venv/lib/python3.11/site-packages/dlt/common/configuration/container.py:94: DeprecationWarning: getName() is deprecated, get the name attribute instead\n", + " if m := re.match(r\"dlt-pool-(\\d+)-\", threading.currentThread().getName()):\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Creating default graph\n", + "OOOOO []\n", + "[{'id': 'a27bb4fa-897e-53a5-94ca-b446e1d33dbf', 'name': 'Natural language processing', 'file_path': '/Users/vasa/Projects/cognee/.data/explanations/Natural language processing.txt', 'extension': 'txt', 'mime_type': 'text/plain', 'keywords': 'language|processing|subfield|computer|science|information|retrieval|ability|corpora|speech|machine|goal|capable|citation|technology'}, {'id': '062c22df-d99b-599f-90cd-2d325c8bcf69', 'name': '062c22df-d99b-599f-90cd-2d325c8bcf69', 'file_path': '/Users/vasa/Projects/cognee/.data/explanations/062c22df-d99b-599f-90cd-2d325c8bcf69.txt', 'extension': 'txt', 'mime_type': 'text/plain', 'keywords': 'quantum|computer|advantage|phenomena|matter|behavior|superposition|entanglement|hardware|preparation|manipulation|operation|respect|size|encryption'}, {'id': '6dfe01b6-07d2-5b77-83c8-1d6c11ce2aa7', 'name': '6dfe01b6-07d2-5b77-83c8-1d6c11ce2aa7', 'file_path': '/Users/vasa/Projects/cognee/.data/explanations/6dfe01b6-07d2-5b77-83c8-1d6c11ce2aa7.txt', 'extension': 'txt', 'mime_type': 'text/plain', 'keywords': 'language|model|ability|generation|classification|training|process|form|input|text|token|word|architecture|network|state'}]\n", + "Processing document (a27bb4fa-897e-53a5-94ca-b446e1d33dbf)\n", + "WE ARE HERE\n", + "Processing document (062c22df-d99b-599f-90cd-2d325c8bcf69)\n", + "WE ARE HERE\n", + "Processing document (6dfe01b6-07d2-5b77-83c8-1d6c11ce2aa7)\n", + "WE ARE HERE\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/vasa/Projects/cognee/.venv/lib/python3.11/site-packages/pydantic/json_schema.py:307: ResourceWarning: unclosed \n", + " if self._config.json_schema_mode_override is not None:\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=84 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=89 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=90 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Document (062c22df-d99b-599f-90cd-2d325c8bcf69) categorized: ['Research papers and academic publications']\n", + "Document (a27bb4fa-897e-53a5-94ca-b446e1d33dbf) categorized: ['Research papers and academic publications']\n", + "Document (6dfe01b6-07d2-5b77-83c8-1d6c11ce2aa7) categorized: ['Articles, essays, and reports']\n", + "Layer graphs generated %s [{'{\"layer\": \"Metadata Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer that takes advantage of quantum mechanical phenomena, leveraging behaviors like quantum superposition and entanglement with specialized hardware.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumMechanicalPhenomena', description='Phenomena observed at small scales where physical matter exhibits properties of both particles and waves.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='A quantum state where a particle can exist in multiple states at the same time, leveraged in quantum computing.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='A quantum state where pairs or groups of particles cannot be described independently, leveraged in quantum computing.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='The physics that cannot explain the operation of quantum devices.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='scalableQuantumComputer', description='A quantum computer that could perform certain calculations exponentially faster than classical computers, potentially breaking encryption schemes.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='The process by which a quantum system loses its quantum properties due to interaction with the environment, introducing noise into calculations.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The fundamental unit of information in quantum computing, capable of existing in a superposition of two basis states.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAlgorithm', description='A procedure allowing a quantum computer to perform calculations efficiently and quickly.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='The benefit derived from the time complexity of a quantum computer as opposed to computability, where some algorithms require exponentially fewer steps.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='A field of study that shows some quantum algorithms for selected tasks require exponentially fewer computational steps than non-quantum algorithms.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The claim that quantum computers can perform tasks no classical computer can achieve in any reasonable amount of time, mainly on contrived tasks as of now.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumMechanicalPhenomena', description='leverages', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumSuperposition', description='utilizes', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumEntanglement', description='utilizes', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='scalableQuantumComputer', description='is scalable to become', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='classicalPhysics', description='cannot be explained by', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='qubit', description='uses', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumDecoherence', description='suffers from', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAlgorithm', description='operates using', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAdvantage', description='aims to achieve', color='blue', created_at=None, summarized=None), Edge(source='quantumAdvantage', target='quantumComplexityTheory', description='backed by', color='blue', created_at=None, summarized=None), Edge(source='quantumSupremacy', target='quantumComputer', description='goal of', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Content Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer that leverages quantum mechanical phenomena', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumPhenomena', description='Quantum mechanical properties leveraged by quantum computing, such as quantum superposition and entanglement', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='Branch of physics that cannot explain the operation of quantum devices', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='scalableQuantumComputer', description='A quantum computer that could perform certain calculations exponentially faster than classical computers', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='encryptionSchemes', description='Security measures that could be broken by large-scale quantum computers', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='physicalSimulations', description='Simulations that could be improved with the aid of quantum computers', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='currentTechState', description='The current experimental and impractical state of quantum computing technology', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='practicalTasksQuantumComputing', description='Many practical tasks where scalable quantum computers do not hold promise and quantum speedups are impossible', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The basic unit of information in quantum computing, capable of existing in a superposition of its basis states', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalBit', description='The basic unit of information in traditional digital electronics', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='waveInterference', description='A phenomenon that quantum computers can use to amplify desired measurement results', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAlgorithms', description='Procedures that allow quantum computers to perform calculations efficiently and quickly', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description=\"A disruption in a qubit's state caused by the environment, introducing noise into calculations\", category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='The benefit that quantum computers have over classical computers in terms of time complexity for certain tasks', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='A field that demonstrates some quantum algorithms require exponentially fewer steps than non-quantum algorithms', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The claim that quantum computers can perform tasks that classical computers cannot do in any reasonable time', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='sorting', description='A basic task for which quantum computers do not offer any asymptotic speedup', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumPhenomena', description='manipulates and uses', color='blue', created_at=None, summarized=None), Edge(source='quantumPhenomena', target='classicalPhysics', description='not explained by', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='encryptionSchemes', description='could break', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='physicalSimulations', description='could aid in', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='currentTechState', description='status contrasted by', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='practicalTasksQuantumComputing', description='does not improve', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='classicalBit', description='quantum analog of', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='waveInterference', description='results amplified by', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumAlgorithms', description='manipulation key to', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumDecoherence', description='affected by', color='blue', created_at=None, summarized=None), Edge(source='quantumAdvantage', target='quantumComplexityTheory', description='evidenced by', color='blue', created_at=None, summarized=None), Edge(source='quantumAdvantage', target='sorting', description='not applicable to', color='blue', created_at=None, summarized=None), Edge(source='quantumSupremacy', target='quantumAdvantage', description='form of', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Conceptual Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer that utilizes quantum mechanical phenomena', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='A fundamental principle of quantum mechanics where a physical system exists in multiple states at once', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='A quantum mechanical phenomenon where particles remain interconnected, sharing physical states no matter the distance between them', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='The body of physics that does not account for quantum mechanics', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='scalableQuantumComputer', description='A quantum computer that can perform operations over an arbitrarily large amount of data or number of qubits', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The basic unit of information in quantum computing, akin to the bit in traditional computing', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalBit', description='The basic unit of information in traditional digital electronics', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAlgorithm', description='A procedure developed for quantum computers to efficiently and quickly perform calculations', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='The loss of quantum coherence; when qubits interacting with their environment leads to noise in quantum calculations', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='The ability of quantum computers to solve problems faster than classical computers in terms of time complexity', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='A branch of computational theory that deals with the complexity of quantum algorithms compared to classical algorithms', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The milestone where a quantum computer can solve a problem that no classical computer can solve in any reasonable amount of time', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumSuperposition', description='Leverages', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumEntanglement', description='Leverages', color='blue', created_at=None, summarized=None), Edge(source='quantumCompute', target='classicalPhysics', description='Cannot be explained by', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='quantumComputer', description='Could perform calculations exponentially faster than', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumComputer', description='Used by', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='classicalBit', description='Similar to', color='blue', created_at=None, summarized=None), Edge(source='quantumAlgorithm', target='quantumComputer', description='Designed for', color='blue', created_at=None, summarized=None), Edge(source='quantumDecoherence', target='qubit', description='Affects', color='blue', created_at=None, summarized=None), Edge(source='quantumAdvantage', target='quantumComplexityTheory', description='Defined by', color='blue', created_at=None, summarized=None), Edge(source='quantumAdvantage', target='quantumComputer', description='Offered by', color='blue', created_at=None, summarized=None), Edge(source='quantumSupremacy', target='quantumComputer', description='Claimed by', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Contextual Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer that takes advantage of quantum mechanical phenomena.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumMechanicalPhenomena', description='Physical matter exhibits properties of both particles and waves at small scales.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='A fundamental principle of quantum mechanics where particles can exist in multiple states simultaneously.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='A quantum mechanical phenomenon where particles remain interconnected, sharing their physical states regardless of the distance separating them.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='A branch of physics that deals with matter and energy at the macroscopic level.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='encryptionSchemes', description='Methods used to encode messages or information in a way that only authorized parties can access it.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='physicalSimulations', description='The use of computational models to recreate and analyze complex physical phenomena.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The basic unit of information in quantum computing, akin to the bit in traditional digital electronics.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='The loss of quantum coherence, when a system transitions from a quantum to a classical state, affected by interactions with the external environment.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='The superior speed and efficiency of quantum computers in solving certain computational problems compared to classical computers.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='A branch of computational theory that focuses on the resources, like time or memory, required for quantum computation.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The milestone where quantum computers can solve problems that classical computers practically cannot within a reasonable timeframe.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumMechanicalPhenomena', description='utilizes', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumSuperposition', description='utilizes and leverages behavior of', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumEntanglement', description='utilizes and leverages behavior of', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='classicalPhysics', description='cannot be explained by', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='encryptionSchemes', description='could break widely used', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='physicalSimulations', description='aid in performing', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumComputer', description='is the basic unit of information for', color='blue', created_at=None, summarized=None), Edge(source='quantumDecoherence', target='qubit', description='affects', color='blue', created_at=None, summarized=None), Edge(source='quantumAdvantage', target='quantumComputer', description='presented by, in the form of time complexity', color='blue', created_at=None, summarized=None), Edge(source='quantumComplexityTheory', target='quantumAdvantage', description='shows that some algorithms require fewer steps due to', color='blue', created_at=None, summarized=None), Edge(source='quantumSupremacy', target='quantumComputer', description='is a milestone for', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Citation Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer that takes advantage of quantum mechanical phenomena', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumMechanicalPhenomena', description='Phenomena at small scales where physical matter exhibits properties of both particles and waves', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='A quantum mechanical phenomenon used in quantum computing', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='A quantum mechanical phenomenon used in quantum computing', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='Branch of physics that cannot explain the operation of quantum devices', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAlgorithms', description='Procedures that allow quantum computers to perform calculations efficiently and quickly', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The basic unit of information in quantum computing, representing a two-state quantum-mechanical system', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='The loss of quantum coherence in qubits, introducing noise into calculations', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='A field of theoretical computer science that studies the number of steps required to perform quantum computations', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='The advantage quantum computers have over classical computers in terms of time complexity', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The potential ability of quantum computing devices to solve problems that classical computers practically cannot', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumMechanicalPhenomena', description='utilizes', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumSuperposition', description='leverages', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumEntanglement', description='leverages', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='classicalPhysics', description='cannot be explained by', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAlgorithms', description='performs calculations utilizing', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='qubit', description='uses as a basic unit of information', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumDecoherence', description='suffers from', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumComplexityTheory', description='is studied by', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAdvantage', description='can achieve', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumSupremacy', description='could potentially achieve', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Semantic Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer that utilizes quantum mechanical phenomena.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumMechanics', description='Branch of physics describing physical matter at small scales, having properties of particles and waves.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='A fundamental principle of quantum mechanics where a quantum system can exist in multiple states at once.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='A quantum mechanical phenomenon where quantum states of two or more objects are interconnected.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='Branch of physics based on principles developed before the rise of quantum mechanics.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalComputer', description='A computer that operates on classical computational principles, using bits.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='encryptionSchemes', description='Methods and protocols to secure data from unauthorized access.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='physicalSimulations', description='Computer simulations that mimic physical phenomena.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The basic unit of information in quantum computing, analogous to the bit in classical computing.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalBit', description='The basic unit of information in classical computing, can be either 0 or 1.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAlgorithms', description='Procedures designed to perform calculations on a quantum computer efficiently and quickly.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='A process in quantum computing where qubits lose their quantum properties due to interaction with the environment.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='The superiority of quantum computers over classical computers in solving certain problems more efficiently.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='A field of study that investigates the computational complexity of problems and algorithms in the context of quantum computing.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The point at which a quantum computer can solve a problem that a classical computer cannot solve in any reasonable amount of time.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumMechanics', description='Quantum computers leverage phenomena described by', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='classicalPhysics', description='Cannot explain the operation of quantum computers', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='encryptionSchemes', description='Can potentially break', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='physicalSimulations', description='Can aid in performing', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAdvantage', description='Has the potential for', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumComputer', description='Is the basic unit of information in', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='classicalBit', description='Is analogous to', color='blue', created_at=None, summarized=None), Edge(source='quantumAlgorithms', target='quantumComputer', description='Are designed for', color='blue', created_at=None, summarized=None), Edge(source='quantumDecoherence', target='qubit', description='Adversely affects', color='blue', created_at=None, summarized=None), Edge(source='quantumAdvantage', target='quantumComplexityTheory', description='Is a topic within', color='blue', created_at=None, summarized=None), Edge(source='quantumSupremacy', target='quantumComputer', description='Is a goal for', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Discourse Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer that takes advantage of quantum mechanical phenomena to perform calculations.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumMechanicalPhenomena', description='Physical phenomena observed at small scales, where matter exhibits properties of both particles and waves.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='A quantum property where a quantum system can exist in multiple states at the same time.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='A quantum phenomenon where the state of one particle is dependent on the state of another, regardless of distance.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='Branch of physics based on classical concepts that fails to explain the operation of quantum devices.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='scalableQuantumComputer', description='A large-scale quantum computer with the potential to perform certain calculations exponentially faster than classical computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='encryptionSchemes', description='Cryptographic techniques for securing data, potentially vulnerable to large-scale quantum computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='physicalSimulations', description='Simulations of physical systems and phenomena, an area where quantum computers could aid physicists.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='experimentalAndImpractical', description='The current state of quantum computer technology which is largely unfeasible for practical use.', category='entity', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id='qubit', description='The basic unit of information in quantum computing, analogous to the bit in traditional digital electronics.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='bit', description='The basic unit of information in traditional digital electronics, representing a binary state.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='superposition', description='Property of a qubit to exist in a superposition of two basis states.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='nondeterminism', description='Characteristic of quantum computers where outputs are probabilistic rather than deterministic.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='waveInterferenceEffects', description='Phenomena that can be used to amplify desired measurement results in a quantum computer.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAlgorithms', description='Procedures designed to perform calculations efficiently on quantum computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='Loss of coherence in quantum systems when qubits interact with their environment, leading to noise in calculations.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='Theory that studies the time complexity of quantum algorithms and their advantages over classical algorithms.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSpeedup', description='The reduction in time complexity for certain tasks when performed on a quantum computer versus a classical computer.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The claim that quantum computers can perform certain computations faster than classical supercomputers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumMechanicalPhenomena', description='utilizes', color='blue', created_at=None, summarized=None), Edge(source='quantumMechanicalPhenomena', target='quantumSuperposition', description='includes', color='blue', created_at=None, summarized=None), Edge(source='quantumMechanicalPhenomena', target='quantumEntanglement', description='includes', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='classicalPhysics', description='cannot be explained by', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='quantumComputer', description='is a type of', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='encryptionSchemes', description='could break', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='physicalSimulations', description='could aid in', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='experimentalAndImpractical', description='is currently', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumComputer', description='is the basic unit of', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='bit', description='analogous to', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='superposition', description='can exist in', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='nondeterminism', description='exhibits', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='waveInterferenceEffects', description='can manipulate through', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAlgorithms', description='operates with', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumDecoherence', description='suffers from', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumComplexityTheory', description='is studied by', color='blue', created_at=None, summarized=None), Edge(source='quantumSpeedup', target='quantumComputer', description='is offered by', color='blue', created_at=None, summarized=None), Edge(source='quantumSupremacy', target='quantumComputer', description='is a concept related to', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Methodology Validation Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer that takes advantage of quantum mechanical phenomena.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumMechanics', description='A branch of physics dealing with physical phenomena at nanoscopic scales.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='A fundamental principle of quantum mechanics where a physical system exists in multiple states at the same time.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='A physical phenomenon where particles remain interconnected, sharing physical traits regardless of distance.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='The physics of non-quantum systems, typically at macroscopic scales.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAlgorithms', description='Algorithms designed for execution on quantum computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='The potential ability of quantum computers to solve problems faster than classical computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The basic unit of information in quantum computing, analogous to the bit in classical computing.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='The loss of coherence in quantum states, leading to noise in quantum calculations.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='A theory in computational complexity that defines the complexity of quantum computation.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSpeedup', description='The potential for quantum computers to perform tasks more quickly than classical computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The point where quantum computers can perform tasks that are not feasible for classical computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumMechanics', description='Quantum computers operate based on principles of quantum mechanics.', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumSuperposition', description='Utilizes quantum superposition.', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumEntanglement', description='Utilizes quantum entanglement.', color='blue', created_at=None, summarized=None), Edge(source='classicalPhysics', target='quantumComputer', description='Cannot explain the operation of quantum computers.', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAdvantage', description='Could exhibit quantum advantage over classical computers.', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumComputer', description='Is the basic unit of information for quantum computers.', color='blue', created_at=None, summarized=None), Edge(source='quantumDecoherence', target='quantumComputer', description='Affects the performance of quantum computers.', color='blue', created_at=None, summarized=None), Edge(source='quantumComplexityTheory', target='quantumAdvantage', description='Explains the reduced time complexity of quantum algorithms.', color='blue', created_at=None, summarized=None), Edge(source='quantumSpeedup', target='quantumAlgorithm', description='A potential benefit offered by quantum algorithms.', color='blue', created_at=None, summarized=None), Edge(source='quantumSupremacy', target='quantumComputer', description='A milestone for quantum computers to achieve.', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Ethical Consideration Layer\"}': KnowledgeGraph(nodes=[Node(id='ethicalConsiderationsOfQuantumComputing', description='Ethical considerations related to the development and use of quantum computing.', category='topic', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='impactOnCryptography', description='The potential impact of quantum computing on breaking widely used encryption schemes.', category='event', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='physicalSimulationsAid', description='The role of quantum computing in aiding physicists in performing physical simulations.', category='event', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='experimentalStateOfQuantumTechnology', description='The current experimental and impractical state of quantum computing technology.', category='fact', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='obstaclesToQuantumApplications', description='Obstacles to practical applications of quantum computing.', category='event', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='limitationsOfQuantumComputing', description='The limitations of scalable quantum computers for many practical tasks.', category='fact', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='nondeterminismInQuantumComputing', description='The nondeterministic nature of quantum computers due to probabilistic qubit measurements.', category='fact', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherenceAndNoise', description='Quantum decoherence and noise issues resulting from interacting quantum qubits with their environment.', category='problem', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='tradeOffsInQubitIsolation', description='The trade-offs between isolating qubits for quantum computations and the introduction of errors through necessary operations.', category='problem', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='Quantum advantage in terms of time complexity for selected computational tasks.', category='phenomenon', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='comparisonWithClassicalComputing', description='Comparison of quantum and classical computing in solving the same computational problems.', category='topic', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='The body of knowledge defining the complexity of quantum algorithms in terms of computational steps.', category='field', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='claimsOfQuantumSupremacy', description=\"Claims about quantum computing's superiority over classic computing demonstrated on specific tasks.\", category='event', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='practicalUsesOfQuantumComputing', description='The current limited practical use cases of quantum computing in the near term.', category='fact', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='ethicalConsiderationsOfQuantumComputing', target='impactOnCryptography', description='considers the ethical implications of', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='physicalSimulationsAid', description='considers the ethical implications for', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='experimentalStateOfQuantumTechnology', description='includes the ethical reflection on', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='obstaclesToQuantumApplications', description='takes into account the ethical perspective on', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='limitationsOfQuantumComputing', description='entails the ethical considerations of', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='nondeterminismInQuantumComputing', description='encompasses the ethical aspects of', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='quantumDecoherenceAndNoise', description='addresses the ethical concerns regarding', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='tradeOffsInQubitIsolation', description='highlights the ethical trade-offs involving', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='quantumAdvantage', description='considers the ethical dimension of', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='comparisonWithClassicalComputing', description='includes ethical discussions about', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='quantumComplexityTheory', description='addresses the ethical implications of', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='claimsOfQuantumSupremacy', description='contemplates the ethical aspects of', color='blue', created_at=None, summarized=None), Edge(source='ethicalConsiderationsOfQuantumComputing', target='practicalUsesOfQuantumComputing', description='considers the ethical perspective on', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Data Provenance Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A quantum computer is a computer that takes advantage of quantum mechanical phenomena.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumMechanicalPhenomena', description='At small scales, physical matter exhibits properties of both particles and waves, which quantum computing leverages.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='Quantum superposition is a behavior of matter at quantum scales, used in quantum computing.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='Quantum entanglement is a phenomenon where particles are interconnected, leveraged in quantum computing.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='specializedHardware', description='Specialized hardware supports the preparation and manipulation of quantum states.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='Classical physics cannot explain the operation of quantum devices.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='scalableQuantumComputer', description='A scalable quantum computer could perform calculations much faster than classical computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='encryptionSchemes', description='Widely used encryption schemes could be broken by a large-scale quantum computer.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='physicalSimulations', description='Aid physicists in performing physical simulations is one of the potential applications of quantum computers.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='currentTechnology', description='The current state of quantum computing technology is largely experimental and impractical.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The qubit is the basic unit of information in quantum computing, analogous to the bit in traditional computing but capable of existing in a superposition of states.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalBit', description='A classical bit is a basic unit of information in traditional digital electronics.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='waveInterferenceEffects', description='Wave interference effects can be used in quantum computing to amplify desired measurement results.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAlgorithms', description='Quantum algorithms allow quantum computers to perform calculations efficiently and quickly.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='Quantum decoherence occurs when qubits are not sufficiently isolated, introducing noise into calculations.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumAdvantage', description='Quantum advantage lies in time complexity, making some quantum algorithms exponentially more efficient than non-quantum algorithms.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='Quantum complexity theory shows the computational advantages of quantum algorithms for certain tasks.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='Claims of quantum supremacy highlight the computational potential of quantum computers on specialized tasks.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumMechanicalPhenomena', description='Uses phenomena', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='specializedHardware', description='Utilizes hardware', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='scalableQuantumComputer', description='Eventually becomes', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='encryptionSchemes', description='Could break', color='blue', created_at=None, summarized=None), Edge(source='scalableQuantumComputer', target='physicalSimulations', description='Could aid in', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAlgorithms', description='Runs on', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='currentTechnology', description='Current state', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='classicalBit', description='Quantum version of', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumDecoherence', description='Suffers from', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumAdvantage', description='Offers', color='blue', created_at=None, summarized=None), Edge(source='quantumAdvantage', target='quantumComplexityTheory', description='Supported by', color='blue', created_at=None, summarized=None), Edge(source='quantumMechanicalPhenomena', target='quantumSuperposition', description='Includes', color='blue', created_at=None, summarized=None), Edge(source='quantumMechanicalPhenomena', target='quantumEntanglement', description='Includes', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='quantumSupremacy', description='Related to claims of', color='blue', created_at=None, summarized=None)])}, {'{\"layer\": \"Collaboration Layer\"}': KnowledgeGraph(nodes=[Node(id='quantumComputer', description='A computer utilizing quantum mechanical phenomena.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumMechanicalPhenomena', description='Physical behavior exhibited at small scales, properties of both particles and waves.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSuperposition', description='A fundamental principle of quantum mechanics where a physical system exists in multiple states at once.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumEntanglement', description='A physical phenomenon when pairs or groups of particles are connected and instantaneously affect each other regardless of distance.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='classicalPhysics', description='Physics that does not account for quantum mechanics, insufficient for explaining the operation of quantum devices.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='qubit', description='The basic unit of information in quantum computing, analogous to the bit in traditional computing.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumDecoherence', description='The loss of coherence in a quantum system, detrimental to the stability of qubits.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumComplexityTheory', description='A field of theoretical computer science that studies the number of steps required to solve problems using quantum algorithms compared to classical algorithms.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id='quantumSupremacy', description='The potential ability of quantum computing devices to solve problems that classical computers practically cannot, demonstrated on contrived tasks.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source='quantumComputer', target='quantumMechanicalPhenomena', description='Utilizes', color='blue', created_at=None, summarized=None), Edge(source='quantumMechanicalPhenomena', target='quantumSuperposition', description='Includes', color='blue', created_at=None, summarized=None), Edge(source='quantumMechanicalPhenomena', target='quantumEntanglement', description='Includes', color='blue', created_at=None, summarized=None), Edge(source='quantumComputer', target='classicalPhysics', description='Cannot be explained by', color='blue', created_at=None, summarized=None), Edge(source='qubit', target='quantumComputer', description='Is a unit of', color='blue', created_at=None, summarized=None), Edge(source='quantumDecoherence', target='qubit', description='Affects', color='blue', created_at=None, summarized=None), Edge(source='quantumComplexityTheory', target='quantumComputer', description='Studies problem-solving steps for', color='blue', created_at=None, summarized=None), Edge(source='quantumSupremacy', target='quantumComputer', description='Relates to the potential ability of', color='blue', created_at=None, summarized=None)])}]\n", + "Document (062c22df-d99b-599f-90cd-2d325c8bcf69) layer graphs created\n", + "Could not find mapping for edge from quantumCompute to classicalPhysics\n", + "Could not find mapping for edge from quantumSpeedup to quantumAlgorithm\n", + "Document (062c22df-d99b-599f-90cd-2d325c8bcf69) layers connected\n", + "Document categories, summaries and metadata are: [{'data_type': 'text', 'layer_name': 'Research papers and academic publications'}]\n", + "Document metadata is: {'id': '062c22df-d99b-599f-90cd-2d325c8bcf69', 'name': '062c22df-d99b-599f-90cd-2d325c8bcf69', 'file_path': '/Users/vasa/Projects/cognee/.data/explanations/062c22df-d99b-599f-90cd-2d325c8bcf69.txt', 'extension': 'txt', 'mime_type': 'text/plain', 'keywords': 'quantum|computer|advantage|phenomena|matter|behavior|superposition|entanglement|hardware|preparation|manipulation|operation|respect|size|encryption', 'categories': ['Research papers and academic publications'], 'summary': \"A quantum computer is a device that uses quantum mechanical properties, like superposition and entanglement, to perform calculations. It operates on qubits, which allow probabilistic, often faster processing than classical computers for certain tasks. However, practical and scalable quantum computing faces challenges like decoherence and error accumulation in qubits. While quantum computers could theoretically solve certain problems quicker, known as quantum advantage, this speedup isn't universal across all computational tasks. Current technological status is largely experimental, with limited practical applications.\", 'content_labels': 'Concepts and Characteristics'}\n" + ] + }, + { + "data": { + "text/plain": "Fetching 7 files: 0%| | 0/7 [00:00>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=92 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=86 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=85 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=93 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=94 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=95 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=96 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=100 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=102 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=98 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=101 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=99 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n" + ] + }, + { + "data": { + "text/plain": "Fetching 7 files: 0%| | 0/7 [00:00>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=97 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=109 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=105 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=111 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=106 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=107 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=108 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=110 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + ":225: ResourceWarning: unclosed \n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + ":225: ResourceWarning: unclosed \n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + ":225: ResourceWarning: unclosed \n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + ":225: ResourceWarning: unclosed \n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + ":225: ResourceWarning: unclosed \n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + ":225: ResourceWarning: unclosed \n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=115 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=113 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=121 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=116 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=112 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n", + "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py:864: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=114 read=idle write=>\n", + " _warn(f\"unclosed transport {self!r}\", ResourceWarning, source=self)\n", + "ResourceWarning: Enable tracemalloc to get the object allocation traceback\n" + ] + }, + { + "data": { + "text/plain": "Fetching 7 files: 0%| | 0/7 [00:00