DKASQL: Dynamic Knowledge Adaptation for Domain-Specific Text-to-SQL
Text2SQL aims to translate natural language queries into structured query language (SQL). LLM-based Text2SQL methods have gradually become mainstream because of their strong capabilities in language understanding and transformation. However, in real-world scenarios with non-public or limited data resources, these methods still face challenges such as insufficient domain knowledge, SQL generation that violates domain-specific constraints, and even hallucination issues. To address these challenges, this paper proposes DKASQL, a domain-specific Text2SQL method based on dynamic knowledge adaptation. The approach features an extraction module, a generation module, and an LLM-based verification module. Through an iterative “extraction–verification” and “generation–verification” mechanism, it dynamically updates the required knowledge, effectively improving both domain knowledge acquisition and the alignment between generated SQL and domain knowledge. To enhance efficiency, DKASQL also incorporates a memory storage mechanism that automatically retains commonly used domain knowledge to reduce iteration overhead. Experiments on the open-source multi-domain dataset BIRD and the ElecSQL dataset collected from the power-grid supply-chain domain show that DKASQL achieves significant performance improvements. With 7B and 32B base models, DKASQL achieves performance comparable to much larger models such as GPT-4o mini and DeepSeek-V3, with less computational overhead. For instance, on ElecSQL, DKASQL improves the execution success rate (ESR) by up to +26.9% and the result accuracy (RA) by up to +8.8% over GPT-4o mini, highlighting its effectiveness in domain-specific Text2SQL tasks.
Authors
- Huaxing Bian
- G. L. Li (ORCID: https://orcid.org/0009-0002-8840-5792)
- Zhen Wu (ORCID: https://orcid.org/0000-0002-7678-103X)
- Jian Shen (ORCID: https://orcid.org/0000-0001-6099-3209)
- Yifan Wang (ORCID: https://orcid.org/0000-0003-2797-609X)
- Qinghan Fu
- Xixian Yao
Institutions
- Shanghai Electric (China) (CN)
- Nanjing University (CN)
Publication Details
- Journal
- Applied Sciences
- Published
- 2025-10-16
- DOI
- https://doi.org/10.3390/app152011121
- Primary Topic
- Semantic Web and Ontologies
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- Science and Technology Project of State Grid
- State Grid Jiangsu Electric Power