Socket
Book a DemoInstallSign in
Socket

shodh-memory

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shodh-memory

Local-first AI memory system for robotics, drones, and edge AI - 100% offline capable

pipPyPI
Version
0.1.5
Maintainers
1

Shodh-Memory

Shodh-Memory

build MCP Registry crates.io crates.io Downloads npm PyPI PyPI Downloads npm Downloads License

Memory that learns. Single binary. Runs offline.

We built this because AI agents forget everything between sessions. They make the same mistakes, ask the same questions, lose context constantly.

Shodh-Memory fixes that. It's a cognitive memory system—Hebbian learning, activation decay, semantic consolidation—packed into a single 8MB binary that runs offline.

How it works:

Experiences flow through three tiers based on Cowan's working memory model [1]. New information enters capacity-limited working memory, overflows into session storage, and consolidates into long-term memory based on importance. When memories are retrieved together successfully, their connections strengthen—classic Hebbian learning [2]. After enough co-activations, those connections become permanent. Unused memories naturally fade.

Working Memory ──overflow──▶ Session Memory ──importance──▶ Long-Term Memory
   (100 items)                  (500 MB)                      (RocksDB)

Architecture

Storage & Retrieval

  • Vamana graph index for approximate nearest neighbor search [3]
  • MiniLM-L6 embeddings (384-dim, 25MB) for semantic similarity
  • TinyBERT NER (15MB) for entity extraction (Person, Organization, Location, Misc)
  • RocksDB for durable persistence across restarts

Cognitive Processing

  • Named entity recognition — TinyBERT extracts entities; boosts importance and enables graph relationships
  • Spreading activation retrieval — queries activate related memories through semantic and graph connections [5]
  • Activation decay — exponential decay A(t) = A₀ · e^(-λt) applied each maintenance cycle
  • Hebbian strengthening — co-retrieved memories form graph edges; weight increases on co-activation
  • Long-term potentiation — edges surviving threshold co-activations become permanent

Semantic Consolidation

  • Episodic memories older than 7 days compress into semantic facts
  • Entity extraction preserves key information during compression

Use cases

Local LLM memory — Give Claude, GPT, or any local model persistent memory across sessions.

Robotics & drones — On-device experience accumulation without cloud round-trips.

Edge AI — Run on Jetson, Raspberry Pi, industrial PCs. Sub-millisecond retrieval, zero network dependency.

Personal knowledge base — Your own searchable memory. Decisions, learnings, discoveries—private and local.

Compared to alternatives

Shodh-MemoryMem0Cognee
DeploymentSingle 8MB binaryCloud APINeo4j + Vector DB
Offline100%NoPartial
LearningHebbian + decay + LTPVector similarityKnowledge graphs
LatencySub-millisecondNetwork-boundDatabase-bound
Best forLocal-first, edge, privacyCloud scaleEnterprise ETL

Performance

Measured on Intel i7-1355U (10 cores, 1.7GHz), release build.

API Latencies

EndpointOperationLatency
POST /api/rememberStore memory (existing user)55-60ms
POST /api/recallSemantic search34-58ms
POST /api/recall/tagsTag-based search~1ms
GET /api/listList memories~1ms
GET /healthHealth check~1ms

Knowledge Graph (Criterion benchmarks)

OperationLatency
Entity lookup763ns
Relationship query2.2µs
Hebbian strengthen5.7µs
Graph traversal (3-hop)30µs

Neural Models

ModelOperationLatency
MiniLM-L6-v2 (25MB)Embedding (384-dim)33ms
TinyBERT-NER (15MB)Entity extraction15ms

Installation

Claude Code / Claude Desktop:

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "shodh-memory": {
      "command": "npx",
      "args": ["-y", "@shodh/memory-mcp"]
    }
  }
}

Config file locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Python:

pip install shodh-memory

From source:

cargo build --release
./target/release/shodh-memory-server

Usage

Python

from shodh_memory import Memory

memory = Memory(storage_path="./my_data")

# Store
memory.remember("User prefers dark mode", memory_type="Decision")
memory.remember("JWT tokens expire after 24h", memory_type="Learning")

# Search
results = memory.recall("user preferences", limit=5)

# Get memory statistics
stats = memory.get_stats()

REST API

# Store
curl -X POST http://localhost:3030/api/remember \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-key" \
  -d '{"user_id": "agent-1", "content": "Deployment requires Docker 24+", "tags": ["deployment"]}'

# Search
curl -X POST http://localhost:3030/api/recall \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-key" \
  -d '{"user_id": "agent-1", "query": "deployment requirements", "limit": 5}'

Memory types

Different types get different importance weights in the scoring model:

  • Decision (+0.30) — choices, preferences, conclusions
  • Learning (+0.25) — new knowledge, facts learned
  • Error (+0.25) — mistakes, things to avoid
  • Discovery, Pattern (+0.20) — findings, recurring behaviors
  • Task (+0.15) — work items
  • Context, Observation (+0.10) — general info

