REAL: REtrieval-reAsoning and Logic-constructed Attention Behaviors for Long-Context KV Cache Compression

· Source: cs.CL updates on arXiv.org · Field: Technology & Digital — Artificial Intelligence & Machine Learning · Depth: Expert, extended

Summary

The SurfaceLogicKV method addresses the significant memory pressure of KV cache storage in Large Language Models (LLMs) for long-context inference. It proposes a novel two-stage compression approach based on distinguishing attention behaviors into "surface memorization" and "logic construction." Observations on Llama-3-8B-Instruct show that approximately 98.5% of attention heads ignore irrelevant information, with 1.5% engaging in logic construction and 0.5% in surface memorization. SurfaceLogicKV integrates these layer- and head-wise behaviors to dynamically allocate KV cache budgets. Experiments on Llama-3-8B-Instruct, Mistral-7B-Instruct, and 123B Mistral-Large-Instruct-2411 across benchmarks like LongBench and LooGLE, with context lengths up to 129K, demonstrate improved compression robustness and competitive performance, sometimes even surpassing FullKV, particularly at a β=1.351 allocation ratio.

Key takeaway

For Machine Learning Engineers optimizing LLM inference for long contexts, you should consider adopting attention behavior-driven KV cache compression methods like SurfaceLogicKV. By analyzing and allocating resources based on "surface memorization" and "logic construction" behaviors, you can achieve more robust performance and memory efficiency than traditional token- or layer-wise approaches. This allows for maintaining competitive inference quality even with significantly reduced KV cache sizes, improving deployment feasibility for large models.

Key insights

LLM KV cache compression can be robustly optimized by distinguishing and allocating resources based on "surface memorization" and "logic construction" attention behaviors.

Principles

Method

SurfaceLogicKV calculates Surface Memorization Score ($SF_{sc}$) and Logic Construction Score ($LG_{sc}$) to derive a comprehensive Inference Score ($INF_{sc}$). This $INF_{sc}$ guides a two-stage, layer- and head-wise dynamic KV budget allocation, combining fixed and dynamic portions.

In practice

Topics

Best for: AI Engineer, NLP Engineer, Research Scientist, AI Scientist, Machine Learning Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by cs.CL updates on arXiv.org.