Mixture of Chapters: Scaling Learnt Memory in Transformers
Organizations: IIT Kharagpur · Fractal AI
Abstract
Transformers lack an explicit architectural mechanism for storing and organizing knowledge acquired during training. We introduce learnable sparse memory banks: a set of latent tokens, randomly initialized and trained end-to-end, that transformer layers query via cross-attention to retrieve stored knowledge. To scale memory capacity without prohibitive attention costs, we propose chapter-based routing inspired by Mixture-of-Experts architectures, partitioning the memory bank into chapters and training a router to select relevant subsets per input. This enables scaling to 262K memory tokens while maintaining tractable computation. We evaluate our approach against standard transformers (in iso-FLOP settings) on pre-training and instruction fine-tuning across relevant benchmarks. Our models surpass iso-FLOP baselines suggesting scope for a new axis of scaling, demonstrating that explicit associative memory provides complementary capacity to what is captured implicitly in model parameters. Additionally, we observe improved knowledge retention under continued training, with robustness to forgetting when transitioning between training phases (e.g., pretraining to instruction fine-tuning).
Figures & tables
| Model | Val loss |
|---|---|
| Vanilla (backbone-only) | 2.92 |
| Vanilla (iso-FLOP) | 2.86 |
| Mixture of Chapters (MoC) | 2.79 |
| Vanilla (iso-FLOP) | MoC | |||||
|---|---|---|---|---|---|---|
| Benchmark | Pretrain (%) | (pp) | IFT (%) | Pretrain (%) | (pp) | IFT (%) |
| MMLU | 26.90 | -0.99 | 25.91 | 27.87 | -0.35 | 27.52 |
| ARC-C | 31.77 | -6.69 | 25.08 | 31.44 | -2.68 | 28.76 |
| BoolQ | 57.13 | -6.24 | 50.89 | 61.87 | +0.24 | 62.11 |
| OBQA | 36.20 | -2.00 | 34.20 | 37.40 | -2.00 | 35.40 |
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| Category | Representative works |
|---|---|
| Learnable internal memory bank (cross-attn / persistent tokens) | Memformer [ 53 ] , LM2 [ 26 ] , persistent memory vectors [ 44 ] , stateful memory variants [ 50 ] . |
| Large trainable memory layers (scalable access) | Memory Layers at Scale [ 4 ] , PKM [ 31 ] , EMAT [ 51 ] , Memorizing Transformers [ 52 ] . |
| Test-time / updatable memory | Titans [ 2 ] , MemoryLLM [ 48 ] , M+ [ 49 ] , Larimar [ 35 ] , EM-LLM [ 20 ] , Engram [ 9 ] . |
| Recurrence and compressive memory for long context | Transformer-XL [ 14 ] , RMT [ 6 , 7 ] , Compressive Transformers [ 39 ] , Infini-attention [ 38 ] , Cached Transformers [ 57 ] . |
| Structured/entity memories | Mention Memory [ 15 ] , Entities as Experts [ 19 ] , Facts as Experts [ 47 ] . |
| Latent-token architectures and context compression | Perceiver/Perceiver IO [ 25 , 24 ] , Flamingo [ 1 ] , Activation Beacon [ 56 ] , ICAE [ 21 ] , compressed-context memory [ 29 ] . |
| Model | Forward FLOPs | Backward FLOPs | Forward+Backward FLOPs |
|---|---|---|---|
| Vanilla (backbone-only) | 0.356T | 0.713T | 1.069T |
| Vanilla (iso-FLOP) | 0.496T | 0.992T | 1.487T |
| Mixture of Chapters (MoC) | 0.459T | 0.918T | 1.378T |
| Component | Setting |
|---|---|
| Backbone | Decoder-only transformer with 16 layers, hidden size 768, 12 attention heads, 4 KV heads, SwiGLU MLP with intermediate size 2304, RMSNorm, RoPE with , tied embeddings, vocabulary size 49152 |
| Memory placement | Memory cross-attention inserted at layers |
| Memory bank | 262,208 latent memory tokens, shared across memory layers |
| Chapter routing | 4097 total chapters, including 1 shared chapter; top- chapters selected per sequence |
| Memory attention | 12 memory query heads and 12 memory KV heads |
| Routing details | Sequence-level routing, routed scaling factor 2.5, shared/routed mixing normalized with RMSNorm |
| Setting | Pretraining | IFT |
|---|---|---|
| Tokenizer | HuggingFaceTB/SmolLM2-135M | HuggingFaceTB/SmolLM2-135M-Instruct |
| Dataset | Tasmay-Tib/fineweb-edu-10bt-split | HuggingFaceH4/ultrachat_200k |
| Data split | train / eval | train_sft / test_sft |
| Sequence length | 1024 | 2048 |
| Distributed setup | DDP on 8 GPUs | DDP on 4 GPUs |
| Batch size | 32 with gradient accumulation 4 | 32 with gradient accumulation 1 |
| Model | MMLU | ARC-C | BoolQ | OBQA |
|---|---|---|---|---|
| Vanilla (iso-FLOP) | 0.2690 | 0.3177 | 0.5713 | 0.3620 |
| MoC | 0.2787 | 0.3144 | 0.6187 | 0.3740 |
| Vanilla (backbone-only) | 0.2746 | 0.3311 | 0.5446 | 0.3340 |
| IFT setting | MMLU | ARC-C | BoolQ | OBQA |
|---|---|---|---|---|
| MoC (bank frozen) | 0.2754 | 0.2843 | 0.6214 | 0.3540 |
| MoC (bank 1/10 LR) ∗ | 0.2752 | 0.2876 | 0.6211 | 0.3540 |
| MoC (bank equal LR) | 0.2753 | 0.2943 | 0.6211 | 0.3480 |
Memory-Augmented Language Models
Memory-augmented language models combine persistent or temporary memory with neural computation to retain, retrieve, and use information beyond the active context.
See all 283 papers