THE NEW MEMORY

Karpathy-Style Self-Learning Architecture

Kilo Memory System v2026.4.17

Executive Summary

A Self-Evolving Memory System That Actually Learns

This system transforms passive data storage into an active learning engine. Inspired by Andrej Karpathy's LLM Knowledge Base architecture, it combines pattern extraction, Hebbian link detection, ACT-R cognitive modeling, and Ebbinghaus forgetting curves to create a memory system that improves over time.

System Architecture

Tier 1: Redis (Hot Cache)

127.0.0.1:6379

  • kilo:search:* — Search results (1hr TTL)
  • kilo:entry:* — Memory entries (24hr)
  • kilo:stats:* — Aggregations (5min)
  • shared:infra:* — Cross-agent data (12hr)

Tier 2: MariaDB (Primary)

127.0.0.1:3306

  • kilo — 1,209 memory entries
  • aoede — 15,507+ agent entries
  • claude — Knowledge library
  • infra_secrets — Credentials
  • 8 databases total

Tier 3: Obsidian (Knowledge)

127.0.0.1:7654

  • wiki/ — Main documentation
  • kilo/ — Kilo-specific knowledge
  • harry/ — Harry's knowledge
  • raw/ — Research materials
  • 338+ files across 4 vaults

Tier 4: Karpathy Learning

Self-improving engine

  • Pattern Extractor — 1,200+ entries analyzed
  • Hebbian Links — 396+ tag connections
  • ACT-R Activation — 18 types ranked
  • Feedback Loop — Outcome tracking
  • Qdrant — Vector search (L2 layer)

The 5 Learning Components

1

Pattern Extractor

Analyzes all memory entries to identify patterns in successful vs. failed actions. Categorizes by event_type and tags to understand what works.

# Example: What tags lead to success? patterns["successful"]["by_tag"]["redis"] = 23 patterns["successful"]["by_tag"]["deployment"] = 15 patterns["successful"]["by_tag"]["obsidian"] = 31
2

Hebbian Link Detection

"Cells that fire together wire together." Detects co-occurring tags and creates weighted links between them — the system learns that redis and cache often go together.

# Example: Hebbian links (top 5) {"from": "redis", "to": "cache", "weight": 47} {"from": "memory", "to": "karpathy", "weight": 38} {"from": "deployment", "to": "one-page-html", "weight": 29} {"from": "obsidian", "to": "documentation", "weight": 26} {"from": "infra", "to": "127.0.0.1", "weight": 21}
3

ACT-R Activation

Based on John Anderson's ACT-R cognitive theory. Successful patterns "float to top" through activation calculation: A = A_base + ln(1/time) + success_bonus.

# Example: ACT-R activation ranking [{"type": "action", "activation": 4.2}, {"type": "feature", "activation": 3.8}, {"type": "learning", "activation": 3.1}, {"type": "solution", "activation": 2.9}, {"type": "fix", "activation": 2.4}]
4

Ebbinghaus Forgetting

Old failures fade away over time. Entries older than 14 days with event_type 'issue' or 'failed' are automatically deprioritized — the system "forgets" what didn't work.

Threshold: 14 days
Affected types: issue, error, failed, fix-failed
5

Feedback Loop

Tracks outcomes of actions. When you record "success" or "fail", it updates the system to suggest better actions in the future.

from karpathy_learn import FeedbackLoop fb = FeedbackLoop() fb.record_outcome("redis cache setup", "success") fb.record_outcome("obsidian api", "fail") # Get suggestions based on past success recs = get_recommendations("cache redis")

Data Flow

Query
Redis

hot cache

MariaDB

primary

Obsidian

knowledge

Qdrant

vector search

Karpathy

learn

Write
Redis
MariaDB
Memory.py

Memory Layers (L1–L4)

Layer Technology Latency Purpose
L1 Redis 0ms Identity, rules, configs
L2 Qdrant 5-50ms Semantic vector search
L3 MariaDB 5-10ms Structured entries (1,200+ records)
L4 Obsidian 50-200ms Rich content vault (338+ files)

Multi-Agent Memory

Kilo Agent

  • • 4+ Redis keys (search, entry, stats, obsidian)
  • • 1,209 entries in kilo database
  • • 191 sessions tracked
  • • Full R/W to MariaDB
  • • Access to wiki/kilo/ vaults

Harry Agent

  • • 23+ Redis keys (infra, services, creds)
  • • Separate entries in separate DB
  • • Access to wiki/harry/ vault
  • • shared:infra:* accessible to all

Shared Memory

Both agents can read shared:infra:* keys — when Kilo discovers 127.0.0.1 has MariaDB+Redis, Harry doesn't need to re-discover. The knowledge is shared.

Action Breakdown

1,209

Total Actions

191

Sessions

1,200+

Entries Analyzed

8

MariaDB Databases

Top Action Types

action
209
feature
182
obsidian
173
correction
138
learning
104
session-end
98
system
67
discovery
47

Usage

# Log to memory
python3 memory.py log action "Deployed feature" --tags feature,deploy
# Search memory
python3 memory.py search redis
# Access Obsidian
python3 obsidian_access.py search "workflow"
# Run learning cycle
python3 karpathy_learn.py
# Get recommendations
from karpathy_learn import get_recommendations
recs = get_recommendations("redis setup")

"The system doesn't just store memory — it learns from it."

— Kilo Memory Architecture