TL;DR
Compound AI systems—which string together multiple LLM calls to solve complex tasks—are incredibly powerful but prohibitively expensive when using flagship models for every step. This paper introduces SCOPE, an optimization algorithm that automatically selects the most cost-effective LLM for each module in a system without sacrificing quality. By evaluating configurations at a granular, query-by-query level and using statistical confidence bounds, SCOPE cuts optimization search costs by up to 20× and slashes final operational costs by up to 6× compared to state-of-the-art baselines.
What Problem Does This Paper Address?
Modern AI engineering has shifted from training single massive models to building compound AI systems—pipelines, agents, and graphs that link multiple LLM modules together to tackle multi-step tasks like data cleaning or complex question answering.
To guarantee high-quality outputs, developers typically default to using the most powerful (and expensive) model available, like GPT-5, across all modules. However, when processing large-scale enterprise datasets with millions of rows, this brute-force approach leads to astronomical API bills.
The ideal solution is constrained LLM selection: finding a mix of cheap and expensive models tailored to the difficulty of each specific module, minimizing total cost while guaranteeing that the system's average quality stays above a user-defined threshold.
The catch? Optimizing this is incredibly hard. LLM outputs are stochastic (noisy), the search space of model combinations is massive, and traditional black-box optimization methods (like Bayesian Optimization) require evaluating a configuration on the entire dataset just to get a single sample point. Doing this repeatedly can cost more than the actual savings the optimization is trying to achieve.
Methods
The authors propose SCOPE (Sequential Confidence-bound-based Optimization via Partial Evaluation), which introduces two key innovations to make model selection practical:
- Query-Level Evaluation Granularity: Instead of running a candidate model configuration over an entire dataset, SCOPE evaluates it query-by-query. If a configuration starts failing or proving too costly on the first few queries, SCOPE utilizes a pruning mechanism to drop it immediately, saving the remaining budget.
- Statistical Confidence Bounds via Gaussian Processes: SCOPE maintains mathematically rigorous upper and lower confidence bounds for both cost and quality. These bounds are updated continuously after every single query execution.
The algorithm operates in three main phases:
- Bound Calibration: A hybrid initialization phase (
Calibrate) that tests a diverse pool of configurations on a tiny subset of queries, iteratively doubling the query size while discarding the worst-performing half of the configurations to establish a baseline. - Candidate Selection: In each iteration, SCOPE greedily selects a candidate configuration that minimizes the lower bound of cost while statistically satisfying a dynamic quality constraint.
- Sequential Query Evaluation & Early Pruning: The candidate is evaluated on queries ordered by their uncertainty. If the configuration is statistically proven to be infeasible or worse than the current best solution, evaluation stops early.
Datasets
The authors evaluated SCOPE across three distinct data management and analytics tasks using state-of-the-art compound AI frameworks, alongside a scalability benchmark:
- Text-to-SQL: Using the DIN-SQL framework on the BIRD-mini-dev dataset (500 queries) for evaluation and BIRD-dev (1,534 queries) for test-time deployment.
- Data Transformation: Using UniDM-DT on Bing-QueryLogs (102 queries) for evaluation and StackOverflow (710 queries) for testing.
- Data Imputation: Using UniDM-DI on Restaurant-dev (156 queries) for evaluation and Restaurant-test (86 queries) for testing.
- Entity Resolution (Scalability Benchmark): Using UniDM-ER on the Amazon-google-dev dataset containing 2,293 queries.
The candidate pool consisted of 23 distinct LLMs from OpenAI, Google, Anthropic, and DeepSeek, creating search spaces ranging from tens of thousands to millions of possible configurations.
Key Insights and Ideas
- Query-Level Signals are a Goldmine: You don't need to run a model combination on 500 rows of data to realize it's hallucinating or too expensive; you can usually tell within the first 10 to 40 queries. Exploiting this fine-grained signal is what drives SCOPE's massive efficiency.
- The "Quality Cushion" Generates Robustness: Because SCOPE accounts for noise and requires high-probability certification of feasibility, it naturally selects configurations that clear the quality threshold with a safety margin. Surprisingly, this margin allows SCOPE to generalize incredibly well to unseen test datasets, even outperforming the all-flagship reference configuration under dataset shifts.
- Zero Structural Assumptions: Unlike previous methods that assume upgrading a model always improves quality (monotonicity) or that modules don't interact (independence), SCOPE treats the system as a true black box, making it highly robust to real-world pipeline complexities.
Key Results
SCOPE was tested against 7 baselines, including generic optimization methods (cEI, CONFIG, SafeOpt) and compound-AI-specific approaches (LLAMBO, Abacus, LLMSelector).
As illustrated in Figure 1:
- Cost-Efficiency During Search: Under identical search budgets, SCOPE found valid configurations with up to 20× lower cost during the optimization process than its closest competitor.
- Lower Final Operational Cost: The final configurations returned by SCOPE achieved up to 6× lower cost than those found by other baselines.
- Strict Constraint Satisfaction: SCOPE maintained zero constraint violations ($V(\Lambda) = 0$) across all tasks and budgets, whereas alternative methods frequently returned configurations that failed to meet the user's quality threshold.
- Exceptional Generalization: On held-out test sets, SCOPE slashed costs to just 2–5% of the all-GPT-5.2 reference configuration while actually improving average quality by 5% to 21%.
Limitations and Future Work
While SCOPE represents a major leap forward, the authors note a few areas for improvement:
- Algorithmic Computational Overhead: Because SCOPE updates Gaussian Process surrogates at a query-by-query level, its internal computational complexity scales cubically with the number of observations ($\mathcal{O}(Q \cdot |\Theta| \cdot \tau^3)$). While this is heavily outweighed by the savings in LLM API costs, accelerating the internal GP math remains an open engineering challenge.
- Single Constraint Focus: The current formulation optimizes for a single cost metric under a single quality constraint. Real-world enterprise systems often require balancing multi-objective trade-offs, such as optimizing for latency, cost, and multiple distinct quality dimensions simultaneously. The authors plan to extend SCOPE to multi-objective optimization in future work.
Summary updated