Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers and Embedding Providers configured
- Read NodeSets for how tags become graph nodes
- No data is required up front — the script ingests its own passages, but it starts with
cognee.forget(everything=True), which wipes all existing Cognee data; run it against a setup you can afford to reset
Code in Action
What Just Happened
Step 1: Plan the Groups
text_a sits in two groups at once (AI and FinTech), text_b only in AI, and text_c only in MedTech — node sets overlap freely, so a memory does not have to pick a single home.
Step 2: Tag Each Memory on Ingest
node_set is applied while the graph is built, so the labels are materialized as NodeSet nodes and attached to the derived chunks and entities with belongs_to_set edges. self_improvement=False keeps the run to plain ingestion instead of also running improve().
Step 3: Render the Grouped Graph
.artifacts/. Open it and recolor the nodes by Node set: each document contributes one key, so text_a’s nodes show as AI, FinTech while text_b shows as AI and text_c as MedTech. To see the overlap itself, follow the belongs_to_set edges out of the AI NodeSet node — they reach the entities extracted from both text_a and text_b.
Advanced Usage
The labels the script wrote at ingest time are read back at query time. Each option below builds on the sameAI, FinTech, and MedTech groups the script just created.
Scope Recall to One Group
Scope Recall to One Group
The same names you passed to In practice this lets you keep one shared dataset while still asking targeted questions — “only the finance material”, “just the MedTech passages” — without splitting everything into separate datasets.
remember() scope a later recall() through node_name. This is the payoff of tagging: one dataset holds all three topics, but a query can be grounded in a single slice of it.Combine Several Node Sets
Combine Several Node Sets
Pass several names to widen the slice.
node_name_filter_operator controls how they combine: the default OR returns results connected to any of the listed names, while AND requires results to belong to all of them at once.Node-set filtering works with graph-completion search types (
GRAPH_COMPLETION, GRAPH_COMPLETION_COT, GRAPH_COMPLETION_CONTEXT_EXTENSION, GRAPH_SUMMARY_COMPLETION, TEMPORAL, RAG_COMPLETION, TRIPLET_COMPLETION, CHUNKS). It has no effect on SUMMARIES, CYPHER, or NATURAL_LANGUAGE.NodeSets
How tags become first-class graph nodes you can filter on.
Graph Visualization
Render your knowledge graph to an interactive HTML file.
remember()
Every parameter
remember() accepts, including node_set.