Skip to content

🧠 GraphMem

The Human Brain for Your AI Agents

PyPI Python 3.9+ License: MIT GitHub

"Memory is the treasury and guardian of all things." β€” Cicero

GraphMem is the first memory system that thinks like a human brain. It doesn't just store dataβ€”it forgets, consolidates, prioritizes, and evolves exactly like biological memory does.

This is the future of enterprise AI agents.


🧬 Why GraphMem Changes Everything

The Problem with Current AI Memory

Every production AI agent faces the same crisis:

Day 1:     "Who is the CEO?" β†’ "Elon Musk" βœ…
Day 100:   Context window: OVERFLOW πŸ’₯
Day 365:   "Who is the CEO?" β†’ "John... or was it Jane... maybe Elon?" 🀯

Vector databases don't forget. They accumulate garbage until your agent drowns in irrelevant, conflicting, outdated information.

The GraphMem Solution: Memory That Thinks

GraphMem implements the four pillars of human memory:

Human Brain GraphMem Why It Matters
🧠 Forgetting Curve Memory Decay Irrelevant memories fade naturally
πŸ”— Neural Networks Knowledge Graph Relationships between concepts
⭐ Importance Weighting PageRank Centrality Hub concepts (Elon Musk) > peripheral ones
⏰ Episodic Memory Temporal Validity "CEO in 2015" vs "CEO now"

πŸš€ Quick Start

# Core only (in-memory, for development)
pip install agentic-graph-mem

# πŸ”₯ RECOMMENDED: Turso (SQLite persistence + offline)
pip install "agentic-graph-mem[libsql]"

# Enterprise: Neo4j + Redis (full graph power)
pip install "agentic-graph-mem[all]"
from graphmem import GraphMem, MemoryConfig

config = MemoryConfig(
    llm_provider="openai",
    llm_api_key="sk-...",
    llm_model="gpt-4o-mini",
    embedding_provider="openai",
    embedding_api_key="sk-...",
    embedding_model="text-embedding-3-small",

    # ⚠️ Add this for data to survive restarts!
    turso_db_path="my_agent_memory.db",
)

memory = GraphMem(config, memory_id="my_agent")

# That's it. 3 methods:
memory.ingest("Tesla is led by CEO Elon Musk...")  # ← Extract knowledge
memory.query("Who is the CEO?")                    # ← Ask questions
memory.evolve()                                    # ← Let memory mature
from graphmem import GraphMem, MemoryConfig

config = MemoryConfig(
    llm_provider="openai",
    llm_api_key="sk-...",
    llm_model="gpt-4o-mini",
    embedding_provider="openai",
    embedding_api_key="sk-...",
    embedding_model="text-embedding-3-small",

    # πŸ”₯ Just add a file path - that's it!
    turso_db_path="my_agent_memory.db",
)

memory = GraphMem(config)
memory.ingest("Important information...")
# Data persists between restarts!
from graphmem import GraphMem, MemoryConfig

# OpenRouter, Together, Groq, or any OpenAI-compatible API
config = MemoryConfig(
    llm_provider="openai_compatible",
    llm_api_key="sk-or-v1-...",
    llm_api_base="https://openrouter.ai/api/v1",  # Custom base URL
    llm_model="google/gemini-2.0-flash-001",
    embedding_provider="openai_compatible",
    embedding_api_key="sk-or-v1-...",
    embedding_api_base="https://openrouter.ai/api/v1",  # Custom base URL
    embedding_model="openai/text-embedding-3-small",
)

# Or Azure OpenAI
config = MemoryConfig(
    llm_provider="azure_openai",
    llm_api_key="your-azure-key",
    llm_api_base="https://your-resource.openai.azure.com/",  # Azure endpoint
    azure_deployment="gpt-4",
    llm_model="gpt-4",
    azure_api_version="2024-02-15-preview",
    embedding_provider="azure_openai",
    embedding_api_key="your-azure-key",
    embedding_api_base="https://your-resource.openai.azure.com/",
    azure_embedding_deployment="text-embedding-ada-002",
    embedding_model="text-embedding-ada-002",
)

# Or local Ollama
config = MemoryConfig(
    llm_provider="openai_compatible",
    llm_api_key="not-needed",
    llm_api_base="http://localhost:11434/v1",  # Ollama base URL
    llm_model="llama3.2",
    embedding_provider="openai_compatible",
    embedding_api_key="not-needed",
    embedding_api_base="http://localhost:11434/v1",
    embedding_model="nomic-embed-text",
)

🎯 Revolutionary Features

  • Point-in-Time Memory


    Query the past: "Who was CEO in 2015?"

    Learn more

  • Knowledge Graph


    Automatic entity extraction and relationship mapping

    Learn more

  • Self-Evolution


    Memory that consolidates, decays, and improves

    Learn more

  • Multi-Tenant Isolation


    Complete data separation for enterprise

    Learn more

  • Structured Data Import


    Pass custom entities (Person, Org, Quote) and known relationships directly

    Learn more


πŸ“Š Performance

Metric Naive RAG GraphMem Advantage
1K conversations πŸ’₯ Context overflow βœ… Bounded Handles growth
10K entities O(n) = 2.3s O(1) = 50ms 46x faster
1 year history 3,650 entries ~100 consolidated 97% reduction
Entity conflicts Duplicates Auto-resolved Clean data
Temporal queries ❌ Impossible βœ… Native Unique capability

πŸ“š Documentation


🀝 Contributing

We're building the future of AI memory. Join us!


**Made with 🧠 by Al-Amin Ibrahim** *"Give your AI agents the memory they deserve."*