GPT-Based Text-to-SQL for Spatial Databases

Text-to-SQL for spatial databases enables the translation of natural language questions into corresponding SQL queries, allowing non-experts to easily access spatial data, which has gained increasing attention from researchers. Previous research has primarily focused on rule-based methods. However,...

Full description

Saved in:
Bibliographic Details
Published inISPRS international journal of geo-information Vol. 14; no. 8; p. 288
Main Authors Wang, Hui, Guo, Li, Liang, Yubin, Liu, Le, Huang, Jiajin
Format Journal Article
LanguageEnglish
Published Basel MDPI AG 24.07.2025
Subjects
Online AccessGet full text
ISSN2220-9964
2220-9964
DOI10.3390/ijgi14080288

Cover

More Information
Summary:Text-to-SQL for spatial databases enables the translation of natural language questions into corresponding SQL queries, allowing non-experts to easily access spatial data, which has gained increasing attention from researchers. Previous research has primarily focused on rule-based methods. However, these methods have limitations when dealing with complicated or unknown natural language questions. While advanced machine learning models can be trained, they typically require large labeled training datasets, which are severely lacking for spatial databases. Recently, Generative Pre-Trained Transformer (GPT) models have emerged as a promising paradigm for Text-to-SQL tasks in relational databases, driven by carefully designed prompts. In response to the severe lack of datasets for spatial databases, we have created a publicly available dataset that supports both English and Chinese. Furthermore, we propose a GPT-based method to construct prompts for spatial databases, which incorporates geographic and spatial database knowledge into the prompts and requires only a small number of training samples, such as 1, 3, or 5 examples. Extensive experiments demonstrate that incorporating geographic and spatial database knowledge into prompts improves the accuracy of Text-to-SQL tasks for spatial databases. Our proposed method can help non-experts access spatial databases more easily and conveniently.
Bibliography:ObjectType-Article-1
SourceType-Scholarly Journals-1
ObjectType-Feature-2
content type line 14
ISSN:2220-9964
2220-9964
DOI:10.3390/ijgi14080288