TL;DR
MLP Memory is a lightweight, 1-billion-parameter module that equips Large Language Models (LLMs) with the benefits of retrieval-augmented generation (RAG) without the massive latency of searching external databases. By pretraining a Multi-Layer Perceptron (MLP) stack to mimic the behavior of a $k$-Nearest Neighbor ($k$NN) retriever, the authors create a differentiable, parametric memory that is roughly 2.5× faster than RAG and significantly more accurate than standard fine-tuning.
The Problem: The Knowledge Trade-off
Currently, enhancing an LLM's factual accuracy forces a choice between two flawed paradigms:
- Retrieval-Augmented Generation (RAG): The model queries an external database for relevant documents. While excellent for accuracy, RAG suffers from high latency and shallow integration—the model merely reads the retrieved text rather than internalizing the knowledge.
- Parametric Fine-tuning (e.g., LoRA or Continued Pre-training): Knowledge is baked directly into the model's weights. This ensures fast inference but frequently triggers catastrophic forgetting, where the model sacrifices its general reasoning capabilities to memorize new facts.
The authors propose a third path: MLP Memory. This approach bridges the gap by creating an internal (parametric) module that behaves like an external retriever (non-parametric).
Methods: Retriever-Pretraining
The core innovation of this paper is Retriever-Pretraining. Instead of training a model solely to predict the next word, the researchers train an auxiliary MLP stack to imitate a $k$NN retriever.
- The Imitation Game: A $k$NN retriever is run over a massive corpus to determine the token distribution it would suggest for a given context. The MLP Memory is then trained to match this specific probability distribution.
- Hybrid Loss: The training utilizes a combination of Kullback-Leibler (KL) divergence (to match the retriever's broad distribution of possible facts) and standard Cross-Entropy (to ensure accurate ground-truth token prediction).
- Architecture & Inference: The MLP Memory consists of an 8-layer stack (roughly 1B parameters) that plugs into the base LLM. During generation, the system simply interpolates the output probabilities from the frozen base LLM with the probabilities generated by the MLP Memory.
Key Insights
- Retrieval as a Learnable Pattern: The most profound takeaway is that retrieval can be treated as a pattern to be learned. An MLP can learn the mapping of context-to-knowledge, eliminating the need to store and search terabytes of raw text during inference.
- The "Sweet Spot" for Memory: The authors discovered that attaching the memory module at 70% depth of the base model yields optimal results. This implies that early layers handle syntax, middle-to-late layers process factual retrieval, and final layers manage linguistic smoothing.
- Efficiency through Compression: MLP Memory effectively compresses a massive datastore into a compact 4GB parametric module, preserving retrieval performance while maintaining the smooth, coherent output of a parametric model.
Key Results
The researchers evaluated the system across a wide variety of benchmarks, including Knowledge QA (Natural Questions, WebQA, TriviaQA), general NLP tasks, and hallucination evaluations (HaluEval).
- Superior Accuracy: On five QA benchmarks, MLP Memory achieved a 12.3% relative improvement for Mistral-7B and a 7.8% improvement for Llama2-7B.
- Speed and Latency: It delivers 2.5× faster inference (Time to First Token) than RAG (27ms vs. 67ms) and is 5.6× faster than $k$NN-LM. It also maintains a high throughput of 36 tokens per second.
- Hallucination Reduction: On the HaluEval benchmark, MLP Memory reduced hallucinations by nearly 10 points in dialogue and QA tasks compared to the base model.
- No Catastrophic Forgetting: Unlike LoRA or Continued Pre-training (CPT)—which often degrade general capabilities—MLP Memory actually improved general NLP performance by 5.2 points.
Limitations and Future Work
- Training Cost: Training the 1B parameter MLP Memory requires a computational budget roughly equivalent to training a 7B parameter model for one epoch. While highly efficient at inference, the upfront training cost is non-trivial.
- Static Knowledge: Like any parametric method, the MLP Memory is "frozen" after training. Updating its knowledge requires retraining, whereas RAG simply requires updating the external database.
- Scaling Laws: While the paper demonstrates strong scaling behavior up to 1.5B parameters, its efficacy with frontier models (100B+ parameters) remains an open question.
Future work may focus on making these MLP memories pluggable or dynamically updatable to handle rapidly changing information landscapes.
Summary updated