Please wait a minute...
浙江大学学报(工学版)  2026, Vol. 60 Issue (8): 1792-1800    DOI: 10.3785/j.issn.1008-973X.2026.08.018
计算机技术     
大模型驱动的空间数据自然语言查询语料库构建方法
易炜佳(),刘孟怡,许建秋*()
南京航空航天大学 计算机科学与技术学院,江苏 南京 211106
LLM-driven construction of spatial natural language query corpora
Weijia YI(),Mengyi LIU,Jianqiu XU*()
College of Computer Science and Technology, Nanjing University of Aeronautics and Astronautics, Nanjing 211106, China
 全文: PDF(1290 KB)   HTML
摘要:

传统自然语言转结构化查询语言(NL2SQL)模型在空间数据库中面临实体匹配和查询类型识别困难的挑战. 现有语料库覆盖面窄、查询类型单一,难以有效建模空间关系和地理特征,导致训练效果和泛化能力不足. 为此,提出大语言模型驱动的语料库构建方法. 在语料验证方面,设计实现包含错误检测与修复的验证工具,结合LSTM网络与自然语言处理工具定制实体关系抽取算法,对预处理后的查询语句进行建模与校正,提高语义识别与语法纠错的能力. 在语料生成方面,基于查询类型规则驱动机制,结合大语言模型生成、人工采集和模板合成方法,设计支持多数据库、多类型查询的语料生成工具. 实验基于真实空间数据库构建的数据集进行. 结果表明,所提方法提升了空间数据库NL2SQL模型的查询转换率和准确率,在生成效率与语料多样性方面优于GPT-4o、DeepSeek和Gemini 2.0等方法.

关键词: 空间数据库自然语言查询语料库自然语言转结构化查询语言(NL2SQL)大语言模型(LLM)语料生成实体关系抽取    
Abstract:

Traditional natural language to structured query language (NL2SQL) models face significant challenges in spatial databases, especially in entity matching and query type recognition. The narrow coverage of existing corpora and the limited diversity of query types restrict the ability to effectively model spatial relations and geographic features, leading to insufficient training performance and weak generalization. To address these limitations, a large language model (LLM)-driven corpus construction strategy was proposed, focusing on corpus verification and corpus generation. In the verification stage, an error detection and repair tool was developed, in which LSTM networks were combined with customized entity and relation extraction algorithms built on natural language processing techniques. Preprocessed queries were modeled and corrected by the tool, thereby enhancing semantic recognition and grammatical correction. In the generation stage, a query-type-oriented, rule-driven mechanism was introduced, integrating LLM-based generation, manual collection, and template synthesis to develop a corpus generation tool supporting multiple databases and diverse query categories. Experiments were conducted on datasets derived from real spatial databases, and the results demonstrated that the query conversion rates and accuracy of NL2SQL models in spatial contexts were improved by the proposed strategy. Furthermore, higher generation efficiency and greater corpus diversity were achieved by this approach compared with GPT 4o, DeepSeek, and Gemini 2.0.

Key words: spatial database    natural language query corpus    natural language to structured query language (NL2SQL)    large language model (LLM)    corpus generation    entity-relationship extraction
收稿日期: 2025-07-31 出版日期: 2026-07-16
CLC:  TP 391  
基金资助: 国家自然科学基金资助项目(62472217, U23A20296).
通讯作者: 许建秋     E-mail: wjyi_x@nuaa.edu.cn;jianqiu@nuaa.edu.cn
作者简介: 易炜佳(2001—),女,硕士生,从事语料库构建研究. orcid.org/0009-0002-0494-8678. E-mail:wjyi_x@nuaa.edu.cn
服务  
把本文推荐给朋友
加入引用管理器
E-mail Alert
作者相关文章  
易炜佳
刘孟怡
许建秋

引用本文:

易炜佳,刘孟怡,许建秋. 大模型驱动的空间数据自然语言查询语料库构建方法[J]. 浙江大学学报(工学版), 2026, 60(8): 1792-1800.

Weijia YI,Mengyi LIU,Jianqiu XU. LLM-driven construction of spatial natural language query corpora. Journal of ZheJiang University (Engineering Science), 2026, 60(8): 1792-1800.

链接本文:

https://www.zjujournals.com/eng/CN/10.3785/j.issn.1008-973X.2026.08.018        https://www.zjujournals.com/eng/CN/Y2026/V60/I8/1792

