장기 기억을 활용한 언어 모델 강화
Augmenting Language Models with Long-Term Memory
June 12, 2023
저자: Weizhi Wang, Li Dong, Hao Cheng, Xiaodong Liu, Xifeng Yan, Jianfeng Gao, Furu Wei
cs.AI
초록
기존의 대형 언어 모델(LLM)은 입력 길이 제한으로 인해 고정된 크기의 입력만 처리할 수 있어, 과거 입력에서 제공되는 풍부한 장문맥 정보를 활용하지 못하는 한계가 있습니다. 이를 해결하기 위해, 우리는 LLM이 장기 기억을 저장할 수 있도록 하는 '장기 기억을 강화한 언어 모델(LongMem)' 프레임워크를 제안합니다. 우리는 원본 백본 LLM을 메모리 인코더로 고정하고, 적응형 잔차 사이드 네트워크를 메모리 검색기 및 리더로 사용하는 새로운 디커플링된 네트워크 아키텍처를 설계했습니다. 이러한 디커플링된 메모리 설계는 메모리 부실 문제 없이 장기간의 과거 문맥을 쉽게 캐시하고 업데이트할 수 있습니다. 메모리 강화 적응 훈련을 통해 LongMem은 장기간의 과거 문맥을 기억하고 이를 언어 모델링에 활용할 수 있습니다. 제안된 메모리 검색 모듈은 메모리 뱅크에서 무제한 길이의 문맥을 처리할 수 있어 다양한 다운스트림 작업에 이점을 제공합니다. 일반적으로 LongMem은 장문 기억을 65,000 토큰까지 확장할 수 있어, 인컨텍스트 학습을 위한 다수의 예시를 장문 기억으로 캐시할 수 있습니다. 실험 결과, 우리의 방법은 도전적인 장문맥 모델링 벤치마크인 ChapterBreak에서 강력한 장문맥 모델을 능가하며, LLM 대비 메모리 강화 인컨텍스트 학습에서 뛰어난 개선을 달성했습니다. 이러한 결과는 제안된 방법이 언어 모델이 장문 내용을 기억하고 활용하는 데 효과적임을 입증합니다. 우리의 코드는 https://aka.ms/LongMem에서 오픈소스로 제공됩니다.
English
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.