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

SEMA-SQL:超越传统关系查询的大型语言模型

SEMA-SQL: Beyond Traditional Relational Querying with Large Language Models

Alibaba Group(阿里巴巴集团);University of Michigan(密歇根大学)

Yin Lin, Tianjing Zeng, Zhongjun Ding, Rong Zhu, Bolin Ding, H. V. Jagadish, Jingren Zhou

AI总结:

SEMA-SQL通过结合关系操作与LLM语义推理,自动回答自然语言问题,提升查询能力。

摘要:

关系数据库在结构化数据分析中表现优异,但现实中的查询需求超出标准SQL,如跨不一致名称的语义匹配、提取非显式存储的信息以及分析非结构化文本。尽管文本到SQL系统支持自然语言查询,但受限于关系操作,无法利用现代大语言模型的语义推理能力。相反,最近的语义操作系统通过LLM扩展关系代数(如语义连接、映射、聚合),但需要用户手动构建复杂查询管道。为解决这一差距,我们提出了SEMA-SQL系统,能够通过生成高效的查询结合关系操作与LLM语义推理。我们正式化了混合关系代数(HRA),一种将传统关系运算符与LLM用户定义函数(UDFs)统一的声明性抽象。系统自动化了三个关键方面:(1)通过上下文学习生成HRA查询,以产生精确的自然语言规范用于LLM UDFs;(2)通过基于成本的转换和UDF重写进行查询优化;(3)高效的执行算法,通过智能分组将语义连接中的LLM调用减少93%。通过广泛实验与扩展基准测试,证明了我们的设计在查询能力方面的显著改进。

英文摘要:

Relational databases excel at structured data analysis, but real-world queries increasingly require capabilities beyond standard SQL, such as semantically matching entities across inconsistent names, extracting information not explicitly stored in schemas, and analyzing unstructured text. While text-to-SQL systems enable natural language querying, they remain limited to relational operations and cannot leverage the semantic reasoning capabilities of modern large language models (LLMs). Conversely, recent semantic operator systems extend relational algebra with LLM-powered operations (e.g., semantic joins, mappings, aggregations), but require users to manually construct complex query pipelines. To address this gap, we present SEMA-SQL, a system that automatically answers natural language questions by generating efficient queries that combine relational operations with LLM semantic reasoning. We formalize Hybrid Relational Algebra (HRA), a declarative abstraction unifying traditional relational operators with LLM user-defined functions (UDFs). The system automates three critical aspects: (1) query generation via in-context learning that produces HRA queries with precise natural language specifications for LLM UDFs, (2) query optimization via cost-based transformations and UDF rewriting, and (3) efficient execution algorithms that reduce LLM invocations by an average of 93% in semantic joins through intelligent batching. Extensive experiments with known benchmarks, and extensions thereof, demonstrate the significant query capability improvements possible with our design.

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

↑