Skip to main content
QUICK REVIEW

[论文解读] Augmenting Language Models with Long-Term Memory

Weizhi Wang, Li Dong|arXiv (Cornell University)|Jun 12, 2023
Topic ModelingComputer Science被引用 33
一句话总结

LongMem 提出一个解耦的记忆框架,使冻结的主干 LLMs 能编码长期的历史上下文,而一个轻量级的 SideNet 检索并融合记忆增强,从而实现长上下文建模和记忆增强的上下文学习。

ABSTRACT

Existing large language models (LLMs) can only afford fix-sized inputs due to the input length limit, preventing them from utilizing rich long-context information from past inputs. To address this, we propose a framework, Language Models Augmented with Long-Term Memory (LongMem), which enables LLMs to memorize long history. We design a novel decoupled network architecture with the original backbone LLM frozen as a memory encoder and an adaptive residual side-network as a memory retriever and reader. Such a decoupled memory design can easily cache and update long-term past contexts for memory retrieval without suffering from memory staleness. Enhanced with memory-augmented adaptation training, LongMem can thus memorize long past context and use long-term memory for language modeling. The proposed memory retrieval module can handle unlimited-length context in its memory bank to benefit various downstream tasks. Typically, LongMem can enlarge the long-form memory to 65k tokens and thus cache many-shot extra demonstration examples as long-form memory for in-context learning. Experiments show that our method outperforms strong long-context models on ChapterBreak, a challenging long-context modeling benchmark, and achieves remarkable improvements on memory-augmented in-context learning over LLMs. The results demonstrate that the proposed method is effective in helping language models to memorize and utilize long-form contents. Our code is open-sourced at https://aka.ms/LongMem.

研究动机与目标

  • 使语言模型能够记住并利用超出固定输入限制的长篇过去上下文。
  • 将记忆编码与记忆检索解耦,以避免在适应过程中出现记忆陈旧。
  • 开发一个轻量级的 SideNet,它检索并将记忆增强融合到当前输入处理中。
  • 允许无限长度的记忆,以支持长篇文本任务和上下文中的数千次演示。
  • 在长上下文语言建模基准和记忆增强的上下文学习上展示改进。

提出的方法

  • 将冻结的主干 LLM 用作记忆编码器,将过去的注意力键值对缓存在不可微分的记忆库中。
  • 引入一个残差式 SideNet 作为记忆检索器和读取器,通过记忆增强适应训练,同时保持主干冻结。
  • 实现令牌到块的记忆检索,以获取前K个记忆块,并通过记忆增强的解码器层融合它们。
  • 应用跨网络残差连接,通过逐层残差将主干 LLM 信息注入到 SideNet。
  • 使用标准自左向右的语言建模目标进行记忆增强训练,以使模型学习如何检索和融合记忆。

实验结果

研究问题

  • RQ1解耦记忆架构是否能够使 LLMs 在不出现记忆陈旧的情况下利用长期过去的上下文?
  • RQ2轻量级的 SideNet 在检索和融合记忆增强以应对长上下文任务方面的效果如何?
  • RQ3在具备无限记忆时,长上下文语言建模和上下文学习的收益有哪些?
  • RQ4记忆大小和分块粒度如何影响检索质量及下游表现?

主要发现

  • LongMem 在长文本建模基准上优于强基线,在 PG-22 (-1.38 ~ -1.62) 和 ArXiv (-1.0) 上实现了显著的困惑度下降。
  • 在 ChapterBreak (AO3) 上,LongMem 实现了 40.5% 的后缀识别准确率,超过了 x-former 基线和参数更多的 GPT-3。
  • 在记忆增强的上下文学习中,LongMem 相对于 MemTRM 和非记忆基线实现显著提升,包括在 20-shot 设置下对 5 个 NLU 任务的平均准确率约提升 +8.0。
  • 使用记忆演示(例如,额外 200 次演示)时,LongMem 将 SQuAD 开放式生成指标提升至 EM 26.77 和 F1 35.70。
  • 消融式发现表明,较小的块大小(例如 csz = 2)可以有利于 ICL 任务的细粒度检索,且记忆大小选择(msz)与数据集上下文长度对困惑度性能具有最佳匹配。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。