MemoryLLM: Plug-n-Play Interpretable Feed-Forward Memory for Transformers

Ajay Kumar Jaiswal, Lauren Hannah, Han-Byul Kim, Duc N.m Hoang, Arnav Kundu, Mehrdad Farajtabar, Minsik Cho

TL;DR

This paper introduces MemoryLLM, a novel transformer architecture that decouples Feed-Forward Networks (FFNs) from self-attention, treating them as interpretable, context-free neural retrieval memories. This allows FFNs to be pre-computed as token-wise lookups (ToLs), significantly improving inference efficiency and reducing memory footprint, while also enabling deeper interpretability of FFNs.

What Problem Does This Paper Address?

Transformer-based Large Language Models (LLMs) have revolutionized AI, but understanding the inner workings of their components, particularly the Feed-Forward Networks (FFNs), remains a challenge. FFNs, which constitute a significant portion of LLM parameters, are typically intertwined with self-attention modules, making it difficult to isolate and study their specific contributions. Previous attempts to interpret FFNs as memory have been hampered by their dependency on complex, multi-pass analysis and the lack of discrete, human-interpretable query mechanisms. This paper aims to address this by proposing a new architecture that disentangles FFNs from self-attention, allowing them to function as explicit, context-free token-level retrieval memories.

Methods

The core innovation is MemoryLLM, an architecture that trains self-attention and FFN modules independently and in parallel. Crucially, FFNs are trained in isolation, directly on context-free token embeddings, rather than on the combined output of self-attention and the residual stream. This decoupling allows FFNs to be viewed as token-wise neural retrieval memories.

Key techniques include:

  • Context-Free FFN Training: FFNs are trained solely on token embeddings, making their behavior independent of the self-attention output and residual stream.
  • Token-wise Lookups (ToLs): The pre-computed FFN outputs for each token in the vocabulary can be stored as static lookups. This enables on-demand transfer between VRAM and storage, drastically reducing inference memory and computational costs.
  • TKV (Token-Key-Value) Framework: This framework provides a structured way to interpret FFN parameters as neural retrieval memory. The up-projection matrix acts as keys, the down-projection matrix as values, and a gate-projection mechanism re-weights key contributions. This allows for a finite, human-interpretable query space (the vocabulary).
  • Flex-MemoryLLM: To bridge the performance gap between MemoryLLM and conventional LLMs, Flex-MemoryLLM is introduced. It splits FFN parameters into a "compute" part (FFN-C) that operates on the residual stream and a "memory" part (FFN-M) that functions as context-free memory, offering a trade-off between performance and interpretability.

Datasets

The paper mentions training and evaluating on datasets commonly used for LLMs, including:

  • C4: Used for training and perplexity evaluation.
  • Wikitext-2: Used for perplexity evaluation.
  • LAMBDA: Used for perplexity evaluation.
  • SIQA, ARC-Easy, HellaSwag, Winogrande, BoolQ, PIQA: Used for evaluating performance on various downstream tasks, categorized into recall/retrieval and logical/reasoning tasks.
  • MT-Bench: Used for evaluating multi-turn conversational and instruction-following abilities.

No new benchmarks were introduced.

Key Insights and Ideas

  • FFNs as Explicit Retrieval Memories: The most significant insight is that FFNs can be effectively trained and interpreted as context-free, token-level retrieval memories, separate from the self-attention mechanism.
  • Semantic Similarity Maps to Memory Locations: The TKV framework reveals that semantically similar tokens tend to activate similar key-value pairs within FFN memory, suggesting a structured organization of knowledge.
  • FFNs Crucial for Recall Tasks: The study shows that FFNs play a dominant role in tasks requiring recall or retrieval of factual information, more so than in inferential or logical reasoning tasks.
  • ToLs Enable Significant Efficiency Gains: Pre-computing FFN outputs as ToLs allows for substantial reductions in active parameters during inference, enabling deployment on resource-constrained devices.
  • Layer-wise Redundancy in FFNs: Analysis of singular values suggests that FFNs in later layers exhibit more redundancy and are more amenable to compression, offering a path for efficient storage and computation.

Key Results

  • Performance on Downstream Tasks: MemoryLLM demonstrates competitive performance, particularly on recall-heavy tasks, and can achieve close to base model performance with significantly fewer active parameters when using Flex-MemoryLLM variants.
  • Efficiency Gains: ToLs enable a reduction in active parameters by up to 5x (e.g., from 1.2B to 402M active parameters for MemoryLLM-1B), leading to reduced VRAM usage and faster inference.
  • Storage Cost Reduction: Quantization (e.g., to 4-bit) and low-rank compression techniques can further reduce the storage cost of ToLs by up to 2x with minimal performance degradation.
  • Interpretability: The TKV framework provides a concrete mechanism for understanding how FFNs store and retrieve information, mapping vocabulary tokens to specific memory locations.
  • Flex-MemoryLLM Performance: Flex-MemoryLLM variants show a significant performance improvement over MemoryLLM, bridging the gap with conventional LLMs while retaining some of the interpretability and efficiency benefits. For instance, Flex-MemoryLLM-3h² (704M active parameters) outperforms a base model with 737M parameters.

Limitations and Future Work

  • Performance Gap: While MemoryLLM offers interpretability and efficiency, it may fall short of conventional dense LLMs in raw performance, especially on tasks requiring complex reasoning. Flex-MemoryLLM aims to mitigate this.
  • Storage Cost: Despite compression techniques, storing ToLs for large vocabularies and many layers can still require significant storage space, though less than active VRAM.
  • Future Work: The authors suggest further exploration of:
  • Non-uniform rank reduction techniques for ToLs to achieve even greater compression.
  • Layer-wise compression strategies for ToLs, dropping middle layers to save storage.
  • Over-parameterization ratio of FFNs in LLMs and its relationship with training dynamics.
  • Knowledge editing and injection through targeted manipulation of FFN memory keys.

Summary updated

BibTeX
@inproceedings{jaiswal2026memoryllm,
  author = {AJAY KUMAR JAISWAL and Lauren Hannah and Han-Byul Kim and Duc N.M Hoang and Arnav Kundu and Mehrdad Farajtabar and Minsik Cho},
  title = {{MemoryLLM: Plug-n-Play Interpretable Feed-Forward Memory for Transformers}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=1vshJGUVBS},
}
Figure