Bounded Adaptive Hebbian Fast-Weight Cache
Source paper: Where Should Experience Live? Hierarchical Hebbian Memory for Continual Vision Transformers arXiv:2609.00358 ⓘ · analyzed Sep 2, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Add a recurrent associative matrix to each selected transformer layer so recent key-value relationships can be retrieved without retaining every past token or performing gradient updates. The matrix uses input-dependent retention and write gates, but retrieval is always performed from the pre-write state, preventing the current target from leaking into its own prediction. Frobenius-norm clipping makes the recurrent memory bounded and provides a direct stability control.
Formulas
Mathematical statement
The paper forms projected keys and values from the layer input X_t: Q_t=X_tW_Q, K_t=X_tW_K, and V_t=X_tW_V, where X_t is in R^{T x d}, T is the number of tokens, W_Q, W_K, and W_V are learned projection matrices, and d is the projection width. The key-value coactivation matrix is A_t=clip(K_t^T V_t/sqrt(T)), where A_t is in R^{d_k x d_v}, d_k and d_v are key and value widths, and clip is elementwise clipping to a fixed interval. The memory recurrence is M_t=clipnorm(lambda_t M_{t-1}+eta_t A_t,c_M), where M_{t-1} is the state available before the current write, lambda_t in [0,1] is retention, eta_t is nonnegative write strength, and c_M is the maximum Frobenius norm. Define clipnorm(Z,c)=Z min(1,c/(||Z||_F+epsilon)). The adaptation reads the old state with Y_t^mem=Q_t M_{t-1} and writes only after producing the layer output. This creates a bounded linear dynamical system when lambda_t is below one, while eta_t controls rapid association formation.
Implementation notes
1. Integration point: add one memory branch to a transformer self-attention block, preferably after the Q/K/V projections and before the output projection. Maintain one matrix M per attention head or per layer, with shape d_k by d_v; detach it from autograd between examples or episodes so it behaves as state rather than an ever-growing computation graph. Compute standard self-attention as usual, and compute the auxiliary memory values Y_mem=Q M_old. Add this branch to the normal attention output with a learned scalar mixing gate.
2. Pseudocode:
state M_old = zeros(d_k, d_v)
for each sequence X:
Q = X @ WQ; K = X @ WK; V = X @ WV
h = mean(X, axis=tokens)
lambda = sigmoid(controller_lambda(h))
eta = softplus(controller_eta(h))
Y_mem = Q @ stop_gradient(M_old)
Y_attn = softmax(Q @ K.T / sqrt(d_k)) @ V
Y = Y_attn + sigmoid(controller_mix(h)) * Y_mem
A = clip((K.T @ V) / sqrt(T), -a_max, a_max)
Z = lambda * M_old + eta * A
M_new = Z * min(1, c_M / (frobenius_norm(Z) + 1e-6))
emit prediction from Y
M_old = stop_gradient(M_new)
The displayed equations define A, the recurrence, and the bounded read/write mechanism. The controller functions g_lambda and g_eta can be small learned linear layers or a two-layer MLP. Estimate no mathematical constants: c_M, a_max, and the initial memory mixing coefficient are hyperparameters. Log ||M||_F, average lambda, average eta, and the ratio of memory-branch to attention-branch norms to detect saturation or collapse.
3. First experiment: implement this in a 2-4 layer ViT-Tiny or small causal transformer on sequential Omniglot 5-way 1-shot episodes and a CORe50-style class-incremental stream. Compare against the same backbone with no memory, a fixed-retention fast-weight recurrence with constant lambda and eta, and a replay buffer or recurrent-attention baseline with matched parameter and memory budgets. Train the controller and projection layers initially, then jointly train all parameters. The primary success signal is higher delayed-association accuracy after distractor episodes at equal stored-state bytes; secondary signals are lower forgetting, stable bounded ||M||_F, and faster adaptation than the no-memory baseline. An ablation removing read-before-write should be tested for artificial same-step gains or worse held-out temporal accuracy.
Verification
This idea has not been verified yet.
Verification happens in two stages: Stage 1 — a mechanism check on a toy system confirms the claimed mathematical phenomenon reproduces; Stage 2 — a benchmark implements the idea on a real (small) neural network task and compares it against a tuned baseline over 8 paired seeds with a permutation test.
Artifacts
Artifacts unavailable.