Memory Decoder: A Pretrained, Plug-and-Play Memory for Large Language Models
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 nearestneighbor 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.
Introduction. Large Language Models (LLMs) have demonstrated remarkable capabilities across a wide range of natural language processing tasks (Grattafiori et al., 2024; Yang et al., 2024; Liu et al., 2024; Guo et al., 2025). Pretrained on vast corpora of general text data, LLMs have revolutionized how we approach language understanding and generation tasks. However, despite their impressive general capabilities, adapting LLMs to perform optimally in specific domains remains a significant challenge. Domain-specific adaptation is crucial for applications in specialized fields such as biomedicine, finance, and law (Chen et al., 2023; Liu et al., 2023b; Colombo et al., 2024), where domain expertise and terminology are essential for accurate and reliable performance.
Discussion / Conclusion. In this paper, we introduced Memory Decoder, a novel plug-and-play approach for domain adaptation of large language models. By pre-training a small transformer decoder to emulate the behavior of non-parametric retrievers, Memory Decoder effectively adapts any compatible language model to a specific domain without modifying its parameters. Our comprehensive experiments across multiple model families and specialized domains demonstrate that Memory Decoder consistently outperforms both parametric adaptation methods and traditional retrieval-augmented approaches.
Lines of inquiry this paper opens 24
Research framings built by reading the notes related to this paper — the questions it feeds into.
What mathematical limits constrain embedding-based retrieval systems?- Can discrete codes and embedding injection both solve the text versus identity tradeoff?
- Can embedding tables be efficiently adapted per downstream domain?
- Why does text encoding create different subspaces across domains?
- Why do bi-encoder retrievers sacrifice effectiveness for latency in two-stage ranking?
- What makes retrieval augmentation more effective than simply increasing embedding size?
- Why does pure numeric ID indexing force models to learn from scratch?
- Do Doc2Query approaches suffer from the same misaligned-target problem?
- How does retrieval-augmented generation extract structured properties from domain descriptions?
- Why does domain-specific terminology require customization of vector search and generation?
- What makes web retrieval more effective than static knowledge bases?
- What hidden costs might fine-tuning retrieval models introduce on out-of-distribution queries?
- Can semantic query expansion overcome vocabulary mismatch in corrupted text?
- Could eliminating retrieval entirely work better than shifting the burden?
- What documents improve answers beyond surface query similarity?
- Can temporal ranking improve retrieval without modifying the underlying video model?
- How can inference-time retrieval avoid the domain boundary problem?
- How does semantic mismatch between user language and API documentation degrade tool retrieval?