Enhanced Text-to-SQL Generation via Query Classification
Ruohan Gao, Jiapeng Guo, Hang Zhao, Jiaquan Diao, Qingyu Lu, Qu Peng · Frontiers in artificial intelligence and applications · 2025
With the popularization of big data technologies, the demand for non-technical personnel to directly manipulate databases through natural language is growing. However, existing text-to-SQL methods still suffer from insufficient accuracy and efficiency when dealing with multi-table complex queries, especially on large-scale cross-domain datasets. This paper proposes a text-to-SQL method that integrates query classification, query intermediate representation and dynamic example selection. The method links natural language entities to database structures through a schema linking module, designs a query classification module to distinguish between simple and complex queries, and provides corresponding hint templates for different categories of queries. For multi-table complex queries, which often suffer from connection errors, the method introduces query intermediate representation and a dynamic example strategy to address these issues. Experiments on the Spider and BIRD datasets show that the method improves execution accuracy and efficiency scores, achieving better results.