When to use this
After cognify, entity descriptions may be fragmented or repetitive because each description is derived from a single chunk. This pipeline rewrites each entity’s description using the LLM and the entity’s full neighborhood context (edges and neighbors), producing more coherent and complete descriptions. Before you start:- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured
- Have an existing knowledge graph with
Entitynodes (add → cognify completed)
Code in Action
What Just Happened
- Prune — clears existing data and metadata so the example starts fresh.
- Add + Cognify — builds a knowledge graph with
Entitynodes for each person and location. consolidate_entity_descriptions_pipeline()— loads each entity along with its graph neighbors and edges, sends the context to the LLM, and writes back a refined description.
What Changed in Your Graph
- Existing
Entitynodedescriptionfields are rewritten using LLM analysis of each entity’s neighbors and edges. - No new nodes are created. The pipeline updates descriptions in place.
- Descriptions become more coherent because the LLM sees each entity in the context of its graph neighborhood, not just the original chunk text.
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 + neighborhood to the LLM, which returns a refined description.add_data_points— writes the updatedEntityobjects back to the graph and vector DB.
Troubleshooting
Troubleshooting
- No entities found — the graph must contain
Entitynodes. Runcognee.add()andcognee.cognify()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.