[论文解读] Needle in the Haystack for Memory Based Large Language Models
该论文展示了一个1.3B参数的 Larimar 模型,具有外部、由 CPU 持有的记忆体,能够在不进行专门任务训练的情况下实现长上下文回忆(可达 100K+ 标记),在 passkey 任务和 needle-in-the-haystack 任务上超越基线。
Current large language models (LLMs) often perform poorly on simple fact retrieval tasks. Here we investigate if coupling a dynamically adaptable external memory to a LLM can alleviate this problem. For this purpose, we test Larimar, a recently proposed language model architecture which uses an external associative memory, on long-context recall tasks including passkey and needle-in-the-haystack tests. We demonstrate that the external memory of Larimar, which allows fast write and read of an episode of text samples, can be used at test time to handle contexts much longer than those seen during training. We further show that the latent readouts from the memory (to which long contexts are written) control the decoder towards generating correct outputs, with the memory stored off of the GPU. Compared to existing transformer-based LLM architectures for long-context recall tasks that use larger parameter counts or modified attention mechanisms, a relatively smaller size Larimar is able to maintain strong performance without any task-specific training or training on longer contexts.
研究动机与目标
- 促使在大型语言模型中改进长上下文检索。
- 提出并评估一个与 Larimar 集成的外部记忆机制,用于测试时的长上下文自适应。
- 展示可扩展到非常长的上下文而不增加 GPU 内存使用的记忆读写操作。
- 证明记忆读出会促使解码器生成正确输出。
- 讨论基于 CPU 的外部内存用于长上下文任务的可行性与局限性。
提出的方法
- 使用 Larimar 架构与通过最小二乘内存更新编写的外部联想记忆。
- 使用编码和写入键将上下文片段写入内存。
- 使用从前缀或查询编码派生的读取键从内存读取。
- 将内存读出计算为 z_read = w M,并以此读出结果对解码器进行条件化。
- 通过固定键内存来控制键,确保最近邻映射将写入与读取关联起来。
- 在 CPU 上操作内存,以便随着上下文扩展内存大小,同时将解码保持在 GPU 上。
实验结果
研究问题
- RQ1外部持有且可动态更新的记忆是否能够在不进行任务专门训练的情况下提升 LLM 的长上下文回忆?
- RQ2在测试时基于前缀的键计算如何实现对非常长的上下文(100K–1M 标记)的可靠检索?
- RQ3将内存卸载到 CPU 以用于长上下文任务时,在内存大小、延迟与 GPU 使用之间有哪些权衡?
- RQ4在 passkey 和 needle-in-the-haystack 任务上,Larimar 与基线长上下文检索模型相比如何?
主要发现
- Larimar 在1.3B参数模型下,无需任务特定训练,仍能对长上下文(超过100K标记)保持强回忆。
- 即使完整上下文存储在 GPU 外,记忆读出也能引导解码器生成正确输出。
- 与基线模型(Mistral 7B, Phi-3-Mini-128K)相比,在相似或更小的模型规模下,Larimar 在 passkey 和 needle-in-the-haystack 任务上显示出更好的回忆。
- 使用基于前缀的写入键方法可提升对更长或更复杂 needle 的回忆。
- 基于 CPU 的外部内存使得可以扩展到更长的上下文而不增加 GPU 内存使用。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。