Skip to content

Projective Shannon Sketches for Transformer KV Memory: Needle Rescue under Compressed Keys on GPT Model

Sep 2026 · Zenodo (CERN European Organization for Nuclear Research)

Abstract

Projective KV-Cache: Slashing LLM Memory Costs by 50%–75% Without Context Amnesia (Empirical Validation on GPT-2) The Executive Problem: Large Language Models (LLMs) processing long documents face an expensive bottleneck: the Key-Value (KV) Cache. Storing every token's attention memory in GPU VRAM creates immense hardware costs. Current industry workarounds—such as static eviction or sliding-window pruning (e.g., StreamingLLM)—suffer from severe "middle-context amnesia": they discard older tokens, causing the model to hallucinate or miss critical facts hidden deep inside long prompts. The Solution (Two-Tier Hierarchical Memory): This repository implements a mathematically grounded two-tier retrieval architecture: Ultra-Compact Sketching: Incoming attention keys are compressed into low-dimensional random Gaussian sketches (D = 16 or D = 32 dimensions instead of the full 64/128-dimensional space), cutting key memory by 50% to 75%. Dynamic Needle Retrieval & Exact Re-Attention: When a query arrives, the lightweight sketch scans the entire sequence in milliseconds to locate relevant deep-context tokens. Full-precision attention is then computed strictly on a small, high-value candidate set (64 tokens). Empirical Validation on Production Weights (GPT-2 124M): Tested on a ~943-token prompt containing an operational factual "needle" buried in the middle (token #468), evaluated across 12 attention heads in deep layers: Layer 11 (Critical Semantic Integration Layer): Industry Baseline (Static Eviction, 64 tokens): Output cosine fidelity drops to 76.5%, and the model misses the critical fact across 100% of heads (0/12 heads). Projective Sketch D = 16 (75% Key VRAM reduction): Output fidelity stays at 93.8%, recovering the hidden fact in 8 out of 12 heads. Projective Sketch D = 32 (50% Key VRAM reduction): Output fidelity reaches 95.8%, recovering the hidden fact in 10 out of 12 heads (83.3% retrieval recall). Business & Infrastructure Impact: Drastic Cost Reduction: Slashes GPU VRAM footprints for enterprise long-context inference (chatbots, legal analysis, document search) without sacrificing factual recall. Edge & On-Device Deployment: Enables long-context reasoning on consumer GPUs, laptops, and mobile devices that previously suffered out-of-memory crashes. No Re-training Required: Operates as a zero-shot, drop-in memory layer compatible with existing Transformer weights.

View source

Similar papers

#computer vision Review Sep 2017

Agile Software Development Methods: Review and Analysis

This publication proposes a definition and a classification of agile software development approaches and analyses ten software development methods that can be characterized as being "agile" against the defined criterion.

P. Abrahamsson, O. Salo, Jussi Ronkainen et al. · 727 citations · ⚡54
#small language model Dataset Open access Oct 2026

Socratic guiding questions in synthetic arithmetic data: matched LoRA runs (revision v2)

Supporting data, adapters, predictions and code for the article *Low-Cost LoRA Fine-Tuning of Small Language Models for Multi-Step Arithmetic Reasoning* by Jake O'Grady, Asena Isik Gürhan, Chee Fong Ting and Effirul Ramlan (University of Galway). We generated 20,000 GSM8K-derived arithmetic problems with step-by-step s...

O'Grady, Jake, Gürhan, Asena Isik, Chee, Fong Ting et al. · 465 citations
#computer vision Jun 2008

The impact of agile practices on communication in software development

The study shows that agile practices improve both informal and formal communication, but indicates that, in larger development situations involving multiple external stakeholders, a mismatch of adequate communication mechanisms can sometimes even hinder the communication.

M. Pikkarainen, Jukka Haikara, O. Salo et al. · 401 citations · ⚡48
#machine learning Review Open access Oct 2014

Software development in startup companies: A systematic mapping study

The results indicate that software engineering work practices are chosen opportunistically, adapted and configured to provide value under the constrains imposed by the startup context.

Nicolò Paternoster, Carmine Giardino, M. Unterkalmsteiner et al. · 394 citations · ⚡54

Related blog posts

MIT News · Artificial Intelligence Oct 15, 2026

AI model decodes the language cells use to communicate

A new computational approach reveals how cells communicate to assemble into tissues. This could accelerate stem cell engineering, improve disease models, and inform therapies.

Microsoft Research Blog Oct 15, 2026

Proof-based general-purpose computing with Magnetar

Zero-knowledge proofs can verify computing results without rerunning workloads or exposing sensitive data. Magnetar helps bring them into the mainstream with support for standard programming languages, major speed gains, and quantum-resistant security. The post Proof-based general-purpose computing with Magnetar appeared first on Microsoft Research.

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.