improve() for the standard self-improvement flow; use this guide when you specifically want entity-description consolidation.
This pipeline only rewrites description text — it never creates or deletes nodes. To merge near-duplicate
Entity nodes into one, see Entity Deduplication.Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured
- Have an existing knowledge graph with
Entitynodes — the script below builds one withremember()
Code in Action
What Just Happened
Step 1: Clear Existing Data
Step 2: Build and Visualize the Graph
lives_in relationships, then save a visualization of the graph before consolidation.
Step 3: Consolidate and Visualize Again
Entity node’s description in place using LLM analysis of the entity’s neighbors and edges — no nodes are created or deleted. Descriptions become more coherent because the LLM sees each entity in the context of its graph neighborhood, not just the original chunk text, and the before and after HTML files make the change easy to inspect.
Additional Information
- Runnable guide script available on our GitHub
- Pipeline implementation: consolidate_entity_descriptions.py
Under the hood
Under the hood
Three tasks run in sequence:
get_entities_with_neighborhood— loads allEntitynodes and fetches their edges and neighbor nodes.generate_consolidated_entities— sends each entity plus neighborhood to the LLM, which returns a refined description.add_data_points— writes the updatedEntityobjects back to the graph and vector DB.
Legacy guide
Legacy guide
Troubleshooting
Troubleshooting
- No entities found — the graph must already contain
Entitynodes. Runcognee.remember()first. - LLM errors — verify that your LLM provider is configured. See LLM Providers.
- Permission errors — the user must have write access to the target dataset. See Permissions.
Entity Deduplication
Merge near-duplicate entity nodes into one canonical node
Improve
Understand the current improvement workflow
Self-Improvement Quickstart
Bridge session memory and enrich a dataset
Search
Query the enriched graph with specialized search types