Memory Decoder: A Pretrained, Plug-and-Play Memory for Large Language Models

Jiaqi Cao, Jiarui Wang, Rubin Wei, Qipeng Guo, Kai Chen +2 more
8/13/2025
cs.CLcs.AI

No official code found. Best implementation: LUMIA-Group/MemoryDecoder (75 stars, Apache-2.0, last commit 2025-09-29).

Abstract

Large Language Models (LLMs) have shown strong abilities in general language tasks, yet adapting them to specific domains remains a challenge. Current method like Domain Adaptive Pretraining (DAPT) requires costly full-parameter training and suffers from catastrophic forgetting. Meanwhile, Retrieval-Augmented Generation (RAG) introduces substantial inference latency due to expensive nearest-neighbor searches and longer context. This paper introduces Memory Decoder, a plug-and-play pretrained memory that enables efficient domain adaptation without changing the original model's parameters. Memory Decoder employs a small transformer decoder that learns to imitate the behavior of an external non-parametric retriever. Once trained, Memory Decoder can be seamlessly integrated with any pretrained language model that shares the same tokenizer, requiring no model-specific modifications. Experimental results demonstrate that Memory Decoder enables effective adaptation of various Qwen and Llama models to three distinct specialized domains: biomedicine, finance, and law, reducing perplexity by an average of 6.17 points. Overall, Memory Decoder introduces a novel paradigm centered on a specially pretrained memory component designed for domain-specific adaptation. This memory architecture can be integrated in a plug-and-play manner, consistently enhancing performance across multiple models within the target domain.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

The official implementation of the paper "Memory Decoder: A Pretrained, Plug-and-Play Memory for Large Language Models" (NeurIPS 2025 Poster).

7510Shell, PythonSep 22, 20251 years agoApache-2.0

Similar Papers

Cite this paper

@article{cao2025memory,
  title  = {Memory Decoder: A Pretrained, Plug-and-Play Memory for Large Language Models},
  author = {Jiaqi Cao and Jiarui Wang and Rubin Wei and Qipeng Guo and Kai Chen and Bowen Zhou and Zhouhan Lin},
  year   = {2025},
  eprint = {2508.09874},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2508.09874v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2508.09874.svg)](https://codeofpaper.com/paper/2508.09874)

Discussion