shodh-memory
Persistent cognitive memory for AI agents. Local-first. Runs offline.
Give your AI agents memory that persists across sessions, learns from experience, and runs entirely on your hardware.
Installation
[]
= "0.1"
On first use, models (~37MB) download automatically to ~/.cache/shodh-memory/.
Quick Start
use ;
use Result;
Features
- Semantic search — MiniLM-L6 embeddings (384-dim) for meaning-based retrieval
- Hebbian learning — Connections strengthen when memories co-activate
- Activation decay — Unused memories fade naturally (exponential decay)
- Entity extraction — TinyBERT NER extracts people, orgs, locations
- Knowledge graph — Entity relationships with spreading activation
- 3-tier architecture — Working → Session → Long-term memory (Cowan's model)
- 100% offline — Works on air-gapped systems after initial model download
Memory Types
API Overview
Core Operations
// Store
memory.remember?;
// Semantic search
let results = memory.recall?;
// Tag-based search (fast, no embedding)
let results = memory.recall_by_tags?;
// Date range search
let results = memory.recall_by_date?;
// Get single memory
let mem = memory.get_memory?;
// List all
let all = memory.list_memories?;
// Statistics
let stats = memory.get_stats?;
Forget Operations
// Delete single
memory.forget?;
// Delete old memories
memory.forget_by_age?;
// Delete low-importance
memory.forget_by_importance?;
// Delete by pattern (regex)
memory.forget_by_pattern?;
// Delete by tags
memory.forget_by_tags?;
// Delete date range
memory.forget_by_date?;
// GDPR: Delete all
memory.forget_all?;
Context & Introspection
// Context summary for LLM bootstrap
let summary = memory.context_summary?;
// 3-tier memory state
let state = memory.brain_state?;
// Consolidation report (learning activity)
let report = memory.consolidation_report?;
// Flush to disk
memory.flush?;
REST Server
Run the built-in HTTP server:
use run_server;
async
Or use the binary:
Performance
Measured on Intel i7-1355U (10 cores, 1.7GHz):
| Operation | Latency |
|---|---|
remember() |
55-60ms |
recall() semantic |
34-58ms |
recall_by_tags() |
~1ms |
| Entity lookup | 763ns |
| Hebbian strengthen | 5.7µs |
| Graph traversal (3-hop) | 30µs |
Configuration
let config = default
.with_storage_path
.with_working_memory_capacity
.with_session_memory_limit_mb
.with_decay_factor
.with_maintenance_interval_secs;
Environment variables:
SHODH_MEMORY_PATH=./data
SHODH_MAINTENANCE_INTERVAL=300
SHODH_ACTIVATION_DECAY=0.95
SHODH_OFFLINE=true # Disable auto-download
RUST_LOG=info
Architecture
Working Memory ──overflow──> Session Memory ──importance──> Long-Term Memory
(100 items) (500 MB) (RocksDB)
Cognitive processing:
- Spreading activation retrieval
- Exponential activation decay: A(t) = A₀ · e^(-λt)
- Hebbian strengthening on co-retrieval
- Long-term potentiation (permanent connections)
- Memory replay during maintenance
- Retroactive interference detection
Platform Support
| Platform | Status |
|---|---|
| Linux x86_64 | Supported |
| macOS ARM64 | Supported |
| macOS x86_64 | Supported |
| Windows x86_64 | Supported |
| Linux ARM64 | Coming soon |
Links
License
Apache 2.0