MemLong: Memory-Augmented Retrieval for Long Text Modeling

Weijie Liu, Zecheng Tang, Juntao Li, Kehai Chen, Min Zhang
8/30/2024
cs.CLcs.AI

Official code: Bui1dMySea/MemLong (96 stars, last commit 2024-12-06).

Abstract

Recent advancements in Large Language Models (LLMs) have yielded remarkable success across diverse fields. However, handling long contexts remains a significant challenge for LLMs due to the quadratic time and space complexity of attention mechanisms and the growing memory consumption of the key-value cache during generation. This work introduces MemLong: Memory-Augmented Retrieval for Long Text Generation, a method designed to enhance the capabilities of long-context language modeling by utilizing an external retriever for historical information retrieval. MemLong combines a non-differentiable ``ret-mem'' module with a partially trainable decoder-only language model and introduces a fine-grained, controllable retrieval attention mechanism that leverages semantic-level relevant chunks. Comprehensive evaluations on multiple long-context language modeling benchmarks demonstrate that MemLong consistently outperforms other state-of-the-art LLMs. More importantly, MemLong can extend the context length on a single 3090 GPU from 4k up to 80k. Our code is available at https://github.com/Bui1dMySea/MemLong

View on arXivView PDF

Code Implementations(1)

Bui1dMySea/MemLongOfficial100%
9613Shell, PythonAug 25, 20241 years ago

Similar Papers

Cite this paper

@article{liu2024memlong,
  title  = {MemLong: Memory-Augmented Retrieval for Long Text Modeling},
  author = {Weijie Liu and Zecheng Tang and Juntao Li and Kehai Chen and Min Zhang},
  year   = {2024},
  eprint = {2408.16967},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2408.16967v1}
}

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/2408.16967.svg)](https://codeofpaper.com/paper/2408.16967)

Discussion