Get started
← Back to all data apps

Cognee vs RAG: graph-powered AI memory in Deepnote

By Cognee

Updated on July 24, 2025

What if AI could connect the dots instead of just a text recall? 

Use template ->

Cognee is that connection layer. It’s an open-source AI memory engine that builds structured knowledge graphs from your data – text, images, audio, you name it – and supercharges your AI’s understanding.

If compared against traditional RAG (Retrieval-Augmented Generation) , cognee’s graph-based approach delivers deeper reasoning, richer results, and more context-aware answers.

Evaluation benchmarks show:

Base RAG: EM 0, F1 0.12, LLM as a Judge-Correctness 0.4 on HotpotQA

cognee: EM 0.5 F1 0.63, LLM as a Judge-Correctness 0.7 on HotpotQA

Here’s how cognee outperforms classic RAG and how easily you can try it in a Deepnote notebook.

From data ingestion to graph

Traditional RAG systems feed LLMs with snippets of text fetched via vector similarity. That works, but it misses a lot. Cognee goes further: it automatically ingests both structured and unstructured data – documents, scanned files, images, even audio – and converts them into an interconnected knowledge graph.

That means your AI isn’t just parroting retrieved text; it’s drawing on a structured web of facts. Picture feeding PDFs, screenshots, and call transcripts into cognee – it transcribes and parses everything, capturing key facts and relationships as graph data points. The result is a dynamic knowledge network that gives AI a full-context memory, not just isolated blurbs.

Why do Ontologies matter

Cognee can even plug in ontologies – formal domain schemas and rules – to enrich the graph with background knowledge. In practice, this means cognee understands how your domain concepts relate (e.g. a Mercedes is-a Car, which is-a Vehicle) and can infer new facts via hierarchy, transitive relations, and other logic. By integrating ontologies, cognee transforms a good knowledge graph into an exceptional one, applying “rule-book” reasoning to what’s been captured. This ontology-driven reasoning grounds the AI in domain knowledge and drastically reduces hallucinations. Here is an example of a simple ontology, that illustrates how they work.

image (1).png

Search with GRAPH_COMPLETION vs RAG_COMPLETION

When it’s query time, cognee offers advanced search modes that leverage the graph. You can ask questions in GraphCompletion mode to get answers aware of the web of relationships, or fall back to a classic RAG-style completion. In fact, cognee provides both: GRAPH_COMPLETION taps into the graph structure for contextually aware responses, whereas RAG_COMPLETION relies on traditional retrieval. Need a concise answer that stitches together multiple data points? GraphCompletion will traverse the knowledge graph to give you a nuanced answer with all the relevant connections considered. For a straightforward fact lookup, RAGCompletion is there too – all within the same toolkit. In practical terms, cognee’s graph-based queries can understand complex, multi-hop questions and deliver answers that feel more “aware” of context than a vector search ever could.

Graph visualization

One of cognee’s most powerful (and coolest) features is its built-in graph visualization. Instead of treating your data as an opaque blob of text embeddings, cognee lets you see the knowledge. With a single function call, you can generate a network graph of your data entities and their relationships. This isn’t just for show – it helps you literally connect the dots. Traditional RAG has no equivalent for this, because there’s no structured network to visualize. Cognee’s graphs turn AI memory from a black box into a clear map of knowledge, which is invaluable for understanding your data’s story.

image (2).png

Getting started with a notebook

Perhaps best of all, cognee is a Python library you can spin up in your Deepnote notebook with a few lines of code. It beats Jupyter notebooks and makes it easier to build prototypes quickly .

You can pip install cognee and start feeding data into a knowledge graph right inside your notebook. The library abstracts away heavy lifting with simple APIs, so you don’t need to be a knowledge graph expert to use it. This ease of use means you can focus on asking deeper questions of your data. Want to turn a folder of company docs into an intelligent Q&A bot? Or enrich your ML model with a world of contextual knowledge? Just integrate cognee in Deepnote, and watch as it transforms your data into a high-quality knowledge system powered by logical inference and domain modeling.

Cognee has many options for your DB layer— here is an example how you can pair it with Postgres + pgvector in second, drawing directly from the docker-compose.yml shipped in the cognee

#excerpt from cognee/docker-compose.yml
postgres:
  image: pgvector/pgvector:pg17
  container_name: postgres
  environment:
    POSTGRES_USER: cognee
    POSTGRES_PASSWORD: cognee
    POSTGRES_DB: cognee_db
  ports:
    - "5432:5432"
  networks:
    - cognee-network

Add your env vars - the same credentials used above:

DB_PROVIDER=postgres
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USERNAME=cognee
DB_PASSWORD=cognee
DB_NAME=cognee_db

VECTOR_DB_PROVIDER="pgvector"

Start the service – your can run docker compose up postgres from a terminal block. Done, Cognee now uses Postgres and pgvector instead of its default options, giving you a persistent AI memory with a single container and a handful of env vars.

Summary

In summary, cognee beats the standard RAG approach with a graph-based memory that connects information, enforces logic, and provides context. The benchmarks can be found here.

As we mentioned results show:

Base RAG: EM 0, F1 0.12, LLM as a Judge-Correctness 0.4 on HotpotQA

cognee: EM 0.5 F1 0.63, LLM as a Judge-Correctness 0.7 on HotpotQA

It builds a structured knowledge graph where vanilla RAG sees only text. It infuses domain semantics via ontologies, enabling the kind of reasoning and consistency traditional RAG can’t touch.

And it offers powerful search modes and visualization tools to explore that knowledge. Why settle for vanilla retrieval, when you can have real understanding?

Cognee

That’s it, time to try Deepnote

Get started – it’s free
Book a demo

Footer

Solutions

  • Notebook
  • Data apps
  • Machine learning
  • Data teams

Product

Company

Comparisons

Resources

Footer

  • Privacy
  • Terms

© 2025 Deepnote. All rights reserved.