π§ GraphMem¶
The Human Brain for Your AI Agents¶
"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¶
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?"
-
Knowledge Graph
Automatic entity extraction and relationship mapping
-
Self-Evolution
Memory that consolidates, decays, and improves
-
Multi-Tenant Isolation
Complete data separation for enterprise
-
Structured Data Import
Pass custom entities (Person, Org, Quote) and known relationships directly
π 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¶
-
Getting Started
Installation, quick start, and configuration
-
Core Concepts
Understanding how GraphMem works
-
Building Agents
Complete guide to building AI agents
-
Production
Deploy at scale with confidence
π€ Contributing¶
We're building the future of AI memory. Join us!
- π Report bugs
- π‘ Request features
- π Submit PRs