Introduction
Building "Compound AI Systems"—applications that chain together multiple LLMs, data retrieval steps, and processing logic—is currently a manual and brittle process. Engineers must hand-pick models (e.g., GPT-4 vs. a local Llama-3), craft specific prompts, and decide the order of operations. This approach suffers from a significant "performance gap," as AI components are orders of magnitude slower and more expensive than traditional database operations. Furthermore, the rapid flux of the AI landscape makes manual optimizations quickly obsolete.
PALIMPZEST addresses these challenges by bringing the "query optimizer" philosophy of relational databases to LLM-powered analytics. By allowing developers to write high-level, declarative code, the system automatically navigates the complex trade-offs between financial cost, execution time, and output quality to find the most efficient execution plan.
System Architecture and Methods
PALIMPZEST introduces a declarative Python library where users define Semantic Analytics Applications (SAPPs) using a relational algebra. Instead of executing code exactly as written, the system generates a search space of many possible "physical plans."
The core innovations include:
- The
convertOperator: A novel relational operator that transforms data from one schema to another using foundation models. - Sentinel Plans & Profiling: To estimate performance, the system runs "sentinel plans" on a small sample (typically 5%) of the data. It uses a "champion model" (the most accurate model available, like GPT-4) as a proxy for ground truth to estimate the quality of cheaper models.
- Physical Optimizations: The system automatically applies techniques such as model selection, code synthesis (replacing LLMs with regex), token reduction, and filter pushdown (e.g., moving cheap text filters before expensive image processing).
Evaluation and Key Results
The system was evaluated using a Real Estate Search workload involving 100 listings with natural language descriptions and images. The task was to find "modern and attractive" homes within specific geographic and price constraints.
PALIMPZEST treats Quality (F1-score), Cost ($), and Time (seconds) as a three-dimensional optimization problem. One of the most significant gains came from logical reordering: checking price (text-based) before checking if a house looks "modern" (image-based) saved massive amounts of money by avoiding unnecessary vision model calls.
In head-to-head tests against a baseline that naively used GPT-4 for everything, PALIMPZEST demonstrated:
- Efficiency: Produced plans that were up to 3.3x faster and 2.9x cheaper.
- Quality: Optimized plans often achieved superior F1-scores (up to 1.1x better) because the optimizer could detect and avoid plans prone to formatting errors.
- Policy Adherence: The system successfully honored user policies, such as "Minimize cost while ensuring an F1-score > 0.8."
- Low Overhead: The optimization process took only about 13 seconds, a negligible cost compared to the savings on large datasets.
Limitations and Future Work
The current prototype uses a record-at-a-time iterator model, which may limit throughput compared to batch-processing. Additionally, quality estimation depends on the accuracy of the "champion" model. Future work will explore more complex optimizations like join re-ordering and sophisticated "micro-RAG" techniques for token reduction.
Summary updated