Skip to content

What the memory keeps

The state of a Memory is a table with one row per node, at most max_nodes rows. Each node keeps three statistics, all forgotten at the same rate:

Statistic Attribute What it is Update
SkS_k Memory.S[k] (d numbers) Forgotten sum of the points written to the node: an arrow pointing where its items point, mostly the recent ones. Add the item’s point zz.
NkN_k Memory.N[k] Mass: how many items it received, counting old ones less. An item two days old counts 0.5. Add 1 per item, or its share.
nkn_k Memory.n[k] Pseudo-mass without direction: prior_mass at birth, then only forgotten. Keeps a young node from being absurdly narrow. Only forgotten.

From these three statistics the centre and concentration of the node follow at any moment:

μk=Sk∥Sk∥,Rˉk=∥Sk∥Nk+nk,κk=min⁡ ⁣(Rˉk (d−Rˉk2)1−Rˉk2, κmax⁡)\mu_k = \frac{S_k}{\lVert S_k \rVert}, \qquad \bar R_k = \frac{\lVert S_k \rVert}{N_k + n_k}, \qquad \kappa_k = \min\!\left(\frac{\bar R_k\,(d - \bar R_k^2)}{1 - \bar R_k^2},\ \kappa_{\max}\right)

The centre is the direction of the sum. The mean resultant length Rˉ\bar R compares the length of the sum with the number of items. The concentration converts Rˉ\bar R into κ\kappa with the approximation of Banerjee et al. (2005), capped at max_concentration. Memory.nodes() returns all of them for the active nodes.

Add unit arrows that all point the same way and the sum is exactly as long as the number of arrows: Rˉ=1\bar R = 1. If they point in scattered directions they partly cancel and the sum is short: Rˉ\bar R near 0. So Rˉ\bar R measures how compact a story is, without storing its items.

Lab · Adding arrows

A drawing in two dimensions to see the idea. The κ values are those the same R̄ would give in 256 dimensions. Click the circle to add items to a node.

The blue arrow is the sum divided by N + n₀; its length is R̄. With one item and no pseudo-mass, R̄ would be 1 and the concentration infinite: the node would accept only exact copies of its first item.

The pseudo-mass solves the newborn node. With one item, Rˉ=1/(1+1)=0.5\bar R = 1/(1+1) = 0.5, which gives κ≈170\kappa \approx 170 in 256 dimensions: a reasonably open node. As items arrive its relative weight dilutes. Because it is forgotten at the same rate as the mass, forgetting does not change a node’s concentration: a dormant node keeps its shape and only loses weight.

The cap stops a spiral. A node contains only the items it accepted, and it accepts only those that already resemble it. So it underestimates its own spread, narrows, accepts even more similar items, and narrows further. The cap cuts the spiral, and it matters: on the paper’s development stream, B³ F1 is 0.851, 0.865 and 0.821 with caps of 250, 500 and 1000, and 0.793 with no cap at all.

After reading the nine years of the Portal with Memory() (the quickstart shows how), the table looks like this:

memory = Memory().fit_projection(reference)
history = memory.read(embeddings, hours)
nodes = memory.nodes()
live = nodes.mass >= 0.1
at_cap = nodes.concentration >= memory.max_concentration - 1e-6
print(f"{len(nodes)} rows in use; {live.sum()} hold a mass of at least 0.1, the rest are fading")
print(f"live nodes at the cap of {memory.max_concentration:.0f}: {at_cap[live].mean():.0%}, "
f"holding {nodes.mass[live & at_cap].sum() / nodes.mass[live].sum():.0%} of the live mass")
print(f"median kappa of the live nodes: {np.median(nodes.concentration[live]):.0f}")
Output
256 rows in use; 55 hold a mass of at least 0.1, the rest are fading
live nodes at the cap of 500: 58%, holding 41% of the live mass
median kappa of the live nodes: 500

All 256 rows are in use, but only 55 nodes still hold a mass above 0.1: the rest are stories that ended weeks ago, fading but not removed, because Memory() has no expiry and a row is only reused when a new node needs it. Of the live nodes, more than half sit at the cap: the spiral is real, and the cap is what bounds it. In the memory explorer you can change the cap and watch the effect.