Skip to Content
Core ConceptsNode Sets

Node Sets

What are Node Sets?

In Cognee, a node set is a list of tags (strings) that you can associate with any content you add to the system. These tags help organize your knowledge graph and can be used for filtering and categorization during data addition, processing, and retrieval.

Node sets provide a simple yet powerful tagging mechanism that helps in managing the growing complexity of your knowledge base as you add more content.

How Node Sets Work

When adding content to Cognee, you can specify a node_set parameter that contains one or more tags. These tags are associated with the content in the knowledge graph, creating semantic connections that can be leveraged during searches and analysis.

Basic Usage

The node_set parameter is used with the cognee.add() function to tag content as it’s being added to the system:

await cognee.add( "AI is transforming healthcare with predictive analytics.", node_set=["AI", "Healthcare"] )

In this example, the content is tagged with both “AI” and “Healthcare” categories.

Practical Example

Below is a complete example showing how to use node sets to categorize different pieces of content:

import os import asyncio import cognee from cognee.api.v1.visualize.visualize import visualize_graph # Define content with different topics text_a = """ AI is revolutionizing financial services through intelligent fraud detection and automated customer service platforms. """ text_b = """ Advances in AI are enabling smarter systems that learn and adapt over time. """ text_c = """ MedTech startups have seen significant growth in recent years, driven by innovation in digital health and medical devices. """ # Define node sets (tags) for each content piece node_set_a = ["AI", "FinTech"] node_set_b = ["AI"] node_set_c = ["MedTech"] async def main(): # Clear previous data await cognee.prune.prune_data() await cognee.prune.prune_system(metadata=True) # Add content with their respective tags await cognee.add(text_a, node_set=node_set_a) await cognee.add(text_b, node_set=node_set_b) await cognee.add(text_c, node_set=node_set_c) # Process the content await cognee.cognify() # Visualize the resulting graph visualization_path = os.path.join( os.path.dirname(__file__), "./.artifacts/graph_visualization.html" ) await visualize_graph(visualization_path) if __name__ == "__main__": asyncio.run(main())

In this example:

  • text_a is tagged with “AI” and “FinTech”
  • text_b is tagged with “AI” only
  • text_c is tagged with “MedTech” only

After processing, the knowledge graph will contain nodes that are tagged accordingly, allowing for more organized content management and retrieval.

Benefits of Using Node Sets

Isolation for Agents per topics

Agents can now write data in certain topics to a particular place (events, reasoning, web search)

Content Organization

Node sets allow you to categorize related content, maintaining a structured knowledge base even as it grows larger.

Improved Retrieval

Tag-based filtering enables more precise information access when used in conjunction with semantic searches.

Topic-Based Analysis

Node sets facilitate analysis of patterns and insights within specific domains or categories.

Knowledge Management at Scale

As your knowledge base grows, node sets help maintain organization and reduce complexity.

Advanced Use Cases

Domain-Specific Processing

You can use node sets to apply different processing strategies based on content type:

# Add different types of content with appropriate tags await cognee.add(technical_document, node_set=["Technical", "Documentation"]) await cognee.add(marketing_content, node_set=["Marketing"]) # Process content with domain-specific settings await cognee.cognify( ontology_file_path="technical_ontology.owl", datasets=["Technical"] )

Multi-Dimensional Content Organization

Node sets can be used to implement multi-dimensional categorization:

# Tag content along multiple dimensions await cognee.add( research_report, node_set=["Research", "2023", "Q2", "Healthcare"] ) # Later, you can search within specific dimensions results = await cognee.search( query_text="Latest developments", query_type=SearchType.INSIGHTS, node_types=["Research", "2023"] )
  • Pipelines: Learn how node sets can be used with processing pipelines
  • Ontologies: Understand how node sets can complement ontological structures
  • Search: Discover how to leverage node sets in search operations

Join the Conversation!

Have questions about node sets? Join our community now to connect with professionals, share insights, and get your questions answered!