- Gemma 3 270M Continual Memory (
OnlineSlotDAM&Ternary-SpikeSide-Memory)- Method & Honest Scope
- Relation to Prior Work
- Benchmark & Baseline Results (
seeds 0..4, Gemma 3 270M MPSfloat32)- 1. Outside Baselines vs.
OnlineSlotDAM(results/baselines_gemma3-270m.json,5seeds) - 2. Internal Ablations (
results/eval_v1.json,eval_v2.json,eval_relnet_ablation.json) - 3. Error-Threshold & Ternary Key Variants (
results/eval_spiking.json, fixed monotonic clock) - 4. Cross-Model Summary (
Gemma 3 270MvsGemma 3 1B-ITvsQwen2.5-1.5B-Instruct)
- 1. Outside Baselines vs.
- Quick Start
- Method & Honest Scope
Gemma 3 270M Continual Memory (OnlineSlotDAM & Ternary-Spike Side-Memory)
Factored residual-stream side-memory adapters and 5-seed (0..4) evaluation artifacts for parser-free single-pass continual factual storage on frozen google/gemma-3-270m: 86.1%β86.7% unseen-paraphrase recall ([83.7β88.6%] per seed; 82.2% [79.1β84.4%] with 70%-silent signed ternary keys and sign-quantized error feedback), 85.9%β86.3% absolute recall after 16k streaming distractor tokens (99.8% relative retention), and 0.00020β0.00110 T4 TinyStories KL (with zero weight updates to the base Gemma weights).
Method & Honest Scope
In the GRACE / Larimar / MEMOIR / SERAC external side-memory lineage, OnlineSlotDAM keeps google/gemma-3-270m frozen and maintains a dynamic key-value table in code/online_slotdam.py:
- Subject key (
S): A lightweight causal attention-poolingKeyNet(640 β 320dims, whitened layer-12residuals at the last prompt token), trained via last-token multi-positive InfoNCE across9disjoint relations (600synthetic names drawn from~1.36 Γ 10^132-syllable pairs with separate RNG seeds) plus a generic-prose margin (l_gen) β zero subject-span labels at train or inference time. - Relation key (
R): Un-trained final-layer residual (H[17],640-dim) centered by a Bayesian online running mean (mu_r, worth+4.3 ptsover static centering and+20.3 ptsover uncenteredRawH17, while learnedRelNetoverfit at56.4%). - Value (
V), Read & Gate: Stores unit-norm unembeddingU[tok_ids[0]](first answer token only). Reads use cubic factored attentionrelu(SΒ·Ks)^3 * relu(RΒ·Kr)(beta=200), gated by raw subject familiarityfam >= thr_s0and added toH[17](alpha β 6%β10%of typical residual norm). - Write & Background Habituation: Refractory (
> 8tokens) delta-rule overwrite on matched(tau_s_m, tau_r_m)slots, otherwise allocating a new slot unlessbg_bank(2,048inv1/calib_v1.safetensors;4,096inv2/calib_v2.safetensors) flags the key as generic prose.
Transparent caveats & negative findings:
- Synthetic world + first-token scope: Recall (
T1βT3) is evaluated on synthetic240-person /3-relation (city,job,pet) worlds storing and scoring only the first answer token (U[tok_ids[0]]), not multi-token spans or open benchmarks (CounterFact/zsRE/EasyEdit GRACE/WISE, planned next).- Why
T4 KL β 0: Across20,000held-out TinyStories tokens, the familiarity gate stays closed (gate_open = 0.0on seeds0..3,0.0001[2/20,000tokens] on seed4).bg_bankprevents0β2generic slots per world from leaking; on seed4,Ternary-Spikeopens on the exact same2tokens (0.0001) as float, just with smaller logit shift (KL=0.00105vs0.00336/0.00498).- Spiking & compression framing: On
T2-noise,Scalar-PESP(0.7433 / 0.7322) andSpike-PESP(0.7344 / 0.7389) match closely, showing distractor resistance comes from thresholded error integration + per-evalguard_mode, withSpike-PESPacting as per-coordinate sign-quantized error feedback. Likewise,"16Γ smaller"(80 Bvs1,280 B) applies to320-dimKskey vectors only; each slot still stores floatKr0,V, andRes, and un-accelerated NumPy sparse key matching is172Γβ593Γslower on CPU (65.6β225.2 msvs0.38 msBLASSGEMM).
Relation to Prior Work
Places directly alongside decoupled side-memory & fast-weight architectures: GRACE (discrete layer codebook + radius gate), Larimar (one-shot gradient-free external episodic memory + scope detector), MEMOIR (sparse top-k residual key + overlap gate), WISE (gated side memory), SERAC (scope-gated edit memory), kNN-LM (final-state non-parametric retrieval), Fast Weight Programmers (delta-rule updates), Titans (surprise-gated test-time writes, used in T3 at tau_surp=4.0), Modern Hopfield, Transformer-Patcher, ROME, FlyHash (Dasgupta et al., 2017), and Gemma 3.
Benchmark & Baseline Results (seeds 0..4, Gemma 3 270M MPS float32)
All thresholds were tuned strictly on VAL_SEED=200 (vehicle/drink/teacher) and frozen for test seeds 0..4 (city/job/pet, net_seed = seed % 3).
1. Outside Baselines vs. OnlineSlotDAM (results/baselines_gemma3-270m.json, 5 seeds)
| Method | Parser-Free? | T1 held_free [minβmax] |
T1 held_cons |
T2 over_new |
T3 abs (ret) |
T4 KL (gate_open) |
Toks/Q | ms/Q |
|---|---|---|---|---|---|---|---|---|
Base-ZeroShot |
Yes | 0.0013 [0.001β0.002] |
0.0849 |
β |
β |
0.00000 (0.0%) |
10.2 |
3.9 (batch=32) |
In-Context (Clean Facts) |
Yes | 0.0761 [0.041β0.095] |
0.1015 |
0.2017 |
β |
0.20855 (100%) |
9,327 |
7.7 KV / 12.7 amort |
In-Context (Full Stream) |
Yes | 0.0789 [0.051β0.111] |
0.1133 |
0.2167 |
β |
0.55704 (100%, s0) |
18,382 |
10.8 KV / 30.3 amort |
RAG-BM25 (k=1) |
Yes | 0.3434 [0.306β0.400] |
0.4374 |
0.2450 |
0.2806 (81.9%) |
β |
34.1 |
5.9 (batch=32) |
RAG-BM25 (k=3, ungated) |
Yes | 0.4290 [0.319β0.487] |
0.6156 |
0.3606 |
0.3910 (91.7%) |
0.27047 (100%) |
83.6 |
11.3 (batch=32) |
RAG-BM25-Gated (k=3) |
Yes | 0.4290 [0.319β0.487] |
0.6156 |
β |
β |
0.00025 (0.06%) |
83.6 |
11.3 (batch=32) |
RAG-ExactName (oracle) |
No | 0.6159 [0.533β0.710] |
0.8474 |
0.4733 |
0.6159 (100.0%) |
0.00000 (0.0%) |
86.7 |
11.5 (batch=32) |
Online-Delta (v1) |
Yes | 0.8608 [0.837β0.881] |
0.8400 |
0.7800 |
0.8589 (99.8%) |
0.00070 (0.002%) |
~10.5 |
β |
Online-Delta (v2) |
Yes | 0.8650 [0.838β0.886] |
0.8500 |
0.7833 |
0.8631 (99.8%) |
0.00110 (0.003%) |
10.5 |
63.7 (stream=1) |
Ternary-Spike |
Yes | 0.8222 [0.791β0.844] |
0.8109 |
0.7067 |
0.8185 (99.6%) |
0.00020 (0.002%) |
10.5 |
52.9 (stream=1) |
(Gemma 3 270M has 512-token sliding-window attention on 15/18 layers, so 9.3kβ18.4k in-context prompting drops to 7.6%β7.9%; even oracle RAG-ExactName trails OnlineSlotDAM by 24.9 pts on T1 and 31.0 pts on T2 due to filler/conflicting context.)
2. Internal Ablations (results/eval_v1.json, eval_v2.json, eval_relnet_ablation.json)
| Arm | T1 ident |
T1 held_free [minβmax] |
T2 (new / old / untouch) |
T3 abs (ret, +bg) |
T4 KL (mean / max, gate_open s0..4) |
|---|---|---|---|---|---|
Uncentered RawH17-Delta |
0.717 |
0.658 |
0.789 / 0.062 / 0.625 |
0.658 (100%) |
0.4806 / 1.3455 |
Learned RelNet-Delta (dropped) |
0.700 |
0.564 |
0.660 / 0.094 / 0.541 |
0.563 (99.8%) |
0.5105 / 1.3841 |
Ablation-NoOnline (v1, static mu_r) |
0.900 |
0.8183 [0.778β0.846] |
0.794 / 0.098 / 0.798 |
0.8179 (99.9%, +400) |
0.00070 / 0.00371 |
Ablation-NoBgFilter (v1 / v2) |
0.946 / 0.950 |
0.8609 / 0.8649 |
0.780 / 0.783 |
0.8591 / 0.8631 (+0) |
0.5807 / 1.4115 |
Online-Delta (v1, bg_n=2048) |
0.945 |
0.8608 [0.837β0.881] |
0.780 / 0.146 / 0.846 |
0.8589 (99.8%, +432) |
0.00070 / 0.00336 (0,0,0,0,1e-4) |
Online-Delta (v2, bg_n=4096) |
0.950 |
0.8650 [0.838β0.886] |
0.783 / 0.147 / 0.851 |
0.8631 (99.8%, +853) |
0.00110 / 0.00498 (5e-5,0,0,0,1e-4) |
3. Error-Threshold & Ternary Key Variants (results/eval_spiking.json, fixed monotonic clock)
| Arm | Key (Ks) / Update |
T1 held_free [minβmax] |
T2 1-shot (over_new) |
T2-noise (w/ guard_mode) |
Update Silence | T3 abs (ret) |
T4 KL (mean / max, s4 gate) |
|---|---|---|---|---|---|---|---|
Float-Delta |
float32 / Delta |
0.8667 [0.838β0.890] |
0.7856 |
0.7822 / 0.0367 / 0.9156 (no guard) |
0.0% |
0.8648 (99.8%) |
0.00100 / 0.00498 (1e-4) |
Scalar-PESP |
float32 / scalar thr |
0.8207 [0.801β0.836] |
0.7850 |
0.7433 / 0.7322 / 0.1167 |
72.8% (skip) |
0.8173 (99.6%) |
0.00100 / 0.00494 (1e-4) |
Spike-PESP |
float32 / coord sign |
0.8219 [0.806β0.836] |
0.7283 |
0.7344 / 0.7389 / 0.0933 |
96.2% (coord) |
0.8181 (99.5%) |
0.00100 / 0.00494 (1e-4) |
Ternary-Spike |
70%-silent Ks / sign |
0.8222 [0.791β0.844] |
0.7067 |
0.7400 / 0.7111 / 0.0644 |
93.4% (coord) |
0.8185 (99.6%) |
0.00020 / 0.00105 (1e-4) |
FlyHash-Bin |
93.75%-silent {0,1} |
0.6081 [0.554β0.655] |
0.4656 |
0.6200 / 0.5178 / 0.1378 |
93.6% (coord) |
0.6022 (99.0%) |
0.00000 / 0.00000 (0.0) |
4. Cross-Model Summary (Gemma 3 270M vs Gemma 3 1B-IT vs Qwen2.5-1.5B-Instruct)
| Model | Arm | T1 held_free |
T2 over_new |
T2-noise (new / keep) |
T3 abs (ret) |
T4 KL (mean / max) |
|---|---|---|---|---|---|---|
Gemma 3 270M |
Float-Delta / Ternary-Spike |
0.867 / 0.822 |
0.786 / 0.707 |
0.740 / 0.711 (tert) |
0.865 / 0.819 (99.8% / 99.6%) |
0.00100 / 0.00020 (0.00105) |
Gemma 3 1B-IT (ablation) |
Float-Delta / Spike / Ternary |
0.696 / 0.673 / 0.573 |
0.604 / 0.565 / 0.503 |
0.584 / 0.523 (spike) |
0.686 / 0.662 / 0.568 (~98.6%) |
0.00030 / 0.00133β0.00149 |
Qwen2.5-1.5B-IT |
Float-Delta / Spike / Ternary |
0.735 / 0.695 / 0.739 |
0.689 / 0.514 / 0.622 |
0.753 / 0.680 (tert) |
0.723 / 0.685 / 0.724 (97.9%β98.5%) |
0.00000 / 0.00000 (5/5) |
Quick Start
import sys, torch
from huggingface_hub import snapshot_download
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = snapshot_download("jordanrburger/gemma3-270m-continual-memory")
sys.path.insert(0, f"{repo}/code")
from online_slotdam import GemmaSlotMemory
device = "mps" if torch.backends.mps.is_available() else ("cuda" if torch.cuda.is_available() else "cpu")
tok = AutoTokenizer.from_pretrained("google/gemma-3-270m")
model = AutoModelForCausalLM.from_pretrained("google/gemma-3-270m", dtype=torch.float32).to(device).eval()
# profile="v1" (calib_v1, 2048 bg), "v2" (calib_v2, 4096 bg, max_bg_rate=0), or "ternary_spike"
mem = GemmaSlotMemory(model, tok, repo_dir=repo, seed=0, profile="ternary_spike", device=device)
mem.remember("The home city of Mara Velt is", " Tokyo")
print(mem.predict_next("Everyone knows that Mara Velt comes from"))
checkpoints/{k_attn_s0..2,calib_v1,calib_v2}.safetensorsβKeyNet& calibration banks (calib_v2adds4,096-tokenv2banks).code/{online_slotdam,demo_gemma3}.py,config.json,results/{tuning_*,eval_*,baselines_gemma3-270m}.json.
- Downloads last month
- -
Model tree for jordanrburger/gemma3-270m-continual-memory
Base model
google/gemma-3-270m