Dissecting AI
All modules

Pair-Targeted Kronecker Delta Memory Updates

Hebbian writes can bury an old association and ordinary delta updates can disturb overlapping pairs; the Kronecker Delta Rule corrects one pair’s scalar association along that pair’s rank-one direction.

The short version

What it is

  • Pair score A memory can be queried for how strongly it links a particular key with a particular value.
  • Targeted correction Instead of adding another association or changing a whole retrieved vector, adjust that pair’s score toward a chosen target.
  • Rank-one update The change follows the presented pair’s own value-by-key pattern, so unrelated directions are less disturbed.

Why it matters

Ordinary additive writes can bury old associations, while vector-valued corrections can affect other pairs that share a key. Pair-targeted scalar correction offers revision and erasure with interference gated by both key and value overlap.

Before getting into the mechanics, here is the short version: this rule treats a key–value pair as an address for one scalar score. If the score is wrong, it changes the memory in the direction made by that same pair, rather than letting the memory’s current contents decide where the correction goes. That makes revision more targeted, though overlapping pairs can still interfere.

  1. Revision: A basic linear-attention memory adds an outer product for each new pair. Think of it as keeping notes: adding a new note does not go back and correct the old one, and enough later notes can bury it. The canonical example is presenting the same key and value again with a different desired association. An additive write just adds more; a revision rule needs to compare what the memory currently says with what you want it to say. The notebook analogy is limited because the memory is a matrix, not a set of separate pages.

  2. Choose what to correct: The ordinary Delta Rule corrects a retrieved value vector: it checks what the memory returns for a key and pushes that vector toward the desired value. That can alter other associations that share some of the key’s direction. Here the canonical example is a key that overlaps with another stored key: changing the retrieved vector for the first can tug on the second. So the real question was never just whether memory can revise; it was whether the correction can be aimed at one pair’s own association.

The Kronecker Delta Rule makes that choice by asking for one scalar: how strongly does this memory link this key with this value? In symbols, the score is v⊤Skv^\top Sk — the value vector probes the memory’s response to the key. In words, it is one number measuring this pair’s current association, not the entire retrieved vector. The rule moves that number toward a target. For example, a target of zero means “erase this pair’s score”; a nonzero target says how strong the association should be.

  1. Limit the collateral change: Imagine a memory update as changing one pattern in a notebook rather than erasing a whole page. The pattern here is the pair’s value-by-key outer product, and the scalar error determines how much to change it. The formula is St+1=St+β(c−v⊤Sk)vk⊤S_{t+1}=S_t+\beta(c-v^\top Sk)vk^\top. In words, subtract the current score from the target, then add that error times the pair’s own pattern. The step size is the knob: a small step makes a smaller correction. This is like choosing what not to carry to the next town, except the analogy breaks because non-orthogonal patterns can overlap rather than being cleanly separate items.

That overlap is the important caveat. Another pair is protected if either its key direction or its value direction is orthogonal to the updated pair; otherwise both overlaps can contribute to interference. Overall, I like the precision of this update, but it does not make arbitrary associations independent. So the remaining question is: how much overlap can a particular collection of pairs tolerate before the memory stops behaving like separate addresses?

Read the deep dive

Why People Wanted It

A matrix memory can store key–value associations by adding each pair’s outer product. But additive writes do not revise an association; later writes can bury it. The ordinary Delta Rule does revise, yet its correction depends on the memory’s current retrieval, so a write can disturb other associations whose keys overlap. The real question is whether you can correct the score of one chosen pair without letting the memory’s other contents choose the direction of that correction.

The Core Move

Correct the scalar score for the presented key–value pair, and move the memory only along that pair’s outer product:

St+1=St+βt(ct−vt⊤Stkt)vtkt⊤.S_{t+1}=S_t+\beta_t(c_t-v_t^\top S_tk_t)v_tk_t^\top.

Here vt⊤Stktv_t^\top S_tk_t is the pair’s current score, ctc_t is its target, and βt\beta_t controls the correction size. The update is rank one: the pair itself supplies the direction, while the scalar residual says how far to move.

Quiz
What determines the direction of a Kronecker Delta Rule memory update?
The difference between the entire retrieved vector and the target vector
A fixed direction independent of the presented pair
The key overlap with every previously stored association
The presented value–key outer product, scaled by the scalar score error

Why the Scalar Score Changes the Correction

Here is the part that gets technical: the key distinction is between correcting a whole retrieved value and correcting one scalar association. A matrix memory SS maps a key kk to a value-like vector SkSk. The ordinary Delta Rule compares that vector with the desired value, using residual Sk−vSk-v. The Kronecker Delta Rule instead asks for the scalar bilinear score v⊤Skv^\top Sk and compares it with scalar target cc.

Write a=k⊗v=vec⁡(vk⊤)a=k\otimes v=\operatorname{vec}(vk^\top) and s=vec⁡(S)s=\operatorname{vec}(S). Then v⊤Sk=a⊤sv^\top Sk=a^\top s, so the update becomes st+1=st+βt(ct−at⊤st)ats_{t+1}=s_t+\beta_t(c_t-a_t^\top s_t)a_t. In words, this is a scalar error-correction step along the feature vector belonging to the pair. The target sets the desired score; the memory’s other entries do not set the direction.

For a repeated pair, the scalar error contracts by the factor 1−βt∥at∥21-\beta_t\|a_t\|^2. Thus a positive step size below 2/∥at∥22/\|a_t\|^2 contracts the error, and the step size 1/∥at∥21/\|a_t\|^2 reaches the target in one update. What does making the direction pair-specific buy when other associations are present?

Why the Rank-One Direction Limits Interference

Now the version for readers who want more of the machinery: the update matrix is always a scalar multiple of vk⊤vk^\top, so it changes SS only in that rank-one direction. For a test pair (k′,v′)(k',v'), the change in its read-out is proportional to (v′⊤v)(k⊤k′)(v'^\top v)(k^\top k') times the current pair’s scalar residual. In words, both the key overlap and the value overlap must be present for this update to alter that other pair’s score.

That gives an exact protection condition: if either k′⊥kk'\perp k or v′⊥vv'\perp v, the test pair’s bilinear read-out is unchanged. This is more selective than interference controlled by key overlap alone. It is not universal isolation: non-orthogonal pairs can still interact, and an inaccurate current score leaves a residual that can produce that interaction. So what if the goal is not merely to revise a score, but to erase it?

Why the Target Enables Erasure

Here is the deeper consequence: setting c=0c=0 asks the update to drive the presented pair’s scalar score to zero, rather than to store a particular output vector. For the same pair, this is the same contraction of its scalar error toward the chosen target; with the one-step size 1/∥k⊗v∥21/\|k\otimes v\|^2, the score reaches that target in one update.

The update can also be split into an erase term and a write term by expanding the residual: St+1=St−βt(vt⊤Stkt)vtkt⊤+βtctvtkt⊤S_{t+1}=S_t-\beta_t(v_t^\top S_tk_t)v_tk_t^\top+\beta_tc_tv_tk_t^\top. The first term subtracts the pair’s current contribution along its direction; the second adds the target-scaled pair direction. This is targeted erasure of a bilinear association, not a guarantee that every other non-orthogonal association is untouched. How much protection and capacity do you get from this pair-addressed view?

Minimal Causal Code

The loop below exposes the state change directly; it is intentionally not optimized.

import torch

def kronecker_delta(memory, keys, values, targets, beta):
    # memory: [value_dim, key_dim]
    for key, value, target, step_size in zip(keys, values, targets, beta):
        current_score = value @ memory @ key
        residual = target - current_score
        memory = memory + step_size * residual * torch.outer(value, key)
    return memory

Each iteration measures one pair’s score, forms its scalar error, and adds only the pair’s outer-product direction to memory.

What You Gain, and What You Lose

You gain a revision rule whose correction direction is determined by the presented pair, scalar error correction for that pair, and doubly gated interference: both key and value overlap matter. You can set the target to zero to erase that pair’s score. In a vectorized view, each pair imposes one scalar linear constraint on the memory, so independent pair features can represent scalar associations.

You do not get perfect isolation for arbitrary pairs: overlapping keys and values can still cause crosstalk. Nor is this the same objective as retrieving a whole value vector; it targets the scalar bilinear association. Step size still matters, and this rule by itself says nothing about a complete sequence-mixer architecture or its execution strategy.

Quiz
When is another pair’s bilinear read-out exactly protected from a Kronecker Delta update?
When either its key or its value is orthogonal to the updated pair’s corresponding vector
Whenever its key differs from the updated key, even if they overlap
Only when both its key and value are identical to the updated pair
For all other pairs, regardless of overlap
Core Takeaway

The Kronecker Delta Rule revises a pair’s scalar score by moving memory only along that pair’s own outer-product direction.