Spectral-LSH Compresses LLM Prompts Sub-Quadratically for Efficiency

Ali Mahdavi, Azaseh Zamanifar, Amirfarhad Farhadi, Omid Kashefi· July 23, 2026 View original

Summary

Spectral-LSH is a training-free prompt compression method that reduces the quadratic scaling of LLM prefill attention by approximating dominant attention-kernel components using Krylov subspace methods and SimHash. It groups similar tokens into macro-tokens, significantly improving perplexity ratios at high compression rates for long prompts.

Researchers have introduced Spectral-LSH, a novel, training-free method designed to compress long prompts for Large Language Models (LLMs) before they enter the model. This technique aims to mitigate the computational expense of prefill attention, which typically scales quadratically with sequence length. Spectral-LSH achieves sub-quadratic scaling by approximating the most influential components of an implicit attention-kernel operator. It does this by combining a Krylov subspace method with random features, thereby avoiding the need to explicitly materialize the computationally intensive O(N^2) attention kernel. Following this approximation, the method applies SimHash within the resulting attention eigenspace to identify and group similar tokens. These grouped tokens are then aggregated into "macro-tokens," which are assigned causal positional information. Experiments conducted on various Mistral and Qwen models using the C4 dataset revealed a distinct phase transition in compression effectiveness. While lightweight chunking is sufficient for low compression ratios (e.g., 4x), Spectral-LSH significantly preserves quality at higher compression rates (e.g., 8x and 16x), where chunking performance degrades. An adaptive backend combines both approaches, utilizing chunking for low compression and spectral clustering for high compression, though chunking remains faster overall for total latency.

Why it matters

Efficiently handling long prompts is crucial for many advanced LLM applications, and this method offers a way to reduce computational costs and improve performance without retraining models.

How to implement this in your domain

  1. 1Evaluate Spectral-LSH as a pre-processing step for long prompts in your LLM inference pipelines.
  2. 2Benchmark the latency and quality trade-offs of Spectral-LSH against existing prompt compression or chunking methods.
  3. 3Consider implementing the adaptive backend to dynamically switch between chunking and spectral clustering based on desired compression ratios.
  4. 4Explore how this method can enable new applications requiring very long context windows that were previously too expensive.

Who benefits

AI DevelopmentContent GenerationCustomer ServiceData AnalysisResearch

Key takeaways

  • Spectral-LSH offers sub-quadratic prompt compression for LLMs, reducing prefill attention costs.
  • It uses Krylov subspace methods and SimHash to group similar tokens into macro-tokens.
  • The method is training-free and improves perplexity ratios at high compression rates.
  • An adaptive backend combines chunking and spectral clustering for optimal performance across compression levels.

Original post by Ali Mahdavi, Azaseh Zamanifar, Amirfarhad Farhadi, Omid Kashefi

"arXiv:2607.19368v1 Announce Type: new Abstract: Long-prompt inference remains expensive because prefill attention scales quadratically with sequence length. We propose Spectral-LSH, a training-free prompt compression method that operates before the prompt enters the language mode…"

View on X

Originally posted by Ali Mahdavi, Azaseh Zamanifar, Amirfarhad Farhadi, Omid Kashefi on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses