EFPC: Towards Efficient and Flexible Prompt Compression

Yun-Hao Cao, Yangsong Wang, Shuzheng Hao, Zhenxing Li, Chengjun Zhan, Sichao Liu, Yi-Qi HuarXiv 2025 · DOI

Abstract Efficient and Flexible Prompt Compression (EFPC) is a novel framework designed to unify task-aware and task-agnostic prompt compression into a single, lightweight model. Utilizing a BERT-based token classifier and a highly data-efficient training strategy, EFPC achieves state-of-the-art accuracy, outperforming existing methods by over 11% on long-context benchmarks. Furthermore, it significantly reduces computational overhead and GPU memory usage, offering a scalable solution for processing large-scale prompts in Large Language Models (LLMs).

1. Introduction

Large Language Models (LLMs) have revolutionized natural language processing through techniques such as Retrieval-Augmented Generation (RAG) and In-Context Learning (ICL). However, these methods often require prompts containing tens of thousands of tokens, leading to substantial API costs, high latency, and performance degradation—often referred to as the "lost in the middle" phenomenon.

Existing prompt compression techniques generally fall into two categories: task-agnostic and task-aware. Task-agnostic methods, such as LLMLingua-2, prune tokens based on general importance. While fast and generalizable, they may discard information critical for specific queries. Conversely, task-aware methods tailor compression to a specific question but often rely on heavy Transformer decoder architectures (e.g., Llama-2-7B), making them computationally expensive and difficult to scale. EFPC bridges this gap by providing a method that is as fast as task-agnostic models and as precise as task-aware ones.

2. Methodology

EFPC conceptualizes prompt compression as a binary token classification task. For each token in a prompt, the model predicts whether it should be preserved or discarded.

The EFPC framework encompasses three stages: data collection via GPT-4 distillation, model training using a token classifier, and efficient model inference.

The architecture employs a lightweight Transformer encoder, specifically multilingual-BERT, ensuring rapid compression. A key innovation is the model's flexibility: it accepts an optional instruction (the user's query) alongside the original text. When an instruction is present, the model operates in task-aware mode; otherwise, it defaults to task-agnostic mode.

To train the model, the authors utilized GPT-4 to generate a "distilled" dataset. GPT-4 was instructed to compress text while ensuring it remained sufficient to answer a specific question. This allows the smaller BERT-based model to inherit the reasoning capabilities of a much larger model. During training, a specialized loss function ($L_{mask}$) is used, which ignores classification loss for instruction tokens, enhancing performance and consistency.

3. Experimental Setup

The model was trained on MeetingBank, a dataset consisting of meeting transcripts and summaries, segmented into 512-token chunks. Evaluation was conducted across both in-domain (MeetingBank QA and Summarization) and out-of-domain benchmarks, including LongBench and ZeroSCROLLS, to assess the model's generalization capabilities across diverse content types like legal documents and technical code.

4. Results and Analysis

EFPC demonstrates significant improvements in both accuracy and efficiency. On the LongBench single-document QA benchmark, EFPC achieved an 11.4% gain over the previous state-of-the-art, LLMLingua-2.

F1 Score performance on LongBench SingleDoc across different compression ratios. EFPC consistently outperforms LLMLingua-2, even with minimal training data.

Key findings include:

  • Data Efficiency: EFPC is remarkably data-efficient. Incorporating just 1% additional training data (approximately 50 documents) resulted in a 4.8% relative improvement in F1-score on LongBench.
  • High Compression Robustness: Unlike many methods that suffer a "performance cliff" beyond 3x or 4x compression, EFPC maintains high accuracy even at 5x compression.
  • Computational Efficiency: The framework provides an end-to-end speedup of 1.6x to 2.4x compared to uncompressed prompts and reduces GPU memory requirements by up to 8x.

5. Conclusion

EFPC represents a significant step toward efficient prompt management for LLMs. By leveraging a bidirectional encoder for token filtering rather than a unidirectional decoder, the framework achieves superior precision with minimal computational overhead. Future work will explore training on more diverse datasets and evaluating performance with a wider range of target LLM sizes and specialized domains.

Summary updated

BibTeX
@misc{cao2025efpc,
  author = {Yun-Hao Cao and Yangsong Wang and Shuzheng Hao and Zhenxing Li and Chengjun Zhan and Sichao Liu and Yi-Qi Hu},
  title = {{EFPC: Towards Efficient and Flexible Prompt Compression}},
  year = {2025},
  eprint = {2503.07956},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.07956},
}
Figure