Larimar: Large Language Models with Episodic Memory Control

Payel Das, Subhajit Chaudhury, Elliot Nelson, Igor Melnyk, Sarathkrishna Swaminathan, Sihui Dai, Aurelie Lozano, Georgios Kollias, Vijil Chenthamarakshan, Jiri Navratil, Soham Dan, Pin-Yu Chen

Abstract

Larimar introduces a brain-inspired architecture that equips Large Language Models (LLMs) with a distributed episodic memory, facilitating rapid, "one-shot" knowledge updates without the need for retraining. Drawing from Complementary Learning Systems (CLS) theory, Larimar utilizes a memory module based on the Kanerva Machine to perform updates via a pseudo-inverse method. Experimental results demonstrate that Larimar achieves 8-10x speedups over existing model-editing baselines, maintains high retention across sequential updates, and supports native selective forgetting and long-context generalization.

1. Introduction

Standard Large Language Models (LLMs) are effectively "frozen" after their initial training phase. When facts change or errors are discovered, updating the model's internal knowledge is a significant challenge. Traditional fine-tuning is computationally expensive and risks "catastrophic forgetting," where the model loses existing knowledge while learning new information. Existing model-editing techniques, such as ROME or GRACE, attempt to modify specific weights or use external caches but often struggle with scalability and performance degradation during sequential updates. Larimar addresses these limitations by providing a unified, efficient framework for both learning and unlearning information.

2. Methods

Larimar is inspired by the Complementary Learning Systems (CLS) theory of the human brain, where the hippocampus handles rapid episodic learning while the neocortex slowly extracts general patterns.

2.1 The Memory Module

Larimar implements a hierarchical memory structure based on the Kanerva Machine architecture. It uses a distributed memory matrix where writing and reading are treated as Bayesian inference. Updates are performed via a "pseudo-inverse" method, allowing the system to store new information in a single pass by solving a linear system. This approach avoids the need for backpropagation during the editing phase.

The LLM (acting as the neocortex) is conditioned on the memory's readout. Larimar encodes input into a latent space, retrieves the relevant "episode" from memory, and injects this information into the LLM's decoder as a compressed Key-Value (KV) cache. For long-context processing, Larimar employs a recursive search in its latent memory space, enabling it to process sequences significantly longer than its original training window. An optional scope detector determines if a query is "in-scope" (related to memory) or should be handled by the base LLM’s internal knowledge.

3. Experimental Setup

The researchers evaluated Larimar using several benchmarks, including CounterFact (for counterfactual edits), ZsRE (Zero-Shot Relation Extraction for QA), WikiText (for general language capability), and CNN Fast Facts (for long-context generalization). The architecture was tested using both GPT-2 and GPT-J as the base decoder models.

4. Key Results

Larimar demonstrates significant improvements over current state-of-the-art model-editing techniques:

  • Speed and Efficiency: Larimar is 8-10x faster than competitive baselines. For a single edit, Larimar requires approximately 1.1s, compared to 4.8s for ROME on GPT-2.
  • Sequential Robustness: Unlike other methods that degrade as more facts are added, Larimar maintains a high Edit Retention Rate (0.97) even after 1,000 sequential updates.
  • Precise Forgetting: Because memory updates are mathematical operations, "forgetting" is achieved by applying the inverse operation ($\alpha = -1$). This allows for one-shot deletion of facts, effectively preventing information leakage under rephrasing attacks.
  • Context Generalization: Larimar successfully recalled facts from contexts exceeding its training window, outperforming models specifically trained for long-context tasks, such as Mistral-7b, in specific recall scenarios.

5. Discussion and Limitations

Larimar’s distributed memory allows it to compress more facts than it has physical rows, making it highly efficient. Furthermore, the architecture is LLM-agnostic, meaning it can be integrated with various transformer-based decoders.

However, limitations remain. The system is currently optimized for sentence-level factual updates; handling complex, multi-sentence narratives or complex logical reasoning across stored facts is an ongoing challenge. Additionally, there is a theoretical limit to memory saturation; accuracy may drop when the number of stored facts significantly exceeds the memory size $K$.

6. Conclusion

Larimar provides a robust, brain-inspired solution for the dynamic update of LLMs. By treating memory as a distributed, differentiable structure, it enables rapid knowledge acquisition and selective forgetting, paving the way for more adaptable and efficient AI systems.

Summary updated

BibTeX
@inproceedings{das2024larimar,
  author = {Payel Das and Subhajit Chaudhury and Elliot Nelson and Igor Melnyk and Sarathkrishna Swaminathan and Sihui Dai and Aurelie Lozano and Georgios Kollias and Vijil Chenthamarakshan and Jiri Navratil and Soham Dan and Pin-Yu Chen},
  title = {{Larimar: Large Language Models with Episodic Memory Control}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=t8mt4YrPsq},
}
Figure