The read
An item arrives with its point , hours after the previous one. Before anything is written, the memory reads it. This is the first half of Memory.step.
Four steps
Section titled “Four steps”0. Expiry (when expiry > 0). Nodes whose mass, forgotten up to now, is below expiry leave the memory and free their row. The dormant node below shows why this is needed.
1. The prior: the restaurant, with masses brought up to date.
Slot 0 is new story and weighs alpha. Each node weighs its mass as it will be when the item arrives. After a long pause every mass has shrunk but has not, so a long pause makes a new story more likely.
2. The likelihood: how well the item fits each bell. For each active node, . For new story, the uniform density on the sphere: the same everywhere, because a story that does not exist yet could be anywhere.
3. The posterior.
is the probability that the item belongs to node , or to a new story for . Along the way the memory obtains the item’s surprise, , returned as Step.surprise.
The lab below runs exactly these sums, with the library’s formulas. Its three starting nodes are chosen to show one effect: the dormant node C, with almost no mass, takes the item because it is very narrow and the item falls close to it. Switch expiry on to see how that is prevented.
Lab · The read, step by step
Cosine: how close the item is to the node's centre. Mass: the node's recent items. κ: the node's concentration. d = 256, α = 0.01, half-life 48 h, as in the library's defaults.
| Option | mass on arrival | geometry κ·cos | narrowness | prior log(mass/α) | advantage (nats) |
|---|
“Narrowness” is log C(κ) minus the log of the uniform density: what a narrow node pays for concentrating its probability in a small region. The three columns add up to the node's advantage over a new story; a positive advantage means the node beats it.
In 256 dimensions, geometry decides
Section titled “In 256 dimensions, geometry decides”Look at the size of the columns. Geometry and narrowness are tens or hundreds of nats; the prior is a few. Multiplying a node’s mass by ten adds only 2.3 nats. The decision is almost always taken by the angle between the item and the centres, corrected by concentration; the prior breaks near-ties. For the same reason the posterior is nearly always close to 100 % for one option. On the Portal stream (the history of What the memory keeps):
chosen = np.array([history.share[i] for i in range(len(history))])print(f"items whose node took over 99% of the posterior: {np.mean(chosen > 0.99):.1%}")print(f"items whose node took under 60%: {np.mean(chosen < 0.6):.1%}")items whose node took over 99% of the posterior: 82.8% items whose node took under 60%: 2.0%
This gives a useful way to explain the model. Each node behaves as a cosine threshold of its own: an item enters if its cosine with the centre exceeds a value that depends on the node’s concentration. A broad theme (low κ) accepts loosely related items; a compact story (high κ) only very similar ones. Systems with a single fixed threshold treat every story alike; here each node sets its own, from how compact its story is.
Why does a cosine of 0.44 suffice for a node at the cap? Because in 256 dimensions the items of even a tight node do not sit near cosine 1, and unrelated items sit near 0. The cosine lab draws both distributions.
Surprise
Section titled “Surprise”The read also returns how unexpected the item was: , the negative log-density of the item under the whole memory, prior included. It comes out negative, because a density on a sphere of 256 dimensions can be far larger than 1 (the uniform density alone is about , which is why the very first item of a stream, read against an empty memory, has a surprise of exactly −344.3); only differences matter. Items that opened a node were, on average, 55 nats more surprising than items that joined one:
print(f"births: {history.born.sum():,} of {len(history):,} items ({history.born.mean():.1%})")print(f"mean surprise, item that opened a node: {history.surprise[history.born].mean():7.1f} nats")print(f"mean surprise, item that joined one: {history.surprise[~history.born].mean():7.1f} nats")births: 7,075 of 49,090 items (14.4%) mean surprise, item that opened a node: -336.1 nats mean surprise, item that joined one: -391.1 nats
Surprise is recorded for every item (Step.surprise, History.surprise) and is a signal in its own right: a burst of surprising items is a burst of news the memory had no place for.
The dormant node that captures items
Section titled “The dormant node that captures items”Without expiry, a narrow node that has had no items for days keeps its centre and its κ; it only loses mass, and mass barely counts. If a new item falls close to its centre, the dormant node wins, even if the live story is another one. Expiry removes nodes whose mass falls below the threshold: with expiry = 0.1 and a half-life of 48 hours, a node of one item expires after 6.6 days, a node of mass 5 after 11.3.
The read as attention
Section titled “The read as attention”For readers who come from deep learning: the read is a cross-attention layer without parameters. The item is the query, the node centres are the keys, each key has its own temperature and its own bias , and it returns the attention weights rather than a mixture of values. Nothing in it is learned: everything comes from the stored sums, which is why the weights are probabilities with a meaning.