查询类型查询示例
范围查询RQTell me which railway are on Software Avenue.
最近邻查询NNList the 1 closest kindergarten near Jiqing Road.
空间连接查询SJFind the bank that are located in Gulou District.
距离连接查询DJIdentify the hospital within 5 kilometers of each amusement.
距离查询DisHow many feet from Yadong City to Waterside Sunny Garden.
方位查询DirHow do I plan the route from McDonald's to 1-10 Contact Line.
长度查询LQPlease advise me on the length of Xinhu Avenue in highway.
面积查询AQWhat is the area of the Palace of Xindi Hotel situated in hotel.
计数查询ACHow many railway goes through the Gulou park.
和查询ASCan you provide the aggregate land area of all pool in Daijiatang.
最大值查询AMWhich highway has the most intersection points compared to others.
表 1  空间数据库自然语言查询类型
图 1  语料库构建框架图
模型TP/%Acc/%
NALSpatial72.064.7
CDR+NALSpatial90.578.9
SpatialNLI64.154.3
CDR+SpatialNLI80.767.5
表 2  语料修复模块的性能对比
图 2  不同模型在语料错误修复中的准确率对比
模型生成效率(条·s?1)TD↑QV/%
GPT-4o293.20.6993.4
DeepSeek9.80.8190.7
Gemini 2.018.30.7591.0
CG1424.50.8795.2
表 3  不同语言模型的生成语料情况对比
方法QV/%TD↑SS/%QESR/%人工成本
仅LLM生成91.70.7582.778.8
LLM生成+人工清洗93.10.7388.583.1
LLM生成+CDR修复94.00.7191.188.3
CG生成95.20.8790.086.4
表 4  模块消融实验结果
1 GÜTING R H, BÖHLEN M H, ERWIG M, et al A foundation for representing and querying moving objects[J]. ACM Transactions on Database Systems, 2000, 25 (1): 1- 42
doi: 10.1145/352958.352963
2 KATSOGIANNIS-MEIMARAKIS G, KOUTRIKA G. A deep dive into deep learning approaches for text-to-SQL systems [C]// Proceedings of the 2021 International Conference on Management of Data. [S.l.]: ACM, 2021: 2846–2851.
3 LIU M, WANG X, XU J, et al NALSpatial: a natural language interface for spatial databases[J]. IEEE Transactions on Knowledge and Data Engineering, 2025, 37 (4): 2056- 2070
doi: 10.1109/TKDE.2025.3525587
4 LI J, WANG W, KU W S, et al. SpatialNLI: a spatial domain natural language interface to databases using spatial comprehension [C]// Proceedings of the 27th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems. Chicago: ACM, 2019: 339–348.
5 TROY C, STURLEY S, ALCARAZ-CALERO J M, et al Enabling generative AI to produce SQL statements: a framework for the auto-generation of knowledge based on EBNF context-free grammars[J]. IEEE Access, 2023, 11: 123543- 123564
doi: 10.1109/ACCESS.2023.3329071
6 DING N, MELLONI L, TIAN X, et al Rule-based and word-level statistics-based processing of language: insights from neuroscience[J]. Language, Cognition and Neuroscience, 2017, 32 (5): 570- 575
doi: 10.1080/23273798.2016.1215477
7 LI H, ZHANG J, LI C, et al RESDSQL: decoupling schema linking and skeleton parsing for text-to-SQL[J]. Proceedings of the AAAI Conference on Artificial Intelligence, 2023, 37 (11): 13067- 13075
8 WANG B, SHIN R, LIU X, et al. RAT-SQL: relation-aware schema encoding and linking for text-to-SQL parsers [EB/OL]. (2021–08–24)[2025–05–29]. https://arxiv.org/pdf/1911.04942.
9 GUO J, ZHAN Z, GAO Y, et al. Towards complex text-to-SQL in cross-domain database with intermediate representation [EB/OL]. (2019–05–29)[2025–05–29]. https://arxiv.org/pdf/1905.08205.
10 ZELLE J M, MOONEY R J. Learning to parse database queries using inductive logic programming [C]// Proceedings of the AAAI. [S.l.]: AAAI, 1996: 1050–1055.
11 CHANG S, PALZER D, LI J, et al. MapQA: a dataset for question answering on choropleth maps [EB/OL]. (2022–11–15)[2025–05–29]. https://arxiv.org/pdf/2211.08545.
12 YU T, ZHANG R, YANG K, et al. Spider: a large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-SQL task [C]// Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing. Brussels: Association for Computational Linguistics, 2018: 3911–3921.
13 ZHONG V, XIONG C, SOCHER R. Seq2SQL: generating structured queries from natural language using reinforcement learning [EB/OL]. (2017–08–31)[2025–05–29]. https://arxiv.org/pdf/1709.00103.
14 杨锦锋, 关毅, 何彬, 等 中文电子病历命名实体和实体关系语料库构建[J]. 软件学报, 2016, 27 (11): 2725- 2746
YANG Jinfeng, GUAN Yi, HE Bin, et al Corpus construction for named entities and entity relations on Chinese electronic medical records[J]. Journal of Software, 2016, 27 (11): 2725- 2746
doi: 10.13328/j.cnki.jos.004880
15 SNOW R, O’CONNOR B, JURAFSKY D, et al. Cheap and fast – but is it good? Evaluating non-expert annotations for natural language tasks [C]// Proceedings of the 2008 Conference on Empirical Methods in Natural Language Processing. Honolulu: Associaton for Computational Linguistics, 2008: 254–263.
16 费浩, 纪荣嵘, 任亚锋 基于动态句法剪枝机制的中文语义角色标注[J]. 计算机学报, 2022, 45 (8): 1746- 1764
FEI Hao, JI Rongrong, REN Yafeng Chinese semantic role labeling based on dynamic syntactic pruning[J]. Chinese Journal of Computers, 2022, 45 (8): 1746- 1764
doi: 10.11897/SP.J.1016.2022.01746
17 KENNEDY G. An introduction to corpus linguistics [M]. London: Routledge, 1998.
18 LONG L, WANG R, XIAO R, et al. On LLMs-driven synthetic data generation, curation, and evaluation: a survey [C]// Proceedings of the Findings of the Association for Computational Linguistics. Bangkok: Association for Computational Linguistics, 2024: 11065–11082.
[1] 魏蕴田,金苍宏,费峥东,郑铜亚,王晓亮,宋明黎. 大小模型协同优化的兴趣点轨迹预测框架[J]. 浙江大学学报(工学版), 2026, 60(6): 1251-1260.
[2] 黄孝喜,查正超,陆诗佳. 基于大语言模型的中文隐喻多维度评估[J]. 浙江大学学报(工学版), 2026, 60(2): 388-395.
[3] 蔡华林,陈刚,陈珂. 多类别复合资源的空间匹配[J]. 浙江大学学报(工学版), 2015, 49(1): 69-78.