Skip to main content
This guide shows how to export your existing Mem0 memories and import them into Cognee.
Need help with a large migration? Chat with us
CapabilityCogneeMem0
Primary StorageBuilt-in knowledge graph + vector store, with scalable optionsVectors (optional graphs)
Data IngestionCreates memories from any data (chats, documents, etc.) allows batch processingCreates memories from conversations
Entity ExtractionMulti-layer semantic connections that tie the graph together more denselyLean with basic entity nets
Memory Enrichmentmemify() derives new facts and enriches existing graphs over timeNot available
Ontology SupportRDF/OWL ontologies and Pydantic models for custom schemasNot available
Temporal AwarenessTime-aware entity extraction and temporal search typeNot available
Feedback LoopUser feedback during search is stored to improve reasoningNot available
Search Types15 retrieval types available to optimize for use caseVector similarity with filters (basic graph queries if enabled)
Data IsolationDataset-scoped permissions and per-dataset storageIsolation through user_id, agent_id, and run_id
API StyleAsynchronous (async/await)Synchronous (sync)

Data Migration Script

Export from Mem0 and import to Cognee in one script:
import asyncio
from mem0 import Memory
import cognee
from cognee.api.v1.search import SearchType

async def migrate():
    # Export from Mem0
    m = Memory()
    mem0_data = m.get_all(user_id="alice")

    # Reset Cognee (optional, for clean start)
    await cognee.prune.prune_data()
    await cognee.prune.prune_system(metadata=True)

    # Import to Cognee
    for memory in mem0_data.get("results", []):
        content = memory.get("memory", "")
        if content:
            await cognee.add(content, dataset_name="alice")

    # Build knowledge graph
    await cognee.cognify()

    # Verify
    result = await cognee.search(
        query_type=SearchType.GRAPH_COMPLETION,
        query_text="What do you know?"
    )
    print(result)

asyncio.run(migrate())

API Mapping

Use this table to translate Mem0 operations to Cognee equivalents:
OperationCogneeMem0
Add textawait cognee.add("text", dataset_name="alice")m.add("text", user_id="alice")
Add fileawait cognee.add("/path/to/file.pdf", dataset_name="docs")Not supported
Add URLawait cognee.add("https://example.com", dataset_name="web")Not supported
Build graphawait cognee.cognify()Automatic (if graph_store configured)
Searchawait cognee.search(query_text="query", query_type=SearchType.GRAPH_COMPLETION)m.search("query", user_id="alice")
Get allawait cognee.datasets.list_data(dataset_id)m.get_all(user_id="alice")
Delete user dataawait cognee.datasets.delete_dataset(dataset_id)m.delete_all(user_id="alice")
Reset allawait cognee.prune.prune_data() + await cognee.prune.prune_system(metadata=True)m.reset()
To get the dataset_id, use await cognee.datasets.list_datasets().

Code Migration Examples

Below are side-by-side comparisons of the most common memory operations in Cognee and Mem0.

Adding Data

import cognee

# Single text
await cognee.add("User loves pizza", dataset_name="alice")

# Conversation messages
messages = [
    {"role": "user", "content": "I love pizza"},
    {"role": "assistant", "content": "Noted!"}
]
await cognee.add(messages, dataset_name="alice")

# Build graph after adding
await cognee.cognify()

Searching

import cognee
from cognee.api.v1.search import SearchType

# Basic search
answer = await cognee.search(
    query_text="What does user like?",
    query_type=SearchType.GRAPH_COMPLETION,
)

# With dataset filter (like user_id)
answer = await cognee.search(
    query_text="What does user like?",
    query_type=SearchType.GRAPH_COMPLETION,
    datasets=["alice"],
)

Deleting

import cognee

# Delete an entire dataset
await cognee.datasets.delete_dataset("alice")

# Full reset
await cognee.prune.prune_data()
await cognee.prune.prune_system(metadata=True)
For a detailed comparison of AI memory architectures and benchmark results, see Deep Dive: AI Memory Comparison.

Next Steps