inv0krr/leworld-memory-architecture
2
LeWorld Memory Architecture ๐ง โก
A CPU-inspired hierarchical neural architecture where 3 Small LeWorld Models (SLMs) compete to find the most useful memory for 1 Big LeWorld Model (BLM) to predict the next world state.
Architecture
Key Ideas
- CPU-Style Memory: Actual bit-level storage (64K ร 32-bit words), accessed by address ranges โ just like RAM
- Product-Key Addressing: SLMs output addresses by predicting high byte (256 choices) + low byte (256 choices) = 65K addresses with only 512 logits
- Binary SLM Routing: BLM selects which SLMs to trust via Straight-Through Sigmoid โ hard
[1,0,1]in forward, differentiable in backward - Active Information Request: BLM generates "what do I need next?" queries that modulate SLM memory search at the next timestep
- 3-Phase Training: Pre-train โ Joint end-to-end โ Info-request refinement with paired-branch reward
Data Flow
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ARTIFICIAL MEMORY โ
โ [0][1][0][1]...[1][0][1][0] โ
โ 64K words ร 32 bits each โ
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ-โโ
โ READ(addr_range)
โโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโผโโโโโโโ โโโโโโโโโโผโโโโโโโโ โโโโโโโโผโโโโโโโโโโโ
โ SLM-0 โ โ SLM-1 โ โ SLM-2 โ
โ (745K) โ โ (745K) โ โ (745K) โ
โ past_state โ โ past_state โ โ past_state โ
โ curr_state โ โ curr_state โ โ curr_state โ
โ character. โ โ character. โ โ character. โ
โ โ addr โ โ โ addr โ โ โ addr โ
โโโโโโโโฌโโโโโโโ โโโโโโโโโโฌโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโบ BLM (11.2M) โโโโโโโโโโโโโโโโ
mask = [1, 0, 1]
โ next_state prediction
โ "what info do I need next?"Files
Quick Start
from leworld_architecture import LeWorldSystem, MemoryConfig, SLMConfig, BLMConfig
from leworld_training import run_training, TrainingConfig
# Build system
system = LeWorldSystem(MemoryConfig(), SLMConfig(), BLMConfig())
# Train (3 phases: pre-train โ joint โ refine)
metrics = run_training(system, TrainingConfig())Literature Foundation
Verified Results (demo run)
Phase 1: SLM loss 12.87 โ 7.13, BLM loss 0.39 โ 0.33
Phase 2: Routing becomes diverse โ SLM usage: [0.72, 0.79, 0.67]
Phase 3: Info-request improves predictions by 19.5 loss units vs baseline
Final: MSE=0.36, Routing entropy=0.70
Per-step MSE: [0.64, 0.44, 0.31, 0.23, 0.19] โ improves over time
Routing patterns: [1,0,1] โ [0,1,1] โ [1,1,1] โ [1,1,0] โ [0,1,0]