Raven: High-Recall Sequence Modeling with Sparse Memory Routing

Arshia Afzal, Aviv Bick, Eric P. Xing, Volkan Cevher, Albert Gu

TL;DR

Raven is a new linear-time sequence model that solves the long-context recall bottleneck by decoupling where information is written from how long it persists. By using sparse, input-dependent routing to update only a selected subset of memory slots, Raven prevents information interference and achieves exceptional length extrapolation up to 16× its training length without sacrificing general language modeling performance.

What Problem Does This Paper Address?

Linear-time sequence models, such as State Space Models (SSMs) and linear Transformers, are highly attractive alternatives to traditional Transformers because their computational cost scales linearly with sequence length. However, they consistently fall short when it comes to long-range recall tasks.

The authors identify a fundamental tradeoff in how existing architectures write to memory:

  • State-based linear models (SSMs) write densely. They update their entire hidden state at every single step, which causes new tokens to interfere with and dilute past information, making specific historical items difficult to recover.
  • Sliding-Window Attention (SWA) writes sparsely by storing explicit token representations, but it only does so within a fixed-size window. Once a token falls outside this window, it suffers from "hard eviction" and is permanently lost.

To bridge this gap, the paper introduces a framework that allows models to selectively write to specific memory locations based on content, avoiding both full-state interference and rigid position-based eviction.

Figure 1: Raven Overview. Visualization of three different sequence mixers using Routing Slot Memories, with different router choices. (a) SWA memory allocation as first-in-first-out strategy using a one-hot vector et as router. (b) SSM memory allocation, which projects each token in all memory slots using a dense, all-ones router 1M (c) Raven memory allocation, which uses a selective router for writes. Visualization uses a sequence of T = 6 token and M = 4 memory slots for the hidden state St and TopK = 1 for Raven router.

Methods

The authors formalize their approach through a new class of models called Routing Slot Memories (RSMs), where the hidden state is organized into a fixed set of independent memory slots.

Raven is a practical instantiation of the RSM framework that introduces three key architectural elements:

  1. Sparse Input-Dependent Routing: Instead of updating all memory slots unconditionally, Raven adapts a top-$K$ routing strategy (similar to those used in Mixture-of-Experts architectures) using a sigmoid scoring function. Each incoming token dynamically chooses a small subset of slots to update based on its content.
  2. Selective Decay: Forgetting (decay) is tightly coupled with writing. An explicit decay operator is applied only to the slots chosen by the router. Unselected slots are completely frozen, allowing their content to persist indefinitely without interference.
  3. Simplified Block Design: Raven simplifies prior linear architectures by completely omitting short-range 1D convolutions over token features, relying entirely on the gated MLP channel mixer, SiLU activations, and QK-RMSNorm.
Figure 3: Raven Neural Architecture. (Left) Raven block vs. (Right) other linear models. Raven requires no short-range con- volutions, yielding a simpler block than existing SSMs and linear transformers.

Datasets

  • Pretraining: The models were pretrained on the SlimPajama-627B dataset. The authors evaluated two scales: a ~400M parameter model (trained on 15B tokens with a 2048 context length) and a ~800M parameter model (trained on 32B tokens with a 4096 context length).
  • Evaluation Benchmarks:
    • Synthetic Retrieval: Single Needle-in-a-Haystack (NIAH-1, NIAH-2, NIAH-3) tasks via the RULER benchmark.
  • Real-World Recall-Intensive Tasks: SWDE (structured web data extraction), FDA (document-level information extraction from PDFs), and SQuAD (extractive question answering).
  • Standard Language Modeling: Zero-shot evaluations on PIQA, Winogrande, HellaSwag, ARC (Easy/Challenge), and Lambada.

Key Insights and Ideas

  • The Routing Axis Extreme: The RSM framework elegantly reveals that SSMs and SWA are not fundamentally different architectures, but rather two extremes on a routing spectrum. SSMs use dense routing with gradual forgetting, while SWA uses maximally sparse, deterministic routing with hard eviction.
  • Beneficial Memory Imbalance: Unlike Mixture-of-Experts (MoE) models, which require strict load-balancing losses to ensure all experts are trained equally, memory routing thrives on imbalance. Raven intentionally omits load-balancing losses, allowing the router to naturally isolate retrieval-critical tokens (like passkeys) into dedicated "retrieval slots" while distributing general content across shared slots.
  • Implicit Length Generalization: Because the router updates slots unevenly, different slots naturally process different "Effective Sequence Lengths" (ESL) during training. This structural variation implicitly exposes the model to variable-length dynamics, allowing it to naturally extrapolate to massive context lengths at test time without explicit length curricula.
Figure 2: Effective Sequence Length Visualization. For a hidden state with M = 4 memory slots and a sequence of length T = 6, each memory slot processes a different effective sequence length (ESL), depending on the router.

Key Results

  • Superior Length Extrapolation: At the 400M scale (trained on a 2K context), Raven maintains near-perfect accuracy ($\ge 99\%$) on NIAH-1 up to 16K tokens and retains strong performance ($>91\%$) at 32K tokens—achieving a 16× context extrapolation where competitive SSM baselines like Mamba-2 and GDN sharply degrade.
  • Downstream Task Outperformance: On real-world recall tasks, Raven consistently outperforms prior linear-time models. At the 400M scale, it achieves 34.1% accuracy on SWDE and 35.4% on SQuAD, outperforming Mamba-2 (25.7% / 31.9%) and Gated Linear Attention (GLA) (29.0% / 30.3%).
  • Robust Hybrid Performance: When interleaved with attention layers in hybrid architectures, Raven-based hybrids dramatically outperform alternative SSM hybrids on long-context tasks, maintaining over 80% accuracy on NIAH-2 at 32K lengths.
In-context recall benchmarks and NIAH accuracy across various context lengths.

Limitations and Future Work

  • Scaling Disparity in Pure LM: At the 800M parameter scale, Raven slightly trails Gated Delta-Net (GDN) on average zero-shot language modeling accuracy, though GDN utilizes a significantly larger parameter budget (892M vs. 792M).
  • Granularity of Routing: Currently, Raven's routing mechanism operates locally within each head's memory allocation. The authors suggest that combining this fine-grained slot routing with coarser routing across different sequence mixer heads (similar to Mixture of Heads) represents a promising direction for achieving even higher levels of memory sparsity.

Summary updated

BibTeX
@inproceedings{afzal2026raven,
  author = {Arshia Afzal and Aviv Bick and Eric P. Xing and Volkan Cevher and Albert Gu},
  title = {{Raven: High-Recall Sequence Modeling with Sparse Memory Routing}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=TAeR7iXyQR},
}
Figure