ChatPaper.aiChatPaper

Q-Filters: Benutting van QK-geometrie voor efficiënte KV-cachecompressie

Q-Filters: Leveraging QK Geometry for Efficient KV Cache Compression

March 4, 2025
Auteurs: Nathan Godey, Alessio Devoto, Yu Zhao, Simone Scardapane, Pasquale Minervini, Éric de la Clergerie, Benoît Sagot
cs.AI

Samenvatting

Autoregressieve taalmodelen maken gebruik van een Key-Value (KV) Cache, die het opnieuw berekenen van verborgen toestanden tijdens generatie vermijdt, waardoor het proces sneller verloopt. Naarmate de grootte van modellen en contextlengtes toenemen, wordt de KV Cache een aanzienlijk geheugenknelpunt, wat de behoefte aan compressiemethoden vergroot die de grootte ervan tijdens generatie beperken. In dit artikel ontdekken we verrassende eigenschappen van Query (Q) en Key (K) vectoren die het mogelijk maken om aandachtsscores efficiënt te benaderen zonder de aandachtswaarden te berekenen. We introduceren Q-Filters, een trainingsvrije KV Cache compressiemethode die minder cruciale Key-Value paren filtert op basis van een enkele context-onafhankelijke projectie. In tegenstelling tot veel alternatieven, is Q-Filters compatibel met FlashAttention, omdat het geen directe toegang tot aandachtswaarden vereist. Experimentele resultaten in lang-context instellingen tonen aan dat Q-Filters concurrerend is met aandacht-gebaseerde compressiemethoden zoals SnapKV in retrievalthandelingen, terwijl het consistent beter presteert dan efficiënte compressieschema's zoals Streaming-LLM in generatieopstellingen. Opmerkelijk is dat Q-Filters een nauwkeurigheid van 99% bereikt in de 'needle-in-a-haystack'-taak met een compressieniveau van x32, terwijl het de daling in generatieperplexiteit met tot wel 65% vermindert in tekstgeneratie vergeleken met Streaming-LLM.
English
Autoregressive language models rely on a Key-Value (KV) Cache, which avoids re-computing past hidden states during generation, making it faster. As model sizes and context lengths grow, the KV Cache becomes a significant memory bottleneck, which calls for compression methods that limit its size during generation. In this paper, we discover surprising properties of Query (Q) and Key (K) vectors that allow us to efficiently approximate attention scores without computing the attention maps. We propose Q-Filters, a training-free KV Cache compression method that filters out less crucial Key-Value pairs based on a single context-agnostic projection. Contrarily to many alternatives, Q-Filters is compatible with FlashAttention, as it does not require direct access to attention weights. Experimental results in long-context settings demonstrate that Q-Filters is competitive with attention-based compression methods such as SnapKV in retrieval tasks while consistently outperforming efficient compression schemes such as Streaming-LLM in generation setups. Notably, Q-Filters achieves a 99% accuracy in the needle-in-a-haystack task with a x32 compression level while reducing the generation perplexity drop by up to 65% in text generation compared to Streaming-LLM.

Summary

AI-Generated Summary

PDF92March 5, 2025