Beyond Compressing Everything: Contrastive Memory Learning for Selective Context Compression

As large language models (LLMs) advance toward increasingly long inputs, soft context compression offers a promising approach to efficient inference by converting long inputs into compact memory slots. Under limited memory budgets, effective context compression remains challenging because task-relevant evidence varies substantially across queries, ranging from localized evidence to multiple distant spans or information dispersed throughout the full document. Instead of compressing everything indiscriminately, we propose CoMem, a query-guided selective context compression framework that learns memory representations conditioned on both the document and the query. CoMem develops Contrastive Compressor Learning to achieve query-sensitive yet context-preserving memory representations. To inject a strong prior over query-dependent evidence distributions, we devise a same-context hard negative mining strategy by pairing a single document with multiple queries, requiring the compressor to selectively retain information according to each query's distinct evidence needs. To address the restricted information flow imposed by causal masking, we further enable bidirectional attention among memory slots. Experiments demonstrate that CoMem consistently outperforms existing context compression methods across compression ratios on question answering and RULER-NIAH benchmarks. Our code is available at https://github.com/scar-on/CoMem.

Link
https://www.semanticscholar.org/paper/42d2cb9a196a3c352c89887a463c96a1e2f9e547
Found by
Semantic Scholar
Authors
Si-Kui Zhang, Hao-Wei Liu, Zi-Yun Gan, Chun-Feng Yuan, Guang-Ze Gao, Nian Liu, Bo-Yu Cai, Bo Li, Xiao-Lei Lv, Jun Gao, Bing Li, Wei-Ming Hu
Categories
benchmark
Published
2026-11-12
Last seen by the radar
2026-11-14
Citations
0
Influential citations
0
Radar score
26.75 / 100 (how it is scored)
Why it scored so
Matched: benchmark; Primary record: Semantic Scholar
Related links
https://arxiv.org/abs/2611.16384
Is this record right? If you made this work and something here is wrong or missing, tell us what to fix.

More records found by Semantic Scholar