Discovering the Gems in Early Layers: Accelerating Long-Context LLMs with 1000x Input Token Reduction
On the map: Efficient LLM inference and serving → KV cache optimization
Abstract (arXiv)
Large Language Models (LLMs) have demonstrated remarkable capabilities in handling long context inputs, but this comes at the cost of increased computational resources and latency. Our research introduces a novel approach for the long context bottleneck to accelerate LLM inference and reduce GPU memory consumption. Our research demonstrates that LLMs can identify relevant tokens in the early layers before generating answers to a query. Leveraging this insight, we propose an algorithm that uses early layers of an LLM as filters to select and compress input tokens, significantly reducing the context length for subsequent processing. Our method, GemFilter, demonstrates substantial improvements in both speed and memory efficiency compared to existing techniques, such as standard attention and SnapKV/H2O. Notably, it achieves a 2.4× speedup and 30% reduction in GPU memory usage compared to SOTA methods. Evaluation on the Needle in a Haystack task shows that GemFilter significantly outperforms standard attention, SnapKV and demonstrates comparable performance on the LongBench challenge. GemFilter is simple, training-free, and broadly applicable across different LLMs. Crucially, it provides interpretability by allowing humans to inspect the selected input sequence. These findings not only offer practical benefits for LLM deployment, but also enhance our understanding of LLM internal mechanisms, paving the way for further optimizations in LLM design and inference. Our code is available at urlhttps://github.com/SalesforceAIResearch/GemFilter.
Key facts. Cited by 39 papers in the map (data through 7 Oct 2026). Placed in KV cache optimization, one of 12 directions in Efficient LLM inference and serving. Builds on 22 of its 30 references that are in the map. First posted on arXiv 25 Sep 2024.
Builds on
22 of 30 references.
Closest ancestors · 5
Same direction, newest first
- 2024ThinK: Thinner Key Cache by Query-Driven Pruning30 Jul
- 2024LOOK-M: Look-Once Optimization in KV Cache for Efficient Multimodal Long-Context Inference26 Jun
- 2024SnapKV: LLM Knows What You are Looking for Before Generation22 Apr
- 2023Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs3 Oct
- 2023H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models24 Jun
Other references · 17
- 2017Attention Is All You Needcited by 59,932
- 2024The Llama 3 Herd of Modelscited by 14,192
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,579
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,551
- 2022Emergent Abilities of Large Language Modelscited by 2,483
- 2023Efficient Streaming Language Models with Attention Sinkscited by 2,115
- 2024Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phonecited by 1,883
- 2023LongBench: A Bilingual, Multitask Benchmark for Long Context Understandingcited by 1,378
- 2024FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precisioncited by 507
- 2023LongLLMLingua: Accelerating and Enhancing LLMs in Long Context Scenarios via Prompt Compressioncited by 443
5 more
- 2024MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attentioncited by 375
- 2024LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compressioncited by 343
- 2023Compressing Context to Enhance Inference Efficiency of Large Language Modelscited by 185
- 2024LongWriter: Unleashing 10,000+ Word Generation from Long Context LLMscited by 142
- 2024LongRAG: Enhancing Retrieval-Augmented Generation with Long-context LLMscited by 104
Built on by
Citing papers per year: 2024: 13; 2025: 18; 2026: 8.
39 papers.
Sort:
By area:
- 2024FaithEval: Can Your Language Model Stay Faithful to Context, Even If "The Moon is Made of Marshmallows"cited by 85
- 2024TidalDecode: Fast and Accurate LLM Decoding with Position Persistent Sparse Attentioncited by 28
- 2024MrT5: Dynamic Token Merging for Efficient Byte-level Language Modelscited by 27
- 2024Circuit Complexity Bounds for RoPE-based Transformer Architecturecited by 26
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descentcited by 21
- 2024The Computational Limits of State-Space Models and Mamba via the Lens of Circuit Complexitycited by 21
- 2024Looped ReLU MLPs May Be All You Need as Practical Programmable Computerscited by 19
- 2024HSR-Enhanced Sparse Attention Accelerationcited by 19
- 2025FastKV: Decoupling of Context Reduction and KV Cache Compression for Prefill-Decoding Accelerationcited by 13
- 2024Theoretical Constraints on the Expressive Power of mathsfRoPE-based Tensor Attention Transformerscited by 12
- 2025Speculative Prefill: Turbocharging TTFT with Lightweight and Training-Free Token Importance Estimationcited by 12
- 2025Video Latent Flow Matching: Optimal Polynomial Projections for Video Interpolation and Extrapolationcited by 11
27 more
- 2025Efficient Prompt Compression with Evaluator Heads for Long-Context Transformer Inferencecited by 10
- 2025Theoretical Guarantees for High Order Trajectory Refinement in Generative Flowscited by 9
- 2025CentroidKV: Efficient Long-Context LLM Inference via KV Cache Clusteringcited by 8
- 2024Lossless KV Cache Compression to 2%cited by 7
- 2025Progressive Sparse Attention: Algorithm and System Co-design for Efficient Attention in LLM Servingcited by 7
- 2025Rethinking Key-Value Cache Compression Techniques for Large Language Model Servingcited by 7
- 2025FreqKV: Key-Value Compression in Frequency Domain for Context Window Extensioncited by 7
- 2025Recurrent Attention-based Token Selection for Efficient Streaming Video-LLMscited by 7
- 2025SparseServe: Unlocking Parallelism for Dynamic Sparse Attention in Long-Context LLM Servingcited by 5
- 2024Advancing the Understanding of Fixed Point Iterations in Deep Neural Networks: A Detailed Analytical Studycited by 4
- 2025HAMburger: Accelerating LLM Inference via Token Smashingcited by 4
- 2024Unlocking the Theory Behind Scaling 1-Bit Neural Networkscited by 3
- 2025Neural Algorithmic Reasoning for Hypergraphs with Looped Transformerscited by 3
- 2025When Can We Solve the Weighted Low Rank Approximation Problem in Truly Subquadratic Time?cited by 3
- 2025SALE : Low-bit Estimation for Efficient Sparse Attention in Long-context LLM Prefillingcited by 3
- 2026Adaptive Layer Selection for Layer-Wise Token Pruning in LLM Inferencecited by 3
- 2026StructKV: Preserving the Structural Skeleton for Scalable Long-Context Inferencecited by 3
- 2025Theoretical Foundation of Flow-Based Time Series Generation: Provable Approximation, Generalization, and Efficiencycited by 2
- 2026Coverage-Driven KV Cache Eviction for Efficient and Improved Inference of LLMcited by 2
- 2024Membership Inference Attack against Long-Context Large Language Modelscited by 1
- 2025PromptDistill: Query-based Selective Token Retention in Intermediate Layers for Efficient Large Language Model Inferencecited by 1
- 2025Unifying Learning Dynamics and Generalization in Transformers Scaling Lawcited by 1
- 2026Token Sparse Attention: Efficient Long-Context Inference with Interleaved Token Selectioncited by 1
- 2026PrefixWall: Mitigating Prefix Caching Side Channels in Shared LLM Systemscited by 1
- 2026CoMem: Reusing Transformer Depth across Queries with Persistent Intermediate Residualscited by 1
- 2026CLAA: Cross-Layer Attention Aggregation for Accelerating LLM Prefillcited by 0
- 2026Compression Beyond the Uncompressed: A Two-Stage Training Recipe for Soft Context Compression in RAGcited by 0
- 2026Compression Beyond the Uncompressed: A Two-Stage Training Recipe for Soft Context Compression in RAG4 Sep 2026
- 2026CoMem: Reusing Transformer Depth across Queries with Persistent Intermediate Residuals30 Jul 2026
- 2026Coverage-Driven KV Cache Eviction for Efficient and Improved Inference of LLM28 Jun 2026
- 2026StructKV: Preserving the Structural Skeleton for Scalable Long-Context Inference8 Apr 2026
- 2026PrefixWall: Mitigating Prefix Caching Side Channels in Shared LLM Systems11 Mar 2026
- 2026CLAA: Cross-Layer Attention Aggregation for Accelerating LLM Prefill17 Feb 2026
- 2026Token Sparse Attention: Efficient Long-Context Inference with Interleaved Token Selection3 Feb 2026
- 2026Adaptive Layer Selection for Layer-Wise Token Pruning in LLM Inference12 Jan 2026
- 2025Unifying Learning Dynamics and Generalization in Transformers Scaling Law26 Dec 2025
- 2025Recurrent Attention-based Token Selection for Efficient Streaming Video-LLMs20 Oct 2025
- 2025SparseServe: Unlocking Parallelism for Dynamic Sparse Attention in Long-Context LLM Serving29 Sep 2025
- 2025CentroidKV: Efficient Long-Context LLM Inference via KV Cache Clustering13 Jun 2025
27 more
- 2025SALE : Low-bit Estimation for Efficient Sparse Attention in Long-context LLM Prefilling30 May 2025
- 2025HAMburger: Accelerating LLM Inference via Token Smashing26 May 2025
- 2025FreqKV: Key-Value Compression in Frequency Domain for Context Window Extension1 May 2025
- 2025Rethinking Key-Value Cache Compression Techniques for Large Language Model Serving31 Mar 2025
- 2025PromptDistill: Query-based Selective Token Retention in Intermediate Layers for Efficient Large Language Model Inference30 Mar 2025
- 2025Theoretical Foundation of Flow-Based Time Series Generation: Provable Approximation, Generalization, and Efficiency18 Mar 2025
- 2025Theoretical Guarantees for High Order Trajectory Refinement in Generative Flows12 Mar 2025
- 2025Progressive Sparse Attention: Algorithm and System Co-design for Efficient Attention in LLM Serving1 Mar 2025
- 2025When Can We Solve the Weighted Low Rank Approximation Problem in Truly Subquadratic Time?24 Feb 2025
- 2025Speculative Prefill: Turbocharging TTFT with Lightweight and Training-Free Token Importance Estimation5 Feb 2025
- 2025FastKV: Decoupling of Context Reduction and KV Cache Compression for Prefill-Decoding Acceleration3 Feb 2025
- 2025Video Latent Flow Matching: Optimal Polynomial Projections for Video Interpolation and Extrapolation1 Feb 2025
- 2025Efficient Prompt Compression with Evaluator Heads for Long-Context Transformer Inference22 Jan 2025
- 2025Neural Algorithmic Reasoning for Hypergraphs with Looped Transformers18 Jan 2025
- 2024Theoretical Constraints on the Expressive Power of mathsfRoPE-based Tensor Attention Transformers23 Dec 2024
- 2024The Computational Limits of State-Space Models and Mamba via the Lens of Circuit Complexity9 Dec 2024
- 2024Membership Inference Attack against Long-Context Large Language Models18 Nov 2024
- 2024Circuit Complexity Bounds for RoPE-based Transformer Architecture12 Nov 2024
- 2024Unlocking the Theory Behind Scaling 1-Bit Neural Networks3 Nov 2024
- 2024MrT5: Dynamic Token Merging for Efficient Byte-level Language Models28 Oct 2024
- 2024Lossless KV Cache Compression to 2%20 Oct 2024
- 2024Advancing the Understanding of Fixed Point Iterations in Deep Neural Networks: A Detailed Analytical Study15 Oct 2024
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descent15 Oct 2024
- 2024HSR-Enhanced Sparse Attention Acceleration14 Oct 2024
- 2024Looped ReLU MLPs May Be All You Need as Practical Programmable Computers12 Oct 2024
- 2024TidalDecode: Fast and Accurate LLM Decoding with Position Persistent Sparse Attention7 Oct 2024
- 2024FaithEval: Can Your Language Model Stay Faithful to Context, Even If "The Moon is Made of Marshmallows"30 Sep 2024
- 2024MrT5: Dynamic Token Merging for Efficient Byte-level Language Modelscited by 27
- 2025FastKV: Decoupling of Context Reduction and KV Cache Compression for Prefill-Decoding Accelerationcited by 13
- 2025Efficient Prompt Compression with Evaluator Heads for Long-Context Transformer Inferencecited by 10
- 2025CentroidKV: Efficient Long-Context LLM Inference via KV Cache Clusteringcited by 8
- 2024Lossless KV Cache Compression to 2%cited by 7
- 2025Progressive Sparse Attention: Algorithm and System Co-design for Efficient Attention in LLM Servingcited by 7
- 2025Rethinking Key-Value Cache Compression Techniques for Large Language Model Servingcited by 7
- 2025FreqKV: Key-Value Compression in Frequency Domain for Context Window Extensioncited by 7
- 2025SparseServe: Unlocking Parallelism for Dynamic Sparse Attention in Long-Context LLM Servingcited by 5
- 2025HAMburger: Accelerating LLM Inference via Token Smashingcited by 4
- 2026Adaptive Layer Selection for Layer-Wise Token Pruning in LLM Inferencecited by 3
- 2026Coverage-Driven KV Cache Eviction for Efficient and Improved Inference of LLMcited by 2
12 most cited of 14 All 14 (JSON)
- 2026Coverage-Driven KV Cache Eviction for Efficient and Improved Inference of LLM28 Jun 2026
- 2026PrefixWall: Mitigating Prefix Caching Side Channels in Shared LLM Systems11 Mar 2026
- 2026Adaptive Layer Selection for Layer-Wise Token Pruning in LLM Inference12 Jan 2026
- 2025SparseServe: Unlocking Parallelism for Dynamic Sparse Attention in Long-Context LLM Serving29 Sep 2025
- 2025CentroidKV: Efficient Long-Context LLM Inference via KV Cache Clustering13 Jun 2025
- 2025HAMburger: Accelerating LLM Inference via Token Smashing26 May 2025
- 2025FreqKV: Key-Value Compression in Frequency Domain for Context Window Extension1 May 2025
- 2025Rethinking Key-Value Cache Compression Techniques for Large Language Model Serving31 Mar 2025
- 2025PromptDistill: Query-based Selective Token Retention in Intermediate Layers for Efficient Large Language Model Inference30 Mar 2025
- 2025Progressive Sparse Attention: Algorithm and System Co-design for Efficient Attention in LLM Serving1 Mar 2025
- 2025FastKV: Decoupling of Context Reduction and KV Cache Compression for Prefill-Decoding Acceleration3 Feb 2025
- 2025Efficient Prompt Compression with Evaluator Heads for Long-Context Transformer Inference22 Jan 2025
12 newest of 14 All 14 (JSON)
- 2025Video Latent Flow Matching: Optimal Polynomial Projections for Video Interpolation and Extrapolationcited by 11
- 2025Theoretical Guarantees for High Order Trajectory Refinement in Generative Flowscited by 9
- 2025Theoretical Foundation of Flow-Based Time Series Generation: Provable Approximation, Generalization, and Efficiencycited by 2
- 2025Theoretical Foundation of Flow-Based Time Series Generation: Provable Approximation, Generalization, and Efficiency18 Mar 2025
- 2025Theoretical Guarantees for High Order Trajectory Refinement in Generative Flows12 Mar 2025
- 2025Video Latent Flow Matching: Optimal Polynomial Projections for Video Interpolation and Extrapolation1 Feb 2025
- 2024TidalDecode: Fast and Accurate LLM Decoding with Position Persistent Sparse Attentioncited by 28
- 2024Circuit Complexity Bounds for RoPE-based Transformer Architecturecited by 26
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descentcited by 21
- 2024Looped ReLU MLPs May Be All You Need as Practical Programmable Computerscited by 19
- 2024HSR-Enhanced Sparse Attention Accelerationcited by 19
- 2024Theoretical Constraints on the Expressive Power of mathsfRoPE-based Tensor Attention Transformerscited by 12
- 2025Speculative Prefill: Turbocharging TTFT with Lightweight and Training-Free Token Importance Estimationcited by 12
- 2025Recurrent Attention-based Token Selection for Efficient Streaming Video-LLMscited by 7
- 2024Advancing the Understanding of Fixed Point Iterations in Deep Neural Networks: A Detailed Analytical Studycited by 4
- 2024Unlocking the Theory Behind Scaling 1-Bit Neural Networkscited by 3
- 2025When Can We Solve the Weighted Low Rank Approximation Problem in Truly Subquadratic Time?cited by 3
- 2025SALE : Low-bit Estimation for Efficient Sparse Attention in Long-context LLM Prefillingcited by 3
12 most cited of 17 All 17 (JSON)
- 2026CoMem: Reusing Transformer Depth across Queries with Persistent Intermediate Residuals30 Jul 2026
- 2026StructKV: Preserving the Structural Skeleton for Scalable Long-Context Inference8 Apr 2026
- 2026CLAA: Cross-Layer Attention Aggregation for Accelerating LLM Prefill17 Feb 2026
- 2026Token Sparse Attention: Efficient Long-Context Inference with Interleaved Token Selection3 Feb 2026
- 2025Unifying Learning Dynamics and Generalization in Transformers Scaling Law26 Dec 2025
- 2025Recurrent Attention-based Token Selection for Efficient Streaming Video-LLMs20 Oct 2025
- 2025SALE : Low-bit Estimation for Efficient Sparse Attention in Long-context LLM Prefilling30 May 2025
- 2025When Can We Solve the Weighted Low Rank Approximation Problem in Truly Subquadratic Time?24 Feb 2025
- 2025Speculative Prefill: Turbocharging TTFT with Lightweight and Training-Free Token Importance Estimation5 Feb 2025
- 2024Theoretical Constraints on the Expressive Power of mathsfRoPE-based Tensor Attention Transformers23 Dec 2024
- 2024Circuit Complexity Bounds for RoPE-based Transformer Architecture12 Nov 2024
- 2024Unlocking the Theory Behind Scaling 1-Bit Neural Networks3 Nov 2024
12 newest of 17 All 17 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2024Quest: Query-Aware Sparsity for Efficient Long-Context LLM Inference
- 2025SlimInfer: Accelerating Long-Context LLM Inference via Dynamic Token Pruning
- 2024TokenSelect: Efficient Long-Context Inference and Length Extrapolation for LLMs via Dynamic Token-Level KV Cache Selection
- 2025InfiniteHiP: Extending Language Model Context Up to 3 Million Tokens on a Single GPU
- 2025MoSKA: Mixture of Shared KV Attention for Efficient Long-Sequence LLM Inference
- 2024A Little Goes a Long Way: Efficient Long Context Training and Inference with Partial Contexts
- 2025PrefillOnly: An Inference Engine for Prefill-only Workloads in Large Language Model Applications
- 2025RetroInfer: A Vector Storage Engine for Scalable Long-Context LLM Inference