Density-aware Soft Context Compression with Semi-Dynamic Compression Ratio

Yijiong Yu, Shuai Yuan, Jie Zheng, Huazheng Wang, Ji Pei
3/26/2026
cs.CL

Official code: yuyijiong/semi-dynamic-context-compress (5 stars, last commit 2026-04-04).

Abstract

Soft context compression reduces the computational workload of processing long contexts in LLMs by encoding long context into a smaller number of latent tokens. However, existing frameworks apply uniform compression ratios, failing to account for the extreme variance in natural language information density. While adopting a density-aware dynamic compression ratio seems intuitive, empirical investigations reveal that models struggle intrinsically with operations parameterized by input dependent, continuous structural hyperparameters. To resolve this pitfall, we introduce Semi-Dynamic Context Compression framework. Our approach features a Discrete Ratio Selector, which predicts a compression target based on intrinsic information density and quantizes it to a predefined set of discrete compression ratios. It is efficiently jointly trained with the compressor on synthetic data, with the summary lengths as a proxy to create labels for compression ratio prediction. Extensive evaluations confirm that our density-aware framework, utilizing mean pooling as the backbone, consistently outperforms static baselines, establishing a robust Pareto frontier for context compression techniques. Our code, data and model weights are available at https://github.com/yuyijiong/semi-dynamic-context-compress

View on arXivView PDF

Code Implementations(1)

50PythonMar 25, 20266 months ago

Similar Papers

Cite this paper

@article{yu2026densityaware,
  title  = {Density-aware Soft Context Compression with Semi-Dynamic Compression Ratio},
  author = {Yijiong Yu and Shuai Yuan and Jie Zheng and Huazheng Wang and Ji Pei},
  year   = {2026},
  eprint = {2603.25926},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2603.25926v1}
}

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/2603.25926.svg)](https://codeofpaper.com/paper/2603.25926)

Discussion