Compressed Context Memory For Online Language Model Interaction
Jang-Hyun Kim, Junyoung Yeom, Sangdoo Yun, Hyun Oh Song
TL;DR
The paper tackles the challenge of online language model inference with ever-expanding context by introducing Compressed Context Memory (CCM), a memory-augmented framework that compresses accumulating attention key/value pairs into a compact Mem(t) using a dedicated COMP token. It combines a lightweight conditional LoRA adapter with two memory schemes (CCM-concat and CCM-merge) and a parallelized training strategy to enable efficient, end-to-end optimization without full fine-tuning. Empirical results across conversation, personalization, and multi-task learning show CCM can reach full-context performance with substantially smaller memory footprints, and it outperforms sliding-window baselines in streaming settings. The approach demonstrates strong generalization with a unified compression adapter and favorable memory/throughput trade-offs, offering practical benefits for memory-constrained online deployments of large language models.
Abstract
This paper presents a context key/value compression method for Transformer language models in online scenarios, where the context continually expands. As the context lengthens, the attention process demands increasing memory and computations, which in turn reduces the throughput of the language model. To address this challenge, we propose a compressed context memory system that continually compresses the accumulating attention key/value pairs into a compact memory space, facilitating language model inference in a limited memory space of computing environments. Our compression process involves integrating a lightweight conditional LoRA into the language model's forward pass during inference, without the need for fine-tuning the model's entire set of weights. We achieve efficient training by modeling the recursive compression process as a single parallelized forward computation. Through evaluations on conversation, personalization, and multi-task learning, we demonstrate that our approach achieves the performance level of a full context model with $5\times$ smaller context memory size. We further demonstrate the applicability of our approach in a streaming setting with an unlimited context length, outperforming the sliding window approach. Codes are available at https://github.com/snu-mllab/context-memory.