API reference

Python client (API parity with REST)

MethodWhat it does
Core Memory
remember(content, memory_type, tags, ...)Store a memory
recall(query, limit, mode, ...)Semantic search
list_memories(limit, memory_type)List all memories
get_memory(memory_id)Get single memory by ID
get_stats()Memory statistics
Forget Operations
forget(memory_id)Delete single memory by ID
forget_by_age(days)Delete memories older than N days
forget_by_importance(threshold)Delete low-importance memories
forget_by_pattern(regex)Delete memories matching pattern
forget_by_tags(tags)Delete memories by tags
forget_by_date(start, end)Delete memories in date range
forget_all()Delete ALL memories (GDPR)
Context & Introspection
context_summary(max_items, ...)Categorized context for LLM bootstrap
brain_state(longterm_limit)3-tier memory visualization
flush()Flush data to disk

REST endpoints

All protected endpoints require X-API-Key header.

EndpointMethodDescriptionAvg Latency
Core Memory
/api/rememberPOSTStore memory (embedding + NER)55ms
/api/recallPOSTSemantic search45ms
/api/recall/tagsPOSTTag-based search (no embedding)1ms
/api/recall/datePOSTDate-range search5ms
/api/list/{user_id}GETList all memories1ms
/api/context_summaryPOSTCategorized context for session bootstrap15ms
Forget Operations
/api/forget/agePOSTDelete memories older than threshold5ms
/api/forget/importancePOSTDelete low-importance memories5ms
/api/forget/patternPOSTDelete memories matching regex10ms
/api/forget/tagsPOSTDelete memories by tags5ms
/api/forget/datePOSTDelete memories in date range5ms
Hebbian Learning
/api/retrieve/trackedPOSTSearch with feedback tracking45ms
/api/reinforcePOSTHebbian reinforcement feedback10ms
Batch & Consolidation
/api/batch_rememberPOSTStore multiple memories55ms/item
/api/consolidatePOSTTrigger semantic consolidation250ms
Introspection
/api/memory/{id}GET/PUT/DELETESingle memory operations10ms
/api/users/{id}/statsGETUser statistics10ms
/api/graph/{id}/statsGETKnowledge graph statistics10ms
/api/brain/{user_id}GET3-tier state visualization50ms
/api/search/advancedPOSTMulti-filter search50ms
Health & Metrics
/healthGETHealth check (no auth)<1ms
/health/liveGETKubernetes liveness (no auth)<1ms
/health/readyGETKubernetes readiness (no auth)<1ms
/metricsGETPrometheus metrics (no auth)<1ms

Authentication

# Development mode (SHODH_API_KEYS not set)
curl -H "X-API-Key: sk-shodh-dev-4f8b2c1d9e3a7f5b6d2c8e4a1b9f7d3c" ...

# Production mode (required)
export SHODH_API_KEYS="your-secure-key-1,your-secure-key-2"
export SHODH_ENV=production

Configuration

SHODH_PORT=3030                    # Default: 3030
SHODH_MEMORY_PATH=./data           # Default: ./shodh_memory_data
SHODH_API_KEYS=key1,key2           # Required in production
SHODH_MAINTENANCE_INTERVAL=300     # Decay cycle (seconds)
SHODH_ACTIVATION_DECAY=0.95        # Decay factor per cycle

Platform support

PlatformStatusUse case
Linux x86_64Servers, workstations
macOS ARM64Development (Apple Silicon)
Windows x86_64Development, industrial PCs
Linux ARM64Coming soonJetson, Raspberry Pi, drones

References

[1] Cowan, N. (2010). The Magical Mystery Four: How is Working Memory Capacity Limited, and Why? Current Directions in Psychological Science, 19(1), 51-57. https://pmc.ncbi.nlm.nih.gov/articles/PMC4207727/

[2] Magee, J.C., & Grienberger, C. (2020). Synaptic Plasticity Forms and Functions. Annual Review of Neuroscience, 43, 95-117. https://pmc.ncbi.nlm.nih.gov/articles/PMC10410470/

[3] Subramanya, S.J., et al. (2019). DiskANN: Fast Accurate Billion-point Nearest Neighbor Search on a Single Node. NeurIPS 2019. https://papers.nips.cc/paper/9527-diskann-fast-accurate-billion-point-nearest-neighbor-search-on-a-single-node

[4] Dudai, Y., Karni, A., & Born, J. (2015). The Consolidation and Transformation of Memory. Neuron, 88(1), 20-32. https://pmc.ncbi.nlm.nih.gov/articles/PMC4183265/

[5] Anderson, J.R. (1983). A Spreading Activation Theory of Memory. Journal of Verbal Learning and Verbal Behavior, 22(3), 261-295.

License

Apache 2.0

MCP Registry · PyPI · npm · GitHub

Keywords

memory

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts