arXiv:2610.11784cs.LGOct 2026

Manuscript Offprint

arXiv:2610.11784

Compile the Table: Query-Calibrated Operator Compression for Tabular In-Context Learning

Xu Zhao, Jiaming Zhao, Bin Zhao, Yong Yang

Abstract

Tabular in-context learning (ICL) has emerged as a training-free and accurate paradigm for tabular prediction, but current approaches to compressing its in-context examples face an accuracy–throughput tradeoff: fixed subsets can sacrifice accuracy, while query-specific retrieval limits cache reuse and batching across queries, reducing throughput. We propose QCOC (Query-Calibrated Operator Compression), which exploits the exchangeability and repeated use of in-context examples by compiling their full KV cache once into compact memory shared across subsequent queries. Instead of retaining raw examples, QCOC clusters their states into joint-KV prototypes, preserves per-cluster multiplicities and the original example count, and calibrates prototype values against attention query vectors produced by the in-context examples through an anchored closed-form solution. Prototype compression drives the speedup, while value fitting helps preserve accuracy. On 64 held-out OpenML-CC18 datasets, QCOC achieves the highest mean accuracy among the compared compression and retrieval methods at both retained counts. Across 12 configurations on seven long tables, it ranks first among compressed methods in ten and averages 0.23 percentage points below full context. Compressing 8,192 in-context examples to 512 memory slots yields a 10.5×10.5\times cache compression ratio; excluding one-time compilation, in a single-core CPU online-serving comparison over 1,000 queries, QCOC is up to 508×508\times faster than dynamic retrieval baselines and 1.98×1.98\times faster than full-context inference. These results show that QCOC enables compact-memory reuse and efficient inference across queries while retaining accuracy close to full context.

Email: {zhaoxu.135, zhaojiaming.214}@jd.com

1 Introduction

Tabular in-context models predict new rows from a labeled in-context example set [12, 13, 26]. Larger contexts expose more in-context information, but increase cache memory and repeated-query inference cost [8, 27]. When one in-context example set serves many queries, what should compression preserve?

Existing context-compression methods mainly select in-context examples in two ways. Global row selection constructs one subset for all queries, making the selected context reusable but often discarding rows needed for accurate prediction [6, 14, 29]. Dynamic row selection retrieves a query-specific subset and often improves local relevance, but limits context reuse and batching across queries, thereby reducing serving throughput [11, 16, 32]. KATE [20], for example, performs nearest-neighbor retrieval in a pretrained representation before each prediction. This creates a central accuracy–throughput tradeoff: global selection has low serving cost but may lose relevant rows, whereas dynamic selection can preserve local relevance at higher serving cost.

Offline operator compilation

Figure

Figure 1 Reusable operator compilation with QCOC. The full in-context cache induces a query-dependent attention operator. Attention query vectors produced by the in-context examples are passed through the full cache to obtain target outputs, and QCOC compresses the cache into (K~ℓ,V~ℓ∗,log⁡wℓ,N)(\widetilde{K}_{\ell}, \widetilde{V}_{\ell}^{*}, \log w_{\ell}, N) memory reused by future queries. Joint-KV clustering, cluster-count weighting, and anchored ridge fitting implement this process.

To resolve this tradeoff, we propose Query-Calibrated Operator Compression (QCOC), which shifts the object of compression from in-context examples to the query-output mapping defined by the in-context example set. For a fixed in-context example set D, each attention head defines a mapping from a query state q to an attention output AD(q)\mathcal{A}_{\mathcal{D}}(q); we refer to this mapping as the in-context-example-conditioned attention operator. Once the in-context example set is fixed, the full KV cache determines this mapping: subsequent queries share the same cache while producing query-dependent outputs. We study tabular compression through reusable operator compilation: approximate the full-cache operator once with a compact memory and apply the compiled operator to subsequent queries. Section 3 gives the formal definition.

Concretely, QCOC compiles the operator induced by an in-context example set into a compact, reusable KV memory. Because the labeled in-context examples are exchangeable, their individual identities and input order need not be retained: at every layer and head, joint-KV clustering groups their states into prototypes, while exact cluster counts restore the total attention contribution of the examples represented by each prototype. Any length-dependent query transformation is evaluated using the original number of in-context examples N rather than the number of compressed slots M. Attention query vectors produced by the in-context examples are passed through the full cache to obtain target outputs. With the compressed keys and cluster counts fixed, one regularized least-squares solve fits the compressed value vectors to reproduce these outputs. The compiled KV memory is reused by every future query while still producing a query-specific attention output.

Our contributions are:

  • We propose Query-Calibrated Operator Compression (QCOC), a post-hoc KV-compression method for tabular ICL. It uses the exchangeability and repeated reuse of labeled in-context examples to aggregate their states into joint-KV prototypes with exact cluster counts, then fits the prototype values using attention query vectors produced by the examples, producing compressed KV memory reusable across queries without extra data or model updates.

• We derive a prototype approximation bound that relates attention-output error to key and value approx-imation errors, and show that the closed-form value fit cannot increase the residual on its calibration queries. Additional analysis characterizes how approximation error may propagate or change across query distributions.

  • Through the primary benchmark, long-context evaluation, transfer-model experiments, and multi-query serving experiments, we show that QCOC retains predictive performance close to full context after KV-cache compression and reduces online inference cost when the cache is reused across queries. Component analysis further clarifies the roles of cluster counts, the original example count N, and value fitting, while failure-case analysis identifies the method's limitations.

References (28)