Inspiration

Current AI memory systems treat memory as flat key-value stores or simple vector databases. But human memory doesn't work that way -- it's associative, with memories strengthening connections through repeated co-activation (Hebbian learning) and consolidating during sleep. We wanted to build a memory engine that works like the brain.

What it does

Mneme is a graph-based associative memory engine for AI agents. It provides:

  • Hebbian edge strengthening -- memories that fire together wire together
  • Spreading activation -- recalling one memory naturally surfaces related ones
  • Exponential decay -- unused connections fade, keeping memory lean
  • Sleep consolidation -- a dedicated cycle that distills recent fragments into durable gist nodes
  • Semantic + bigram search -- find memories by meaning or by text fragments
  • Auto-linking -- new memories automatically form connections to related existing ones

Agents using Mneme can remember conversations, learn user preferences over time, and recall relevant context without explicit retrieval queries.

How we built it

  • Core engine: Pure Python graph with SQLite persistence (memory_core.py, ~310 lines)
  • LLM integration: Qwen Cloud (qwen-plus) via DashScope API for consolidation and auto-linking
  • API layer: FastAPI server with /chat, /sleep, /new_session, /stats, and /health endpoints
  • Deployment: Docker container on Render.com
  • Embedding: Qwen text-embedding-v3 for semantic similarity

Challenges we ran into

  • Tuning decay rates: too aggressive and memories vanish before consolidation; too slow and the graph bloats
  • Balancing recency boost vs. semantic relevance in search results
  • Making sleep consolidation produce useful gists without losing important details
  • Deploying on free tier with 512MB RAM constraint -- optimized SQLite queries and lazy loading

Accomplishments that we're proud of

  • The spreading activation algorithm surfaces genuinely surprising and relevant connections
  • Sleep consolidation actually works -- distilling 20+ fragments into 3-4 coherent gist nodes
  • The entire engine is under 500 lines of Python, no heavy dependencies
  • Live API responding in <2s on free-tier infrastructure

What we learned

  • Hebbian learning principles translate remarkably well to LLM memory systems
  • Graph structure naturally handles the "related but not identical" problem that flat vector stores struggle with
  • Sleep consolidation is the key differentiator -- without it, the graph grows unbounded

What's next for Mneme

  • Multi-agent memory sharing (shared graph with per-agent activation)
  • Emotional valence tagging on edges
  • Self-evolving graph structure (automatic merge/split of clusters)
  • Integration as an MCP tool for Claude and other AI assistants

Built With

Share this project:

Updates