Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

Discovering the Gems in Early Layers: Accelerating Long-Context LLMs with 1000x Input Token Reduction

About

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$\times$ 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 \url{https://github.com/SalesforceAIResearch/GemFilter}.

Zhenmei Shi, Yifei Ming, Xuan-Phi Nguyen, Yingyu Liang, Shafiq Joty• 2024

Related benchmarks

TaskDatasetResultRank
Long-context Language UnderstandingLongBench
M-Avg45.11
219
Long-context Language UnderstandingLongBench (test)
Average Score46.37
133
Long-context UnderstandingRULER
Performance @ 4K Context92.5
65
Long-context language modelingRULER
Accuracy (8K Context)0.83
34
Long-context UnderstandingInfiniteBench v1 (test)
Dialogue17
31
Long-context language modelingInfiniteBench (test)
En Sum Score0.54
10
Long-context performance evaluationRULER--
10
Long-context Text GenerationRULER
Mean Throughput3.32
8
Long-context Language UnderstandingRULER 64k context length
Multi-Key Score58.2
6
Long-context retrievalNeedle-in-a-Haystack 1.0 (test)
Score95.8
5
Showing 10 of 10 rows

Other info

Follow for update