Skip to main content
Cognee gives you the tools to build smarter AI agents with context-aware memory. Use it to create a queryable knowledge graph powered by embeddings from your data. When retrieving data, your agent can reach up to 92.5% accuracy.

What You’ll Learn

In this tutorial, you’ll:
  • Organize memory with nodesets and apply filters during retrieval
  • Define your data model using ontology support
  • Enhance memory with contextual enrichment layers
  • Visualize your graph with graph visualization to explore stored knowledge
  • Search smarter by combining vector similarity with graph traversal
  • Refine results through interactive search and feedback

Example Use Case

In this example, you will use a Cognee-powered Coding Assistant to get context-aware coding help. You can open this example on a Google Colab Notebook and run the steps shown below to build your cognee memory interactively.

Prerequisites

  • OpenAI API key (or another supported LLM provider)
Cognee defaults to gpt-5-mini when using OpenAI, but you can configure the provider and model. Note that the OpenAI free tier does not satisfy the rate limit requirements. Please refer to our LLM providers documentation to use another provider.

Setup

First, let’s set up the environment and import necessary modules.
Create a utility class to handle file downloads and visualization helpers:
Install Cognee using pip:

Create Sample Data to Ingest into Memory

In this example, we’ll use a Python developer scenario. The data sources we’ll ingest into Cognee include:
  • A short introduction about the developer (developer_intro)
  • A conversation between the developer and a coding agent (human_agent_conversations)
  • The Zen of Python principles (python_zen_principles)
  • A basic ontology file with structured data about common technologies (ontology)

Prepare the Sample Data

The download_remote_assets() function:
  • Handles multiple file types (JSON, Markdown, ontology)
  • Creates the required folders automatically
  • Prevents redundant downloads

Review the Structure and Content of Downloaded Data

Next, let’s inspect the data we just downloaded.
Use preview_downloaded_assets() to quickly summarize and preview each file’s structure and contents before Cognee processes them.

Reset Memory and Ingest Structured Data

Start by resetting Cognee’s memory using forget() to ensure a clean, reproducible run. Then, use remember() to load your data into dedicated node sets for organized memory management. remember() ingests the data and builds the knowledge graph in a single call.
Cognee automatically loads the ontology configuration from the ONTOLOGY_FILE_PATH environment variable while remember() runs, so all data is grounded against the supplied ontology as the knowledge graph is built.

Visualize and Inspect the Graph Before and After Enrichment

Generate HTML visualizations of your knowledge graph to see how Cognee processed the data. First, visualize the initial graph structure. Then, use memify() to run the default enrichment pipeline, which extracts coding-rule associations from existing graph chunks and adds them as new nodes and edges. Finally, generate a second visualization to compare the enriched graph.
The generated HTML files can be opened in your browser to explore and inspect the graph structure.

Query Cognee Memory with Natural Language

Use recall() to connect information across multiple data sources. Then, perform filtered recalls within specific node sets to focus on targeted context.

Provide feedback on search answers

Feedback is stored in the session cache, not in the graph. Run searches with a session_id, then use cognee.session.get_session to get the qa_id of the entry you want to rate, and cognee.session.add_feedback to attach a score or comment. See Sessions and Feedback System for details.

Visualize the graph

Generate a final visualization of the knowledge graph.

Next Steps

Join the Community

Cognee DiscordJoin over 1,000 builders to ask questions and share insights.

Explore Examples

GitHub RepositoryStar our repo ⭐ and try additional examples to deepen your knowledge.