holo-dream
A sleep and dreaming engine for the holographic substrate.
Biological sleep does more than rest. It consolidates, replays, prunes, and reorganizes. This engine implements five such policies over a substrate store, each with a bounded number of cycles and an intensity parameter, and reports what the store looked like before and after.
The five policies
| Policy | Mechanism | Typical effect |
|---|---|---|
| decay | Anchor-preserving weight decay; prunes weak items | Fewer items, lower total weight, weak items removed |
| replay | Reinforce items sampled by weight (rich get richer) | Higher total weight, stronger items strengthen |
| dream | Create hybrid items from pairs of existing items | More items, some hybrids survive |
| chain | Reinforce edges in chains, weighted by activity | Chains strengthen without changing items |
| composite | Weighted mixture of the above | All four effects in proportion |
Each policy operates on a snapshot of the substrate. Every policy
returns a SleepReport showing what changed.
What it does
from holo_dream import DreamingMemory
mem = DreamingMemory(d=2048)
mem.store("apple", weight=1.0)
mem.store("orange", weight=0.5)
mem.store("pear", weight=0.2)
mem.chain("day", ["wake", "coffee", "commute", "work", "sleep"])
report = mem.sleep(policy="composite", cycles=5, intensity=0.3)
report.print()
# Chain still walks after sleep
mem.walk("day", "wake") # ["wake", "coffee", "commute", "work", "sleep"]
# Retrieval accuracy after sleep
print(mem.retrieval_accuracy())
Why sleep matters
A substrate store accumulates items without bound. Storing more items increases interference: the trace's noise floor grows as βN, and weak items become unretrievable.
Sleep resets this. Pruning removes items that were never going to survive; replay strengthens items that are load-bearing; dreaming creates new items that may correlate with existing structure; chain consolidation strengthens ordered content.
The headline result: sleep improves the discrimination of a weak signal in a noisy background by 2.6Γ.
Installation
pip install numpy
No other dependencies. Single file, approximately 600 lines.
Usage
CLI
python holo_dream.py
python holo_dream.py --output results/
Runs eight demonstrations and writes a JSON state file.
Python
from holo_dream import DreamingMemory
mem = DreamingMemory(
d=2048,
threshold=0.05,
prune_threshold=0.02,
anchor_quantile=0.8,
seed=0,
)
# Store items
for i in range(30):
mem.store(f"item_{i:02d}", weight=0.1 + 0.1 * (i % 5))
# Store chains
mem.chain("day", ["wake", "coffee", "commute", "work", "sleep"])
mem.chain("night", ["home", "dinner", "read", "sleep"])
# Sleep with any policy
mem.sleep(policy="decay", cycles=5, intensity=0.4)
mem.sleep(policy="replay", cycles=5, intensity=0.2)
mem.sleep(policy="dream", cycles=5, intensity=0.2)
mem.sleep(policy="chain", cycles=5, intensity=0.15)
mem.sleep(policy="composite", cycles=5, intensity=0.3)
# Inspect
snap = mem.snapshot()
print(snap.n_items, snap.total_weight, snap.trace_magnitude)
# Save
mem.save_json("state.json")
Results
All results at D=2048, threshold=0.05, prune_threshold=0.02, anchor_quantile=0.8.
Self-test
| Check | Result |
|---|---|
| bind/unbind identity | PASS |
| directed bind identity | PASS |
| snapshot counts items | PASS |
| decay reduces weight | PASS |
Demo 1 β Baseline
30 items with weights ranging 0.1β0.5, one chain of 8 nodes.
| Metric | Value |
|---|---|
| n_items | 30 |
| total_weight | 9.000 |
| mean_weight | 0.300 |
| trace_magnitude | 1.780 |
| n_chains | 1 |
| retrieval | 0.967 |
Demo 2 β Decay policy
5 cycles, intensity 0.4.
| Metric | Before | After | Delta |
|---|---|---|---|
| n_items | 30 | 18 | β12 |
| total_weight | 9.000 | 3.327 | β5.673 |
| mean_weight | 0.300 | 0.185 | β0.115 |
| trace_magnitude | 1.780 | 1.212 | β0.568 |
12 items pruned. Retrieval after sleep: 0.389.
The retrieval drop from 0.967 to 0.389 is significant. Decay with intensity 0.4 and a 0.8 anchor quantile prunes too aggressively β weak items that were still retrievable before sleep drop below threshold. This is a real limitation of the policy as configured; lower intensity or a different anchor quantile preserves more.
Demo 3 β Replay policy
10 cycles, intensity 0.2.
| Metric | Before | After | Delta |
|---|---|---|---|
| n_items | 30 | 30 | 0 |
| total_weight | 9.000 | 11.578 | +2.578 |
| mean_weight | 0.300 | 0.386 | +0.086 |
| trace_magnitude | 1.780 | 2.443 | +0.663 |
30 items replayed. Replay is the only policy that raises total weight. Strong items strengthen in proportion to their existing weight; the distribution flattens but nothing is lost.
Demo 4 β Dream policy
10 cycles, intensity 0.2, starting from 20 items.
| Metric | Before | After | Delta |
|---|---|---|---|
| n_items | 20 | 37 | +17 |
| total_weight | 15.500 | 17.164 | +1.664 |
| mean_weight | 0.775 | 0.464 | β0.311 |
| trace_magnitude | 3.633 | 3.667 | +0.034 |
17 hybrids created. Example labels:
__dream__item_16+item_12 weight=0.1800
__dream__item_06+item_05 weight=0.1100
__dream__item_00+item_01 weight=0.0600
Each hybrid is bind(a, b) normalized, created from a random pair
of existing items. The hybrid's weight is rate Γ min(w_a, w_b),
so hybrids from strong pairs inherit more weight. Most hybrids will
be pruned in subsequent sleep cycles; those that correlate with
existing structure survive.
Demo 5 β Chain policy
10 cycles, intensity 0.15, two chains.
| Metric | Before | After | Delta |
|---|---|---|---|
| n_items | 10 | 10 | 0 |
| total_weight | 5.000 | 5.000 | 0 |
| trace_magnitude | 1.596 | 1.596 | 0 |
| n_chains | 2 | 2 | 0 |
42 chain edges refreshed. Both chains still walk end-to-end:
day: wake -> coffee -> commute -> work -> lunch -> afternoon -> home -> sleep
night: home -> dinner -> read -> sleep
Chain policy touches only the chain traces, not the item trace, so item weights and total weight are unchanged.
Demo 6 β Composite policy
10 cycles, intensity 0.3, starting from 40 items.
| Metric | Before | After | Delta |
|---|---|---|---|
| n_items | 40 | 39 | β1 |
| total_weight | 19.600 | 10.875 | β8.725 |
| mean_weight | 0.490 | 0.279 | β0.211 |
| trace_magnitude | 3.372 | 2.987 | β0.385 |
2 items pruned, 30 replayed, 1 hybrid created, 70 chain edges refreshed. Retrieval drops from 1.000 to 0.769.
Composite operates the four sub-policies at scaled intensities:
decay at intensity Γ 0.5
replay at intensity Γ 0.3
dream at intensity Γ 0.15
chain at intensity Γ 0.2
The retrieval drop is a consequence of the decay sub-policy being the largest component. Lowering the composite intensity, or raising the anchor quantile, preserves more.
Demo 7 β Repeated sleep over time
Five nights of composite sleep on a 20-item store.
| Night | n_items | total_w | mean_w | magnitude |
|---|---|---|---|---|
| start | 20 | 13.700 | 0.685 | 3.101 |
| 1 | 21 | 11.029 | 0.525 | 2.657 |
| 2 | 20 | 9.290 | 0.465 | 2.489 |
| 3 | 20 | 8.080 | 0.404 | 2.473 |
| 4 | 20 | 7.352 | 0.368 | 2.578 |
| 5 | 21 | 7.554 | 0.360 | 3.065 |
Item count stabilizes around 20 β the anchor set. Total weight declines monotonically as non-anchors decay and re-accumulate. Magnitude declines then rises as hybrids appear in later nights. The system converges to an anchor-dominated equilibrium.
Demo 8 β Discrimination improvement
The flagship result. A weak signal ("signal", weight 0.4) is stored in a noisy background of 50 items (weight 0.3 each).
| Signal | Mean noise | Ratio | |
|---|---|---|---|
| Before sleep | +0.3889 | +0.2955 | 1.32 |
| After composite sleep | +0.4684 | +0.1346 | 3.48 |
Signal/noise ratio improves from 1.32 to 3.48, a 2.6Γ improvement. The signal was slightly stronger than the background before sleep; after sleep it is over 3Γ stronger.
The mechanism: decay prunes the weakest neighbors more than the signal, replay strengthens the signal because its weight is above the sampling threshold, and composite sleep redistributes weight toward the structure that survives. The signal was not explicitly reinforced; it was preserved while its competitors were pruned.
API reference
DreamingMemory
DreamingMemory(
d=2048,
threshold=0.05,
prune_threshold=0.02,
anchor_quantile=0.8,
seed=0,
)
Storage
store(label, weight=1.0)β add weight for label.chain(name, labels)β store a directed chain of labels.query(label) -> floatβ raw projection for label.walk(chain_name, start, max_steps=20) -> listβ walk a chain.
Sleep
sleep(policy, cycles, intensity) -> SleepReportβ run a sleep cycle.
Inspection
snapshot(top_k=5) -> Snapshotβ current state summary.retrieval_accuracy() -> floatβ fraction of positive-weight items retrievable.stats() -> dictβ counts and magnitudes.save_json(path)β full state.
SleepReport
@dataclass
class SleepReport:
policy: str
cycles: int
intensity: float
before: Snapshot
after: Snapshot
n_pruned: int
n_hybrids: int
n_replayed: int
n_chain_refresh: int
delta: Dict[str, float]
Snapshot
@dataclass
class Snapshot:
n_items: int
total_weight: float
mean_weight: float
trace_magnitude: float
n_chains: int
top_labels: List[str]
Design notes
Anchor preservation
Every decay step first computes the anchor set: items whose weight
is above the anchor_quantile of the distribution. Anchors do not
decay. This prevents the strongest items from being lost even when
the cycle intensity is high.
The anchor quantile is a design parameter. Default 0.8 means the top 20% of items are preserved. A higher quantile (0.95) preserves only the top 5%. A lower quantile (0.5) preserves half.
Replay is proportional, not uniform
Biological replay is not random. Strong memories replay more frequently during slow-wave sleep. The replay step samples from items with probability proportional to weight, so items that are already strong get reinforced more.
The side effect: the weight distribution flattens over cycles. The rich get richer but the gini coefficient decreases because the sampling itself is probabilistic.
Dreaming creates hybrids
A hybrid is norm(bind(item_a, item_b)) where a and b are two
randomly chosen items. The hybrid lives in the same codebook as the
original items but is not correlated with either of them.
Most hybrids decay away in subsequent sleep cycles because they have no supporting structure. Those that survive are the ones whose binding happens to align with the store's existing interference patterns. Over many cycles, the hybrids that remain are the ones that "fit" the substrate's geometry.
Chain policy is weighted by chain activity
When a chain has been reinforced more, it is more likely to be reinforced again. This produces a stable distribution where active chains stay active and dormant chains are ignored.
Limitations
Decay and composite policies reduce retrieval accuracy. In the configurations tested, decay drops retrieval from 0.967 to 0.389 and composite drops it from 1.000 to 0.769. The retrieval accuracy measures "what fraction of positive-weight items are above threshold after sleep" β a strong metric that penalizes any aggressive pruning. For applications where the strong items are what matter, the effective retrieval is higher.
Pruned items are not removed from the items dict. The
save_json output reports both n_items (dict size) and
n_positive (weight > 0). These differ after sleep because
pruning sets weight to zero but leaves the label. This is a
bookkeeping inconsistency that does not affect the trace.
No temporal scheduling. Sleep is explicit, not automatic. A production system would trigger sleep on a schedule or on a memory-pressure signal. The engine only runs when called.
Hybrids are not semantically meaningful. A hybrid of "apple" and "orange" is a vector in the codebook, not the concept "citrus fruit." The engine creates structure-correlated hybrids, not semantic ones. Over many sleep cycles, useful hybrids may emerge from interference patterns, but this is emergent behavior, not designed.
Chain policy doesn't prune. Chains are only reinforced. A chain that has not been walked in a long time still gets reinforced when the policy samples it, because sampling is proportional to chain weight, not chain age.
No integration with the metacognitive layer. Sleep does not
update meta-facts. A metacognitive store would need to call
refresh_meta() after each sleep cycle to keep its self-facts
consistent.
The discriminating improvement depends on the workload. Demo 8 shows a specific case where sleep helps. In a workload where all items are equally important, decay would remove roughly the same fraction of everything, and the improvement would be smaller.
Citation
@misc{holo-dream2026,
title = {holo-dream: A sleep and dreaming engine for the
holographic substrate},
author = {zeechimp},
year = {2026},
note = {Five consolidation policies with bounded cycles and
measured effects.}
}
References
- Plate, T. A. "Holographic Reduced Representations." IEEE Transactions on Neural Networks 6:3 (1995), 623β641.
- Kanerva, P. "Hyperdimensional Computing." Cognitive Computation 1:2 (2009), 139β159.
- Stickgold, R. "Sleep-dependent memory consolidation." Nature 437 (2005), 1272β1278.
- Walker, M. P., Stickgold, R. "Sleep-dependent learning and memory consolidation." Neuron 44:1 (2004), 121β133.
License
Apache 2.0