Compositional Online Learning for Semantic Data Processing Systems
Organizations: Snowflake Inc.
Abstract
An LLM call in a semantic data processing system is expensive enough to dominate query cost, yet slow enough to hide a CPU-side learner's update behind its round-trip. In production, LLM compute accounts for of query cost, and each call costs a relational predicate. The latency window inverts a design constraint of classical adaptive query processing, where online learners had to stay lightweight to avoid dominating the predicates they optimize. At LLM latency, per-call gradient steps and per-batch threshold solves fit inside the round-trip. We develop compositional online learning at the LLM call boundary: a framework for combining online-learning components in semantic data processing systems. Each component makes execution-time decisions and refines its learned artifacts online. The design space spans two axes, decision granularity and learner update cadence, and the components share a single learning pattern that hides each trainer step inside the next LLM round-trip. A production case study in Cortex AISQL composes three components: a memoization layer, an online per-call filter-ordering learner, and an online per-batch cascade-routing learner. A conditional cost decomposition assigns each learning component to a distinct factor of per-row LLM cost. Under independence, the two learning components compose multiplicatively to an upper bound on a representative conjunction-filter workload. Self-selection at the cascade boundary, sample-budget shrinkage, and selectivity-estimation drift reduce it to a realistic figure near .
Figures & tables
| Layer | Decision granularity | Learner update cadence | Artifact / state | Instance |
| Response caching | per-call | none (memoization) | exact-match response cache | AISQL response cache (§ 2.3 ) |
| Filter ordering | per-call | online per-call | selectivity model + DP solver | Larch (§ 4 ) |
| Cascade routing | per-row | online per-batch | calibrated GAM probability map | GAMCAL (§ 5 ) |
| Prompt caching | per-call | none (memoization) | prefix cache + affinity map | future direction (§ 8.1 ) |
| Model substitution | per-batch | one-shot at compile time | distilled student net | future direction (§ 8.1 ) |
| Prompt structure | per-call | online per-batch | prompt template / rewriting rules | future direction (§ 8.1 ) |
| Dataset | PZ | Quest | Larch-Sel |
|---|---|---|---|
| GovReport | 21.3% | 33.6% | 5.1% |
| PubMed | 26.1% | 29.5% | 6.5% |
| BigPatent | 28.3% | 29.7% | 3.6% |
| Dataset | SUPG-SP (LOTUS) | SUPG-IT | GAMCAL |
|---|---|---|---|
| ArXiv | 55.6% | 61.9% | 61.6% |
| BoolQ | 69.7% | 58.2% | 29.3% |
| IMDB | 69.9% | 69.1% | 68.4% |
| MMLU | 67.4% | 62.9% | 43.9% |
| NYT | 21.9% | 22.4% | 17.0% |
| SST-2 | 28.6% | 31.6% | 21.2% |
| Configuration | Cost (rel.) | ||
|---|---|---|---|
| Baseline (no optimization) | 5.0 | 1.0 | 1.00 |
| + Filter ordering alone | 1.0 | ||
| + Cascade routing alone | 5.0 | ||
| Both learning components (upper bound) | ( ) |
LLM Routing
Large language model routing selects models, tools, experts, or inference strategies to balance answer quality, cost, latency, and deployment constraints.
See all 355 papersAccess Paths for Efficient Ordering with Large Language Models
LLM ORDER BY semantic operator as a logical abstraction and conduct a systematic study of its physical implementations. First, we propose several improvements to existing semantic sorting algorithms and introduce a semantic-aware external merge sort algorithm. Our extensive evaluation reveals that no single implementation offers universal optimality on all datasets. From our evaluations, we observe a general scaling relationship between sorting cost and the ordering quality for comparison-based algorithms. Building on these insights, we design a budget-aware optimizer that utilizes heuristic rules, LLM-as-Judge evaluation, and consensus aggregation to dynamically select the near-optimal access path for LLM ORDER BY. In our extensive evaluations, our optimizer consistently achieves ranking accuracy on par with or superior to the best static methods across all benchmarks. We believe that this work provides foundational insights into the principled optimization of semantic operators essential for building robust, large-scale LLM-powered analytic systems.