arXiv:2609.11192cs.CLSep 2026

Manuscript Offprint

arXiv:2609.11192

FlexComp: One Model for Every Ratio in Context Compression

Kaiyan Zhao, Zhongtao Miao, Akiko Aizawa, Yoshimasa Tsuruoka

Abstract

Soft context compression condenses a context into a few memory tokens that a frozen LLM consumes in place of the raw text, but existing compressors fix the compression ratio at training and inference: each deployed ratio requires a separately trained model, and the chosen ratio is applied uniformly to all inputs, whose actual needs vary drastically. We propose FlexComp, a method-agnostic framework that decouples the ratio from both training and deployment: Matryoshka-style training samples the memory budget K per instance, turning one model into an any-ratio compressor, and the budget is then chosen per input by: (1) confidence-based cascade routing or (2) a lightweight learned K predictor. Across ICAE, 500xCompressor, and SAC on MRQA, a single FlexComp model matches separately trained fixed-ratio specialists with minimal degradation. Cascade routing preserves over 98% of the mildest ratio's accuracy at up to 266×266\times average compression; the K predictor, in a single compression-decoding pass, reaches 158−236×158-236\times within 0.7 F110.7\ F1^{1} of the mildest ratio. At serving-scale batch sizes, the K predictor cuts context KV cache by 50% and improves decoding throughput by 47%.

1 Introduction

Large language models (LLMs) rarely answer from a question alone: in most applications, contexts, such as retrieved passages, tool outputs, documents, or conversation history are needed for generation, besides the prompt (Lewis et al., 2020; Yuan et al., 2025; Zhao et al., 2026). Serving these context tokens is costly, as they must be prefilled on every query, and their Key-Value (KV) cache occupies memory for the whole generation, often dominating the memory footprint of inference (Liu et al., 2025). Context compression offers an attractive remedy: a compressor condenses the context into a small number of soft memory tokens, and the LLM

Figure

Figure 1: Fixed-ratio compression vs. FlexComp. Top: for existing soft-token compressors, each deployed compression ratio requires a separately trained model, and the model applies the fixed ratio uniformly to all inputs. Bottom: FlexComp trains a single model that supports any ratio, and selects the budget per input at inference time, via cascade routing or K predictor.

can run inference based on the compressed soft tokens instead of the raw context (Ge et al., 2024; Li et al., 2025; Zhao et al., 2025; Liu et al., 2026; Miao et al., 2026).

Despite steady progress on compression quality, existing methods share a structural limitation: the compression ratio is fixed at training and inference time. As illustrated in Figure 1 (top), supporting multiple operating modes, e.g., mild compression for difficult inputs and aggressive compression when memory is scarce, requires training, storing, and serving a separate model for every ratio. Moreover, whichever ratio is deployed is applied uniformly to all inputs, regardless of how much each input actually needs.

This uniformity is wasteful, because different inputs need very different budgets. Figure 2 shows that for the in-domain subsets in MRQA (Fisch et al., 2019), most inputs are already solved with a

1^{1}All F1 scores are reported on a 0-100 scale.

Figure

Figure 2: The budget each input needs varies drastically. For each subset, we show the distribution over solvable inputs of the minimal sufficient budget: the smallest K∈{1,10,34}K \in \{1, 10, 34\} (number of memory tokens) at which the SAC Matryoshka model answers correctly. A large fraction of inputs is already solvable at K=1 (510x compression), so any fixed ratio could be suboptimal.

single memory token (soft token length K=1)2K = 1)^{2}, yet a non-trivial minority is only solved with far larger budgets. A fixed K therefore loses on both ends: it wastes tokens on the many easy inputs and starves the few hard ones. Worse, the best fixed choice differs from domain to domain, so no single ratio serves all deployments well.

To this end, we propose FlexComp, a framework that decouples the compression ratio from both training and deployment (Figure 1, bottom). FlexComp has two components. First, we introduce Matryoshka-style training for context compression, inspired by matryoshka representation learning (Kusupati et al., 2022). Specifically, during training, the soft prompt length K is sampled per instance, so that a single model learns to encode the context into K memory tokens for any budget in the supported range. One model thus replaces an entire family of fixed-ratio compressors, with no architectural changes to the underlying method. Second, since the budget is now a free inference-time variable, we introduce two complementary strategies for choosing it per input: cascade routing, which starts from the most aggressive budget and re-encodes at a larger one only when the decoder is uncertain, and a lightweight K predictor, which commits to a budget before compression and thus answers in a single compression-decoding pass. FlexComp is method-agnostic; we instantiate it on three representative compressors: ICAE (Ge et al., 2024), 500xCompressor (Li et al., 2025), and SAC (Liu et al., 2026).

Across in-domain (ID) and out-of-domain (OOD) question answering tasks on MRQA (Fisch et al., 2019), a single Matryoshka-trained model matches separately trained fixed-ratio specialists at each native ratio (within 1.3 F1 in the worst case, and often better on OOD), cutting the number of trained models from n to one. On top of the same model, adaptive budget selection improves the accuracy-compression trade-off over any fixed ratio: cascade routing retains over 98% of the mildest ratio's accuracy while raising the average compression from 15×15 \times to up to 266×266 \times, and the K predictor reaches 158−236×158-236 \times in a single compression-decoding pass, at a cost of at most 0.7 F1. These savings are not merely nominal: at serving-scale batch sizes, the predictor cuts context KV cache by 50% and improves aggregate decoding throughput by 47% relative to always running at the mildest ratio.

In summary, our contributions are as follows:

• We show that Matryoshka training turns a fixed-ratio context compressor into a single any-ratio compressor, validated on three distinct methods with negligible degradation.

• We introduce two per-input budget-selection strategies for soft context compression: confidence-driven cascade routing and the K predictor that commits to a budget before compression; for the predictor, we further show these savings translate into gains in KV memory and decoding throughput.

• We systematically analyze the accuracy-compression trade-off, and find it non-monotonic at the instance level: on a non-trivial fraction of inputs, larger budgets preserve surface details that may mislead the decoder, and a single memory token answers correctly where the full budget fails.