DHM: A Differentiable Hippocampal Memory Layer for Continual Knowledge Injection into Frozen Language Models
Abstract
Large language models (LLMs) store knowledge in frozen weights, and teaching a pretrained model to remember new, training-time-unseen content remains difficult. External text memory (retrieval-augmented generation, tool calling) keeps knowl- edge outside the model, but its interface is textual and discrete: retrieved strings must be re-encoded into the model’s continuous representation space, and function calls are not differentiable. We propose a Differentiable Hippocampal Memory layer (DHM): a small, always-on, trainable network attached to a frozen LLM that reads and writes memory directly in the model’s hidden-state space. DHMnever returns text; it returns a continuous vector ∆h injected into the frozen model at a chosen layer. A learned gate multiplies the memory output: when no relevant mem- ory is found the gate is trained toward zero so that ∆h ≈ 0 (zero-when-absent), and when memory is found the gate opens and injects the stored matrix. Memory is written in a stage-1 block-training phase that freezes the LLM and updates only the memory layer; in a stage-2 phase, the memory layer is frozen and only the gate threshold is trained. On synthetic fact-injection benchmarks, DHMrecovers 87.5–100% of 8 novel facts and 60% of 100 novel facts, outperforming LoRA (50% / 16%) and a hidden-state–based RAG baseline (75% / 19%), with the gap widening as the number of facts grows. On unseen facts, the gate closes to 0.024, demonstrating the zero-when-absent behavior. We also report two negative results: injecting at multiple layers hurts rather than helps, and recall saturates at about 60% of 100 facts regardless of whether the memory has 64 or 128 slots, indicating that the bottleneck is the gradient-based write mechanism rather than slot capacity. Our results position differentiable matrix memory as a promising complement to both weight editing and text retrieval, and we outline a hippocampal consolidation loop as the next step.