Key-Value Means
This work addresses the high computational complexity, substantial memory footprint, and poor state scalability of conventional attention mechanisms in long-context scenarios by introducing Key-Value Means (KVM), a novel block-recurrent attention mechanism. KVM constructs a recurrent structure using standard attention operations—without requiring custom kernels—and supports both fixed and growable state representations while preserving parallel training capability and enabling linear-time inference. Its key contribution lies in unifying the scalable memory of Transformers with the efficient inference of linear RNNs, allowing continuous adjustment of prefill complexity from O(N) to O(N²). This significantly reduces KV cache overhead and achieves sub-quadratic prefill time and sub-linear state growth on long-context tasks, all with minimal additional parameters. The code and models are publicly released.