An Empirical Study on Prompt Compression for Large Language Models

Zheng Zhang, Jinyi Li, Yihuai Lan, Xiang Wang, Hao Wang
4/24/2025
cs.CLcs.AI

Official code: 3DAgentWorld/Toolkit-for-Prompt-Compression (292 stars, MIT, last commit 2025-02-11).

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.

View on arXivView PDF

Code Implementations(1)

MIT

Toolkit for Prompt Compression

29210Shell, PythonMar 8, 20241 years agoMIT

Similar Papers

Cite this paper

@article{zhang2025empirical,
  title  = {An Empirical Study on Prompt Compression for Large Language Models},
  author = {Zheng Zhang and Jinyi Li and Yihuai Lan and Xiang Wang and Hao Wang},
  year   = {2025},
  eprint = {2505.00019},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.00019v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.00019.svg)](https://codeofpaper.com/paper/2505.00019)

Discussion