An Empirical Study on Prompt Compression for Large Language Models
Zheng Zhang, Jinyi Li, Yihuai Lan, Xiang Wang, Hao Wang
TL;DR
This work tackles the cost and latency associated with long prompts for large language models by conducting an empirical study of six prompt compression methods across 13 datasets and three (M)LLMs, introducing the compression ratio $\rho = 1 - \frac{L_c}{L_o}$ to quantify input shortening. It evaluates six compressors (KiS, SCRL, Selective Context, LLMLingua, LongLLMLingua, LLMLingua-2) on tasks including summarization, reconstruction, and QA, with multimodal VQA analysis, and uses MiHR/MaHR to assess hallucinations. The authors find long-context prompts are more sensitive to compression, moderate compression can improve long-context QA, and LLMLingua variants generally deliver the best performance at high compression, while all methods increase hallucinations due to information loss. They also introduce PCToolkit for reproducible evaluation and provide insights on word omission and multimodal applicability, underscoring practical guidance for prompt design in real-world deployments.
Abstract
Prompt engineering enables Large Language Models (LLMs) to perform a variety of tasks. However, lengthy prompts significantly increase computational complexity and economic costs. To address this issue, we study six prompt compression methods for LLMs, aiming to reduce prompt length while maintaining LLM response quality. In this paper, we present a comprehensive analysis covering aspects such as generation performance, model hallucinations, efficacy in multimodal tasks, word omission analysis, and more. We evaluate these methods across 13 datasets, including news, scientific articles, commonsense QA, math QA, long-context QA, and VQA datasets. Our experiments reveal that prompt compression has a greater impact on LLM performance in long contexts compared to short ones. In the Longbench evaluation, moderate compression even enhances LLM performance. Our code and data is available at https://github.com/3DAgentWorld/Toolkit-for-Prompt-Compression.
