arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.11622cs.DB
收藏

Sema: 一种高性能的基于大语言模型的语义查询处理系统

Sema: A High-performance System for LLM-based Semantic Query Processing

Beijing Institute of Technology(北京理工大学);Wuhan University(武汉大学);The Chinese University of Hong Kong(香港中文大学);HKUST (Guangzhou)(香港科技大学(广州))

Kangkang Qi, Dongyang Xie, Wenbo Li, Hao Zhang, Yuanyuan Zhu, Jeffrey Xu Yu, Kangfei Zhao

AI总结:

Sema 是一种基于 DuckDB 构建的高性能语义查询引擎,通过 SemaSQL 实现自然语言表达与 SQL 的无缝集成,提升语义查询的性能和结果质量。

摘要:

将大型语言模型(LLMs)整合到数据分析中,已经解锁了对大量结构化和非结构化数据进行推理的强大能力。然而,现有系统通常依赖于 DataFrame 原语,这些原语缺乏现代数据库管理系统(DBMS)的高效执行基础设施,或者依赖于 SQL 用户定义函数(UDFs),这些函数将语义逻辑与查询优化器隔离开来,并给用户带来实现复杂性。LLM 语义操作符也带来了新的挑战,因为 LLM 调用的成本高且非确定性,传统优化规则和成本模型无法用于其优化。为弥合这些差距,我们提出了 Sema,一种基于 DuckDB 构建的高性能语义查询引擎,将 LLM 语义操作符作为第一公民。Sema 引入了 SemaSQL,一种声明性方言,允许用户无缝地将自然语言表达式注入到标准 SQL 子句中,从而实现端到端的优化和执行。在逻辑层面,Sema 的优化器会压缩自然语言表达式并从语义操作符中推导出关系约束。在运行时,Sema 采用自适应查询执行(AQE)来动态重新排列操作符、融合语义操作并应用提示批处理。这种方法旨在寻找在准确性约束下平衡令牌消耗和延迟的帕累托最优执行路径。我们在 20 个语义查询上评估了 Sema,涵盖分类、总结和提取任务。实验结果表明,Sema 在三个基线系统上实现了 2-10 倍的加速,同时实现了具有竞争力的结果质量。

英文摘要:

The integration of Large Language Models (LLMs) into data analytics has unlocked powerful capabilities for reasoning over bulk structured and unstructured data. However, existing systems typically rely on either DataFrame primitives, which lack the efficient execution infrastructure of modern DBMSs, or SQL User-Defined Functions (UDFs), which isolate semantic logic from the query optimizer and burden users with implementation complexities. The LLM-powered semantic operators also bring new challenges due to the high cost and non-deterministic nature of LLM invocation, where conventional optimization rules and cost models are inapplicable for their optimization. To bridge these gaps, we present Sema, a high-performance semantic query engine built on DuckDB that treats LLM-powered semantic operators as first-class citizens. Sema introduces SemaSQL, a declarative dialect that allows users seamlessly inject natural language expressions into standard SQL clauses, enabling end-to-end optimization and execution. At the logical level, the optimizer of Sema compresses natural language expressions and deduces relational constraints from semantic operators. At runtime, Sema employs Adaptive Query Execution (AQE) to dynamically reorder operators, fuse semantic operations, and apply prompt batching. This approach seeks a Pareto-optimal execution path balancing token consumption and latency under accuracy constraints. We evaluate Sema on 20 semantic queries across classification, summarization, and extraction tasks. Experimental results demonstrate that Sema achieves $2-10 \times$ speedup against three baseline systems while achieving competitive result quality.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