Abstract
As we enter the era of "semantic" data, users increasingly need to perform complex analytics across multi-modal datasets containing text, images, and structured fields. Traditional relational databases lack the flexibility to process unstructured content, while naive Large Language Model (LLM) prompting is constrained by context window limits and high operational costs. This paper introduces Nirvana, a framework that brings database-style query optimization to LLM-powered multi-modal analytics. By employing an agentic logical optimizer and a cost-aware physical optimizer, Nirvana reduces processing costs by 76% and runtimes by up to 85% without sacrificing accuracy.
Introduction
Modern data analytics often involves queries that require a deep understanding of content, such as identifying "movies with a dark aesthetic" or "estates with a yard" from collections of images and descriptions. Relational databases (SQL) are ill-equipped for these tasks. Conversely, attempting to process entire tables through an LLM like GPT-4o quickly exceeds context limits and becomes prohibitively expensive as the dataset grows.
Nirvana addresses these challenges by treating LLM-based analytics as a query optimization problem. It interprets natural language questions and translates them into a structured execution plan, bridging the gap between expensive AI reasoning and efficient classical computing.
The Nirvana Framework
Nirvana decomposes natural language queries into a directed acyclic graph (DAG) of semantic operators, including map, filter, reduce, and rank. This structured approach allows the system to apply sophisticated optimization techniques similar to those found in traditional database management systems.
Optimization Layers
The system features two primary layers of optimization:
- Agentic Logical Optimizer: An LLM-based agent explores various query structures. It applies transformation rules such as Operator Fusion (merging filters) and Non-LLM Replacement. In the latter, the optimizer identifies when a semantic filter (e.g., "rating > 8.5") can be converted into a standard Python function (UDF), replacing expensive LLM calls with nearly-free code execution.
- Cost-Aware Physical Optimizer: Nirvana selects the most cost-effective LLM backend (e.g., GPT-4o-mini vs. GPT-4o) for each operator. It uses an improvement-score metric and techniques like Evaluation Pushdown and Computation Reuse to minimize expensive model invocations, only using high-tier models on data samples where cheaper models show high uncertainty.
Experimental Evaluation
The researchers evaluated Nirvana using three real-world multi-modal benchmarks: Movie (text + images), Estate (long-form descriptions + images), and Game (18,891 records including PEGI rating images).
Key Results
- Efficiency: Nirvana achieved end-to-end runtime reductions of 10% to 85% and decreased monetary costs by an average of 76% compared to state-of-the-art systems like Palimpzest and Lotus.
- Scalability: Unlike direct prompting, Nirvana successfully scaled to process the 18,000+ record Game dataset.
- Semantic-to-Relational Bridge: The most significant gains were observed when the system successfully offloaded semantic tasks to traditional computational functions through UDF generation.
Conclusion and Future Work
Nirvana demonstrates that LLMs are highly effective as query rewriters and optimizers, even when they are too expensive to use as primary executors for large-scale data. While the system significantly improves efficiency, future work is needed to address privacy concerns regarding third-party APIs and to improve "semantic cardinality estimation"—the ability to predict how many rows a semantic filter will return. By integrating AI reasoning with classical optimization, Nirvana provides a scalable path forward for multi-modal data analytics.
Summary updated