[Paper Review] LongLLMLingua: Accelerating and Enhancing LLMs in Long Context Scenarios via Prompt Compression
LongLLMLingua introduces a question-aware prompt compression pipeline that improves key information density, reorders documents, adapts compression granularity, and recovers subsequences, yielding higher task performance with lower costs and faster latency in long-context LLM use.
In long context scenarios, large language models (LLMs) face three main challenges: higher computational cost, performance reduction, and position bias. Research indicates that LLM performance hinges on the density and position of key information in the input prompt. Inspired by these findings, we propose LongLLMLingua for prompt compression towards improving LLMs' perception of the key information to simultaneously address the three challenges. Our extensive evaluation across various long context scenarios demonstrates that LongLLMLingua not only enhances performance but also significantly reduces costs and latency. For instance, in the NaturalQuestions benchmark, LongLLMLingua boosts performance by up to 21.4% with around 4x fewer tokens in GPT-3.5-Turbo, leading to substantial cost savings. It achieves a 94.0% cost reduction in the LooGLE benchmark. Moreover, when compressing prompts of about 10k tokens at ratios of 2x-6x, LongLLMLingua can accelerate end-to-end latency by 1.4x-2.6x. Our code is available at https://aka.ms/LongLLMLingua.
Motivation & Objective
- Motivate efficient, cost-effective use of LLMs in long-context tasks (qa, summarization, coding, etc.).
- Enhance the model’s perception of question-relevant information within compressed prompts.
- Reduce end-to-end latency and API costs while maintaining or improving accuracy.
- Develop and evaluate a prompt-compression framework tailored for long documents and multiple tasks.
Proposed method
- Develop a prompt-compression framework built on LLMLingua with LongLLMLingua enhancements.
- Introduce question-aware coarse-grained compression to select documents via a document-level metric r_k using question-conditioned perplexity.
- Propose contrastive perplexity to guide fine-grained token-level compression for better question relevance.
- Implement document reordering based on importance scores to mitigate information loss in the middle of prompts.
- Adopt dynamic compression ratios to allocate more budget to more relevant documents during fine-grained compression.
- Incorporate a post-compression subsequence recovery strategy to restore original substrings in LLM outputs.
Experimental results
Research questions
- RQ1How can prompt compression be adapted to emphasize question-relevant information in long-context prompts?
- RQ2Do coarse-to-fine compression, document reordering, and adaptive budgeting improve LLM performance and efficiency in long-context tasks?
- RQ3Can a subsequence recovery step improve accuracy and reliability of outputs derived from compressed prompts?
- RQ4What is the latency and cost impact of LongLLMLingua on standard long-context benchmarks?
Key findings
- LongLLMLingua achieves higher performance with substantially fewer input tokens compared to the original prompts on long-context tasks (e.g., up to 17.1% gain on NaturalQuestions with ~4x fewer tokens).
- The approach yields cost savings on LongBench and ZeroScrolls benchmarks (e.g., $28.5 and $27.4 per 1,000 samples).
- End-to-end latency is reduced with compression, achieving 1.4x–3.8x speedups as compression ratio increases.
- Ablation studies show removing any proposed component degrades performance, confirming the necessity of the question-aware mechanism, dynamic ratios, and subsequence recovery.
- Document reordering improves performance not only for LongLLMLingua but also benefits other baselines, demonstrating its effectiveness.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.