Trained Persistent Memory for Frozen Encoder--Decoder LLMs: Six Architectural Methods
Organizations: Inha University in Tashkent, Uzbekistan
Abstract
Frozen encoder--decoder language models are stateless: the latent representation is discarded after every forward pass, so no information persists across sessions. This paper presents a proof-of-concept pilot study showing that persistent memory in the continuous latent space of a frozen LLM is feasible -- even under severe resource constraints (a single frozen Flan-T5-XL backbone, small trainable adapters, a single dataset). We implement six architectural methods spanning three injection points and four write mechanisms; unlike text-level memory systems, every write and read is a differentiable operation on dense vectors. After training only the adapter, the memory bank continues to accumulate at inference time without gradients, enabling conversational learning. Under a forgetting-curve evaluation on LoCoMo at two capacity scales (1 and 10), the stateless baseline scores exactly zero; at 10 all six trained adapters produce positive memory-recall curves; at 1 three methods collapse, revealing capacity as a critical design parameter. Because the memory bank is a compact numerical array, it can be scaled to arbitrarily large capacity without altering the backbone. We argue that full end-to-end training with larger models, larger data, and orders-of-magnitude larger memory will yield substantially stronger results; this pilot study establishes the feasibility baseline and design-space taxonomy that such efforts require.
Figures & tables
| Method | Write rule ( ) | Read rule (inject into decoder) | Type | |
|---|---|---|---|---|
| 0 | Baseline | — | — | |
| 1 | Prefix | , | (extra KV) | Delegated |
| 2 | XAttn | , | Explicit | |
| 3 | KV Extension | , | Delegated | |
| 4 | Hebbian | (extra KV) | Explicit | |
| 5 | Gated | , | , | Explicit |
| Method | Injection point | Primary-path safe | New params | Mem. cost | Write mechanism | |
|---|---|---|---|---|---|---|
| 1 | Encoder-input prefix | Before | ✓ | 4.2M | const. | |
| 2 | Parallel decoder XAttn | Inside | ✓ | 16.8M | const. | |
| 3 | Decoder KV extension | Inside xattn | ✓ | 4.2M | const. | |
| 4 | Hebbian / associative | Decoder KV | ✓ | 1.0M | Hebbian outer prod. | |
| 5 | Context-gated decoder branch | Inside | ✓ | 21.0M | const. | |
| 6 | Slot-based sparse write | Decoder KV | ✓ | 4.2M | Top- overwrite |
| Lag bucket (turns) | ||||||
| Method | 0–31 | 32–63 | 64–127 | 128–255 | 256+ | Mean |
| (samples) | 28 | 24 | 62 | 130 | 395 | |
| 1 capacity ( , ) | ||||||
| M.0 Baseline | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| M.1 Prefix | 0.02 | 0.02 | 0.02 | 0.02 | 0.02 | 0.02 |
| M.3 KV Ext | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| Method | (%) | (%) |
|---|---|---|
| M.0 Baseline | 5.57 | 5.57 |
| M.1 Prefix | 0.00 | 0.00 |
| M.3 KV Ext | 0.00 | 0.00 |
| M.5 Gated | 0.17 | 0.17 |
| M.2 XAttn | 11.04 | 7.34 |
| M.4 Hebbian | 10.62 | 7.84 |
| 1 capacity | 10 capacity | |||
|---|---|---|---|---|
| Method | Tax (%) | Benefit (%) | Tax (%) | Benefit (%) |
| M.1 Prefix | +2.38 | 6.42 | +4.23 | +4.00 |
| M.2 XAttn | +3.39 | +6.76 | +3.39 | +5.09 |
| M.3 KV Ext | +2.38 | 6.44 | +4.23 | +6.26 |
| M.4 Hebbian | +3.39 | +3.10 | +3.39 | +5.46 |
| M.5 Gated | +3.39 | 6.30 | +3.39 | +1.83 |
Persistent Memory for Language Models
Persistent memory for language models studies how models retain, update, and use information across interactions and beyond their context windows.
See all 271 papers