[Paper Review] Augmenting Language Models with Long-Term Memory
LongMem proposes a decoupled memory framework that lets frozen backbone LLMs encode long past contexts while a lightweight SideNet retrieves and fuses memory augmentations, enabling long-context modeling and memory-augmented in-context learning.
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.
Motivation & Objective
- Enable language models to memorize and utilize long-form past context beyond fixed input limits.
- Decouple memory encoding from memory retrieval to avoid memory staleness during adaptation.
- Develop a lightweight SideNet that retrieves and fuses memory augmentations into the current input processing.
- Allow unlimited-length memory to support long-form text tasks and thousands of demonstrations in-context.
- Demonstrate improvements on long-context language modeling benchmarks and memory-augmented in-context learning.
Proposed method
- Use a frozen backbone LLM as a memory encoder to cache past attention key-value pairs in a non-differentiable memory bank.
- Introduce a residual SideNet as a memory retriever and reader trained via memory-augmented adaptation while keeping the backbone frozen.
- Implement token-to-chunk memory retrieval to fetch top-K memory chunks and fuse them through a memory-augmented decoder layer.
- Apply cross-network residual connections that inject backbone LLM information into SideNet via layer-wise residuals.
- Perform memory-augmented training with standard left-to-right language modeling objective to enable learning how to retrieve and fuse memory.
Experimental results
Research questions
- RQ1Can a decoupled memory architecture enable LLMs to leverage long-term past contexts without memory staleness?
- RQ2How effective is a lightweight SideNet in retrieving and fusing memory augmentations for long-context tasks?
- RQ3What are the gains in long-context language modeling and in-context learning when unlimited memory is available?
- RQ4How do memory size and chunking granularity affect retrieval quality and downstream performance?
Key findings
- LongMem outperforms strong long-context baselines on long-text modeling benchmarks, achieving substantial perplexity reductions on PG-22 (-1.38 to -1.62) and ArXiv (-1.0).
- On ChapterBreak (AO3), LongMem achieves a state-of-the-art 40.5% suffix-identification accuracy, outperforming x-former baselines and GPT-3 with many more parameters.
- In memory-augmented in-context learning, LongMem delivers notable gains over MemTRM and non-memory baselines, including around +8.0 average accuracy on 5 NLU tasks in 20-shot settings.
- With memory demonstrations (e.g., 200 extra demonstrations), LongMem improves SQuAD open-ended generation metrics to EM 26.77 and F1 35.70.
- Ablation-style findings show that smaller chunk sizes (e.g., csz = 2) can benefit fine-grained retrieval for ICL tasks, and memory size choices (msz) align with dataset context lengths for best perplexity performance.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.