Sliding window caching boosts transformer memory beyond immediate tokens

Thinking Outside the Box: Retention and Transmission of Information in Sliding-Window KV Inference

Artificial Intelligence

Summary

Transformers usually process text by looking only at a limited recent window of words, forgetting what came before. The authors studied a method that keeps a small rolling cache of recent key and value states, letting the model remember more from earlier in the text without extra training. They found that some models can recall information from even before the cached window, improving how well they retrieve and use past context. This suggests that training architectures with sliding-window attention helps models retain and transmit information better.

What this means in practice

  • For software engineers: Use sliding-window KV caching to improve language model efficiency without retraining during inference on long texts.
  • For ai product designers: Build conversational AI that retains earlier context better by deploying models with sliding-window attention architectures.$Commercial implications: Enables chatbots and assistants to maintain richer context in conversations, improving user experience and product value.

Authors

Timothy DeLise, Seth Cromelin

Abstract

Sliding-window KV inference refers to processing a sequence incrementally while retaining only a fixed-size cache of recent key and value states. It can be applied to pretrained causal transformers at inference time without additional training, while its KV-cache memory remains fixed as more tokens are processed. Because cached states are computed in the context of earlier tokens, they may carry information from beyond the current window and transmit it to later states. This study presents a series of experiments using five open-weight models spanning Qwen, Llama, Mistral, and Muse Glimmer. We investigate whether information originating outside the immediate context window can persist through a rolling KV cache and remain useful for retrieval. Initial results show that retaining previously computed states improves retrieval across the models tested compared with recomputing the final fixed window from raw tokens. We then measure how far this effect extends and find that Muse Glimmer and Mistral 7B show the strongest \emph{latent information relay}: they can recover information even after the relevant source tokens have left the cache. Both models incorporate sliding-window attention in their published architectures, an association that motivates testing whether training with sliding windows promotes more reliable information retention.