NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Memory Mosaics

Jianyu Zhang, Niklas Nolte, Ranajoy Sadhukhan, Beidi Chen, Léon Bottou

In the world of Large Language Models, Transformers are the undisputed kings. However, they are notoriously difficult to interpret—often described as "black boxes" where complex behaviors like "induction heads" emerge in ways that are hard to map back to specific parameters.

A new paper from researchers at FAIR (Meta), CMU, and NYU, titled "Memory Mosaics," proposes a shift in perspective. Instead of the opaque self-attention mechanism, they introduce an architecture built from "associative memories" that work in concert. The result? A model that matches Transformer performance while being significantly more transparent and better at learning in-context.

TL;DR

Memory Mosaics are a new neural architecture that replaces standard self-attention with networks of associative memories. By training these units to predict specific future features—a process called predictive disentanglement—the model naturally decomposes complex tasks into simpler, interpretable sub-tasks, outperforming Transformers on out-of-distribution and in-context learning.

What Problem Does This Paper Address?

While Transformers are powerful, we don't fully understand how they learn to compose information. They often require multiple layers to solve simple logical tasks (like induction), and their internal states are difficult to decipher. Furthermore, they can struggle with "out-of-distribution" (OOD) tasks—situations where the data looks different from what they saw during training.

The authors sought an architecture that possesses the compositional and in-context learning capabilities of Transformers but achieves them through a more transparent mechanism. They wanted to see if they could build a system where the "division of labor" between different parts of the model happens naturally and explicitly.

Methods

The core of the "Memory Mosaic" is the Associative Memory Unit.

Associative Memory Unit Architecture
  1. Kernel Regression as Attention: Instead of the standard Query-Key-Value ($QKV$) attention, Memory Mosaics use Gaussian kernel regression (specifically the Nadaraya-Watson estimator). This is mathematically very similar to softmax attention but treats the process as retrieving a value based on a similarity metric.
  2. The "Future Peek": The key innovation is in how the model is trained. During training, the "Value" ($v_T$) in the memory unit is allowed to "peek" at the near future (e.g., the next token $x_{T+1}$). This turns each memory unit into a specialized predictor.
  3. Two Types of Memory:
    • Contextual Memory: Stores information from the current sequence (like self-attention).
  4. Persistent Memory: Stores fixed key-value pairs learned during training (like the Feed-Forward Networks in a Transformer).
  5. No Positional Encodings: Unlike Transformers, Memory Mosaics don't need explicit positional encodings. They handle time through "leaky averages" of past inputs, which the authors argue is sufficient for implementing the logic needed for language.

Datasets

The researchers evaluated Memory Mosaics across three main areas:

  • Three Moons: A synthetic "toy" dataset involving three moons orbiting a planet at different speeds. This was used to demonstrate how the model disentangles independent periodic signals.
  • BabiStories: A new dataset of "tiny stories" generated using Mixtral-8x7B. It is designed to be a controlled environment for language modeling, similar to the popular TinyStories benchmark.
  • REGBENCH: A rigorous benchmark for in-context learning that uses artificial languages defined by probabilistic finite automata (PFA).
  • Simple English Wikipedia: Used to test how well a model trained on BabiStories can generalize to a more complex, real-world distribution.

Key Insights and Ideas

  • Predictive Disentanglement: This is the "Aha!" moment of the paper. Because each memory unit is forced to be a predictor, the gradient descent process naturally "splits" the overall task. In the "Three Moons" example, instead of one big memory trying to learn the complex combined orbit, three separate units each learned to track a single moon.
Generation Error vs. Context Length
  • Transparency by Design: In a Transformer, the "Value" vector is an abstract embedding. In a Memory Mosaic, the Value is explicitly a prediction of a future feature. This makes it much easier to see what each part of the model is "looking for."
  • Efficiency in Logic: A single layer of Memory Mosaics can implement an "induction head" (the mechanism used to repeat patterns), whereas a standard Transformer requires at least two layers.
  • Meta-Learning at Scale: The authors argue that the normal training process acts as a form of meta-learning, preparing the model to quickly adapt to new patterns it sees in its context window during inference.

Key Results

  • Language Modeling: On the BabiStories task, Memory Mosaics performed as well as (and sometimes slightly better than) GPT-2 small architectures with the same number of parameters.
  • Superior In-Context Learning: On the REGBENCH benchmark, Memory Mosaics dominated. They significantly outperformed Transformers, Mamba, and RWKV, especially as the number of training environments increased.
  • OOD Generalization: When tested on Simple English Wikipedia, Memory Mosaics showed a lower per-token loss than Transformers after seeing about 50 tokens of context, suggesting they are better at "picking up" on a new style or distribution mid-stream.

Limitations and Future Work

  • Scaling: The experiments were conducted on "medium-scale" models (roughly equivalent to GPT-2 small). Whether these benefits hold at the 7B or 70B parameter scale remains to be seen.
  • Computational Complexity: Since they use kernel regression, the model still faces the $O(D^2)$ quadratic scaling issue common to standard Transformers.
  • Simple Feature Extractors: The current implementation uses relatively simple "leaky averages" for keys. The authors suggest that more sophisticated feature extractors could further improve long-range dependency handling.

In summary, Memory Mosaics offer a compelling alternative to the Transformer status quo, suggesting that by making models act more like a collection of specialized memories, we can gain both performance and clarity.

Summary updated

BibTeX
@inproceedings{zhang2025memory,
  author = {Jianyu Zhang and Niklas Nolte and Ranajoy Sadhukhan and Beidi Chen and Léon Bottou},
  title = {{Memory Mosaics}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
}
Figure