@article{M4CF62AAD, title = "SEG-SQL: Structure-aware Example Generation for Text-to-SQL Method with In-context Learning", journal = "Journal of KIISE, JOK", year = "2025", issn = "2383-630X", doi = "10.5626/JOK.2025.52.11.992", author = "Donguk Kwon, Jaewan Moon, Jongwook Lee", keywords = "Text-to-SQL, large language model, in-context learning, few-shot example generation, hint vector, SQL-to-Text", abstract = "Large language models (LLMs) that utilize in-context learning have significantly improved Text-to-SQL performance. However, traditional natural language similarity-based example selection often fails to ensure SQL structural similarity and can degrade performance when no structurally similar examples exist for a target SQL query. To address this issue, we propose SEG-SQL (Structure-aware Example Generation for Text-to-SQL). SEG-SQL first generates an initial SQL query from a given natural language question and converts it into a hint vector that captures its structural characteristics. It then modifies specific bits of this hint vector to create structurally similar SQL queries, which are subsequently transformed back into natural language through SQL-to-Text conversion. These transformed queries are used as few-shot examples for in-context learning. On the BIRD benchmark, SEG-SQL improved execution accuracy by 2.5% compared to CHESS and by 3.4% compared to OpenSearch-SQL. Under the most challenging difficulty setting, these gains increased to 30.0% and 62.2%, respectively. These results show that SEG-SQL consistently enhances the accuracy of in-context learning-based Text-to-SQL methods, even in complex environments." }