Augmenting Language Models with Long-Term Memory

Weizhi Wang, Li Dong, Hao Cheng, Xiaodong Liu, Xifeng Yan +2 more
2/12/2026

No official code found. Best implementation: Victorwz/LongMem (827 stars, Apache-2.0, last commit 2024-03-30).

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.

View on arXivView PDF

Code Implementations(1)

Victorwz/LongMemCommunity67%
Apache-2.0

Official implementation of our NeurIPS 2023 paper "Augmenting Language Models with Long-Term Memory".

82774C, C++Jun 12, 20232 years agoApache-2.0
large-language-modelslong-context-modelinglong-term-memory

Similar Papers

Cite this paper

@article{wang2026augmenting,
  title  = {Augmenting Language Models with Long-Term Memory},
  author = {Weizhi Wang and Li Dong and Hao Cheng and Xiaodong Liu and Xifeng Yan and Jianfeng Gao and Furu Wei},
  year   = {2026},
  eprint = {2306.07174},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/pdf/2306.07174},
  journal = {NEURIPS 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2306.07174.svg)](https://codeofpaper.com/paper/2306.07174)

Discussion