Many modern AI workflows -- ranging from LLM post-training pipelines to agentic reasoning tasks -- can be expressed as declarative queries whose expensive predicate is evaluated by a large model or reward function. We propose a query-centric formulation of these workflows and show that classical database techniques, namely approximate query processing (AQP) and proxy-model (PM) based filtering, can substantially reduce the number of expensive model invocations without changing the database, model and pipeline through exposing the invocations that could be avoided with preserving aggregate or selected-output quality. AQP treats the workflow as an online aggregation problem: it progressively samples records, maintains a running aggregate estimate with an approximate confidence interval and an empirical stopping rule based on interval narrowing and stabilization. PM trains a lightweight, CPU-resident decision tree on a small set of oracle-labeled examples and uses it to pre-filter records using structural features, with oracle confirmation and sampled correction for aggregate queries and candidate selection. We also propose a unified plan on a shared label cache where they yield the AQP estimate and train the proxy to select the best strategy at negligible CPU overhead. We evaluate on TPC-DS aggregate queries and real LLM post-training pipelines including math reasoning, general instruction following, and code generation. On TPC-DS, AQP keeps aggregate error under 10% using about 10% to 15% of oracle calls in the balanced-distribution experiments, and PM reduces oracle calls by 60-70% on several natural-label workloads, with only challenges faced on small-table cases. On LLM pipelines, fixed-budget sampling provides a cost-quality reference, and PM uses up to 19 times fewer RM calls than full scoring with similar accuracies like 91.16% vs 92.95% on LLaMA-3.1-8B Math.
翻译:暂无翻译