PromptDistill: Query-based Selective Token Retention in Intermediate Layers for Efficient Large Language Model Inference

Weisheng Jin, Maojia Song, Pala Tej Deep, Yew Ken Chia, Amir Zadeh, Chuan Li, Soujanya PoriaarXiv 2025 · DOI

TL;DR

This paper introduces PromptDistill, a novel, training-free method to significantly speed up Large Language Model (LLM) inference for long contexts. By intelligently selecting and retaining the most informative tokens in intermediate layers, PromptDistill reduces computational load without sacrificing generation quality, outperforming existing methods like GemFilter.

What Problem Does This Paper Address?

Large Language Models (LLMs) are becoming increasingly powerful, but their widespread adoption is hampered by the immense computational and memory costs associated with processing long input sequences during inference. As context lengths grow, these costs become a major bottleneck, making it challenging to deploy LLMs for tasks requiring extensive background information. Existing methods often struggle to balance efficiency gains with maintaining output quality, either by compressing information too aggressively or by requiring extensive retraining.

Methods

PromptDistill tackles this problem with a training-free approach that focuses on selective token retention in intermediate layers. Here's how it works:

  • Leveraging Attention: The core idea is to use the attention mechanism's inherent ability to identify important tokens. Specifically, PromptDistill uses the dot product between the query of the last prompt token and the keys of all other tokens in an intermediate layer to score their relevance.
  • Preserving Hidden States: Instead of discarding tokens entirely, PromptDistill retains the hidden states of the selected "important" tokens. This allows the model to continue processing these tokens in subsequent layers, preserving crucial contextual information.
  • Single-Stage Selection: In its basic form, PromptDistill selects tokens at a single intermediate layer.
  • Cache Truncation: To further boost efficiency, PromptDistill implements cache truncation. This means that after token selection, the key-value cache is pruned to only include entries for the selected tokens, significantly reducing memory usage and computation in later layers.
  • Multi-Stage Selection: The authors also explore a more advanced multi-stage selection process, where tokens are progressively selected and refined across multiple layers. This allows for a more nuanced approach to compression, balancing efficiency and effectiveness.

Datasets

The paper evaluates PromptDistill on the following benchmarks:

  • LongBench: A benchmark designed for evaluating long-context tasks.
  • InfBench: Another benchmark for long-context tasks, featuring even longer prompts.
  • Needle in a Haystack: A benchmark specifically designed to test an LLM's ability to retrieve accurate information from a specific sentence hidden within a large document.

The authors use base models such as LLaMA 3.1 8B Instruct, Phi 3.5 Mini Instruct, and Qwen2 7B Instruct for their experiments.

Key Insights and Ideas

  • Intermediate Layers are Key: The paper highlights that intermediate layers of LLMs already contain rich contextual information that can be leveraged for efficient token selection, without needing to process the entire model.
  • Retaining Hidden States is Crucial: Unlike methods that simply discard tokens, PromptDistill's approach of retaining hidden states of selected tokens is vital for maintaining performance. This allows for a more holistic representation of the context.
  • Cache Truncation is a Game-Changer: The implementation of cache truncation significantly amplifies the efficiency gains, demonstrating that it's not just about selecting tokens but also about managing the memory footprint of the attention mechanism.
  • Multi-Stage Selection Offers Flexibility: The exploration of multi-stage selection suggests that a more dynamic and layered approach to token selection can further optimize efficiency without sacrificing accuracy, offering a tunable trade-off.

Key Results

PromptDistill demonstrates significant improvements in inference efficiency across various LLMs and benchmarks:

  • Efficiency Gains: PromptDistill significantly reduces computational and memory costs during inference.
  • Performance Preservation: The method achieves minimal impact on output quality, often matching or even slightly improving upon baseline performance.
  • Outperforming Baselines: Compared to GemFilter, PromptDistill achieves an overall 1% to 5% performance improvement while also offering better time efficiency. It also outperforms H2O and SnapKV.
  • Multi-stage Benefits: Multi-stage selection further enhances efficiency while maintaining strong generation performance.
  • Specific Model Performance: For example, on LongBench, PromptDistill-4096 achieved a 30.2 score for LLaMA 3.1 8B Instruct, compared to GemFilter-4096's 25.66.

Limitations and Future Work

  • Extreme Performance Cases: The paper notes that for the Phi-3.5 model, GemFilter performed exceptionally poorly at a selected token count of 4096 on InfBench and Needle in a Haystack. This issue might stem from factors like specific hardware, CUDA version differences, or the model's fine-tuning process, and it disrupts GemFilter's performance due to its rerunning mechanism. PromptDistill's approach appears more robust in these scenarios.
  • Future Work: The authors suggest further exploration of multi-stage selection and its impact on efficiency and performance. They also hint at the adaptability of LLM hidden representations and provide insights into optimizing inference for long-context scenarios. The availability of their implementation is also noted.

Summary updated

BibTeX
@misc{jin2025promptdistill,
  author = {Weisheng Jin and Maojia Song and Pala Tej Deep and Yew Ken Chia and Amir Zadeh and Chuan Li and Soujanya Poria},
  title = {{PromptDistill: Query-based Selective Token Retention in Intermediate Layers for Efficient Large Language Model Inference}},
  year = {2025},
  eprint = {2503.23274},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.23274},
}
Figure