Skip to main content
QUICK REVIEW

[Paper Review] Titans: Learning to Memorize at Test Time

Ali Behrouz, Peilin Zhong|arXiv (Cornell University)|Dec 31, 2024
Artificial Intelligence in GamesComputer Science6 citations
TL;DR

Titans introduces a deep neural long-term memory module that learns to memorize at test time and integrates it with a core attention-based architecture to handle extremely long contexts, outperforming Transformers and linear recurrent models on diverse tasks.

ABSTRACT

Over more than a decade there has been an extensive research effort on how to effectively utilize recurrent models and attention. While recurrent models aim to compress the data into a fixed-size memory (called hidden state), attention allows attending to the entire context window, capturing the direct dependencies of all tokens. This more accurate modeling of dependencies, however, comes with a quadratic cost, limiting the model to a fixed-length context. We present a new neural long-term memory module that learns to memorize historical context and helps attention to attend to the current context while utilizing long past information. We show that this neural memory has the advantage of fast parallelizable training while maintaining a fast inference. From a memory perspective, we argue that attention due to its limited context but accurate dependency modeling performs as a short-term memory, while neural memory due to its ability to memorize the data, acts as a long-term, more persistent, memory. Based on these two modules, we introduce a new family of architectures, called Titans, and present three variants to address how one can effectively incorporate memory into this architecture. Our experimental results on language modeling, common-sense reasoning, genomics, and time series tasks show that Titans are more effective than Transformers and recent modern linear recurrent models. They further can effectively scale to larger than 2M context window size with higher accuracy in needle-in-haystack tasks compared to baselines.

Motivation & Objective

  • Motivate the design of memory systems that combine short-term attention with long-term memorization.
  • Propose a neural long-term memory that updates at test time based on a surprise-driven mechanism.
  • Show how to train and retrieve from the long-term memory in a fast, parallelizable way.
  • Integrate long-term memory with a three-branch Titans architecture (Core, Long-term Memory, Persistent Memory).
  • Demonstrate scalability to context windows larger than 2 million tokens across varied tasks.

Proposed method

  • Introduce a neural long-term memory module that stores past information into its parameters using a surprise-driven update.
  • Define surprise using the gradient of the loss with respect to the input and decompose it into past and momentary surprise with data-dependent decay.
  • Use a meta-learning style inner loop to train the memory via an associative memory loss on key–value pairs.
  • Propose a fast, tensorized training scheme that uses mini-batch gradient descent and matmul-based computations for parallelism.
  • Incorporate a persistent memory (task-related, data-independent) and present three Titans variants where memory is used as a context, a layer, or a gated branch.
Figure 1 : The illustration of how the training of neural memory can be done in parallel and using matmul s.
Figure 1 : The illustration of how the training of neural memory can be done in parallel and using matmul s.

Experimental results

Research questions

  • RQ1What constitutes an effective memory structure for long-term dependencies?
  • RQ2What memory update mechanism best supports memorization and forgetting over long sequences?
  • RQ3What retrieval process efficiently extracts relevant stored information for current tasks?
  • RQ4How can memory modules be efficiently integrated into architectures without sacrificing training/inference speed?
  • RQ5Is a deep neural long-term memory necessary for robust long-horizon memorization?

Key findings

  • Titans outperforms modern recurrent models and their hybrids across language modeling, reasoning, genomics, and time-series tasks.
  • Titans can scale to context windows larger than 2M tokens with higher accuracy on needle-in-haystack tasks compared to baselines.
  • The long-term memory module uses a surprise-driven update and a forgetting mechanism that improves memory management and generalization.
  • Parallelized training via tensorized mini-batch updates enables efficient training of the deep memory.
  • Persistent memory provides input-independent task knowledge to stabilize learning and retrieval.
  • Three Titans variants (Memory as Context, Memory as Gate, and a gating-based design) offer trade-offs between efficiency and effectiveness.
Figure 2 : Memory as a Context (MAC) Architecture. This architecture includes three branches of (1) core, (2) contextual (long-term) memory, and (3) persistent memory. The core branch concatenates the corresponding long-term and persistent memories with the input sequence. Next, attention performs o
Figure 2 : Memory as a Context (MAC) Architecture. This architecture includes three branches of (1) core, (2) contextual (long-term) memory, and (3) persistent memory. The core branch concatenates the corresponding long-term and persistent memories with the input sequence. Next, attention performs o

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.