Page 158 - 《软件学报》2026年第3期
P. 158

软件学报 ISSN 1000-9825, CODEN RUXUEW                                        E-mail: jos@iscas.ac.cn
                 2026,37(3):1121−1142 [doi: 10.13328/j.cnki.jos.007514] [CSTR: 32375.14.jos.007514]  http://www.jos.org.cn
                 ©中国科学院软件研究所版权所有.                                                          Tel: +86-10-62562563



                                                                                 *
                 基于大语言模型的空间数据库自然语言查询转换方法

                 刘孟怡  1 ,    许建秋  1 ,    童咏昕  2


                 1
                  (南京航空航天大学 计算机科学与技术学院/软件学院, 江苏 南京 211106)
                 2
                  (北京航空航天大学 计算机学院, 北京 100191)
                 通信作者: 许建秋, E-mail: jianqiu@nuaa.edu.cn

                 摘 要: Text2SQL  技术通过减少非专业用户与关系数据库交互的技术障碍, 已发展为数据分析和数据库管理的重
                 要工具. 以  GPT  为代表的大语言模型 (large language model, LLM) 的引入, 进一步提升了        Text2SQL  系统的性能.
                 然而, 由于空间数据涉及复杂的几何关系、多样化的查询类型和对高精度语义理解的需求, 现有的                               Text2SQL  技术
                 难以直接适用于空间数据库领域. 为了解决上述问题, 降低普通用户与空间数据库的交互门槛, 提出了面向空间数
                 据库的自然语言查询 (natural language query, NLQ) 转换方法. 该方法有两个核心阶段: (1) 自然语言理解; (2) 可执
                 行语言生成. 在阶段      (1) 中使用实体信息提取算法提取关键查询实体, 并基于大语言模型构建空间数据查询语料库
                 进而确定查询类型. 在阶段        (2) 中根据查询类型选择结构化语言模型 (structured language model, SLM), 然后将实体
                 映射到结构化语言模型中, 得到最终的空间数据库可执行语言. 在多组真实数据集上的实验结果表明, 该方法可以
                 实现从用户的自然语言查询到空间数据库可执行语言的高效转换.
                 关键词: 空间数据库; 自然语言接口; 数据库自然语言接口; 语义解析; 查询处理
                 中图法分类号: TP311

                 中文引用格式: 刘孟怡, 许建秋, 童咏昕. 基于大语言模型的空间数据库自然语言查询转换方法. 软件学报, 2026, 37(3): 1121–1142.
                 http://www.jos.org.cn/1000-9825/7514.htm
                 英文引用格式: Liu MY, Xu JQ, Tong YX. Natural Language Query Transformation Method for Spatial Databases Based on Large
                 Language Model. Ruan Jian Xue Bao/Journal of Software, 2026, 37(3): 1121–1142 (in Chinese). http://www.jos.org.cn/1000-9825/7514.
                 htm

                 Natural Language Query Transformation Method for Spatial Databases Based on Large
                 Language Model
                                     1
                           1
                 LIU Meng-Yi , XU Jian-Qiu , TONG Yong-Xin 2
                 1
                 (College  of  Computer  Science  and  Technology/College  of  Software,  Nanjing  University  of  Aeronautics  and  Astronautics,  Nanjing  211106,
                  China)
                 2
                 (School of Computer Science and Engineering, Beihang University, Beijing 100191, China)
                 Abstract:  Text2SQL  has  evolved  into  a  significant  tool  for  data  analysis  and  database  management  by  reducing  the  technical  barriers  for
                 non-expert  users  to  interact  with  relational  databases.  The  introduction  of  large  language  model  (LLM),  represented  by  GPT,  further
                 improves  the  performance  of  Text2SQL  systems.  However,  existing  Text2SQL  techniques  are  difficult  to  apply  directly  to  the  spatial
                 database  domain  because  spatial  data  involves  complex  geometric  relationships,  diverse  query  types,  and  the  demand  for  high-precision
                 semantic  understanding.  To  address  these  issues  and  lower  the  threshold  for  interaction  between  non-experts  and  spatial  databases,  a
                 natural language query (NLQ) transformation method for spatial databases is proposed. The method consists of two core phases: (1) natural
                 language  understanding;  (2)  executable  language  generation.  In  phase  (1),  an  entity  information  extraction  algorithm  is  employed  to  extract


                 *    基金项目: 国家自然科学基金  (62472217, U23A20296)
                  本文由“向量数据库及     DB4LLM  技术”专题特约编辑高宏教授、李国良教授、张蓉教授推荐.
                  收稿时间: 2025-05-06; 修改时间: 2025-06-30; 采用时间: 2025-08-20; jos 在线出版时间: 2025-09-02
                  CNKI 网络首发时间: 2026-01-08
   153   154   155   156   157   158   159   160   161   162   163