Titans: Learning to Memorize at Test Time

LLM Long Context ML TAVR Mamba/SSM RNN
十多年来,关于如何有效利用循环模型和注意力机制的研究一直在广泛进行。循环模型旨在将数据压缩到固定大小的记忆单元(称为隐藏状态),而注意力机制则允许关注整个上下文窗口,捕捉所有标记之间的直接依赖关系。然而,这种更精确的依赖关系建模伴随着二次成本,限制了模型处理固定长度的上下文。我们提出了一种新的神经长期记忆模块,该模块学习记住历史上下文,并帮助注意力机制在利用远期信息的同时关注当前上下文。我们展示了这种神经记忆的优势在于快速并行化训练,同时保持快速推理速度。从记忆的角度来看,我们认为由于注意力机制具有有限的上下文但准确的依赖关系建模,它表现得像短期记忆;而神经记忆由于其能够记住数据,充当更持久的长期记忆。基于这两种模块,我们引入了一个新的架构系列,称为泰坦(Titans),并提出了三种变体,以探讨如何有效地将记忆整合到此架构中。我们在语言建模、常识推理、基因组学和时间序列任务上的实验结果表明,泰坦比Transformer和最近的现代线性循环模型更有效。此外,它们可以在超过200万的时间窗口大小上有效扩展,在“大海捞针”任务中比基线模型具有更高的准确性。
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.
许愿