Abstract
Large Language Models (LLMs) increasingly rely on extensive prompts for tasks like Retrieval-Augmented Generation (RAG) and In-Context Learning. However, the quadratic complexity of self-attention leads to significant computational overhead and latency. We present DisComp, a two-stage prompt compression framework that balances efficiency and intelligence. DisComp first employs a distillation-based task-agnostic summarization stage to reduce general redundancy, followed by a task-aware sentence-level pruning stage that aligns content with specific user queries. By utilizing a hybrid scoring mechanism and keyword-matching loss, DisComp achieves state-of-the-art performance on benchmarks like LongBench and ZeroSCROLLS while operating up to 6.56x faster than existing token-level compression methods.
Introduction
The rise of long-context LLMs has enabled sophisticated applications, yet it has introduced the challenge of "context bloat." As prompt lengths grow, the computational cost of the Transformer's self-attention mechanism increases quadratically. This results in high latency and hardware demands, necessitating effective prompt compression. Existing solutions generally fall into two categories: task-agnostic methods, which remove redundancy regardless of the query, and task-aware methods, which tailor compression to specific questions. While task-agnostic methods generalize well, they risk deleting critical information. Conversely, task-aware methods, particularly those operating at the token level, are often computationally expensive. DisComp addresses these limitations by combining the strengths of both approaches in a high-speed, two-stage framework.
Methodology
DisComp operates through two distinct phases: distillation-based summarization and sentence-level pruning.
Stage 1: Task-Agnostic Summarization
In the first stage, DisComp distills knowledge from a large "teacher" model (GPT-3.5-Turbo) into a smaller "student" model (T5-large, 775M parameters). To ensure the student model retains factual density rather than just generating fluent text, the authors introduced a Keyword Matching Loss using the RAKE (Rapid Automatic Keyword Extraction) algorithm. This forces the model to prioritize high-information keywords identified by the teacher, preventing the "hallucinated" summaries often seen in standard distillation.
Stage 2: Task-Aware Sentence-Level Pruning
The summarized text then undergoes query-specific pruning. Sentences are ranked using a hybrid score that balances two factors:
- Semantic Similarity: The embedding distance between the sentence and the user's query.
- Generation Probability: The likelihood of the LLM producing a correct answer given that specific sentence.
Low-scoring sentences are discarded until the target compression ratio is met. The remaining text is re-ordered to maintain the original narrative flow, which is crucial for LLM comprehension.
Experimental Evaluation
DisComp was evaluated across three major benchmarks to test its versatility:
- LongBench: A comprehensive benchmark for long-context tasks including single/multi-doc QA and summarization.
- ZeroSCROLLS: A zero-shot benchmark focused on long-text understanding.
- NaturalQuestions: Used to test performance in RAG settings where the position of the answer varies.
The student model was fine-tuned on a custom dataset derived from Wikitext-103, emphasizing factual content.
Key Results and Analysis
DisComp demonstrates superior performance across multiple metrics, effectively addressing both accuracy and efficiency.
Superior Accuracy
On LongBench and ZeroSCROLLS, DisComp consistently outperformed previous state-of-the-art methods like LLMLingua and LongLLMLingua across various compression ratios. For instance, under a 2,000-token constraint, DisComp achieved an average score of 49.6 on LongBench, compared to 48.0 for LongLLMLingua.
Efficiency and Latency
Beyond accuracy, DisComp offers a significant speed advantage. By performing task-aware compression at the sentence level rather than the token level, it drastically reduces the number of entropy calculations required. In head-to-head tests, DisComp was 13.88x faster in average processing time and 6.56x faster in median processing time compared to leading token-level compressors.
Robustness to Information Position
LLMs often struggle with the "lost in the middle" phenomenon, where information in the center of a prompt is ignored. DisComp’s ranking system effectively extracts relevant "needles" regardless of their original position, maintaining high accuracy even when the answer is buried deep in the context.
Conclusion and Future Work
DisComp provides a robust solution for prompt compression, bridging the gap between general summarization and query-specific relevance. While it shows some domain bias toward encyclopedic text and slightly lower performance on synthetic or code-based tasks, its efficiency and accuracy make it highly suitable for production environments. Future directions include expanding the training set to specialized domains like legal or medical text and refining sentence-scoring mechanisms.
Summary updated