LLMLingua: Compressing Prompts for Accelerated Inference of Large Language Models
Large language models (LLMs) have been applied in various applications due to their astonishing capabilities. With advancements in technologies such as chain-of-thought (CoT) prompting and in-context learning (ICL), the prompts fed to LLMs are becoming increasingly lengthy, even exceeding tens of thousands of tokens. To accelerate model inference and reduce cost, this paper presents LLMLingua, a coarse-to-fine prompt compression method that involves a budget controller to maintain semantic integrity under high compression ratios, a token-level iterative compression algorithm to better model the interdependence between compressed contents, and an instruction tuning based method for distribution alignment between language models. We conduct experiments and analysis over four datasets from different scenarios, i.e., GSM8K, BBH, ShareGPT, and Arxiv-March23; showing that the proposed approach yields state-of-the-art performance and allows for up to 20x compression with little performance loss.
instruction과 question이 더 중요하다는 전제 하에, 이 둘의 값을 먼저 정하고, 그것에 맞춰 demonstration의 압축률을 정함
Demonstration 압축이 끝난 이후에, 남는 budget은 추후에 instruction과 question에 추가적으로 할당 ( $\tilde{L}D$는 실제 압축된 길이, $k \times \tau{dems}L_{dems}$ 는 할당된 budget에 따른 최대 허용 길이)
$x_{dems}$에서 subset $D$를 뽑아내는 과정 (몇 개의 demonstration을 남길 것인가?)
Perplexity를 보고, 높은 순서대로 정렬해둔 뒤, 주어진 subset 길이를 초과하기 전까지 demonstration을 추가 (남는 budget은 여기에서 발생)