TY - JOUR T1 - SEG-SQL: Structure-aware Example Generation for Text-to-SQL Method with In-context Learning AU - Kwon, Donguk AU - Moon, Jaewan AU - Lee, Jongwook JO - Journal of KIISE, JOK PY - 2025 DA - 2025/1/14 DO - 10.5626/JOK.2025.52.11.992 KW - Text-to-SQL KW - large language model KW - in-context learning KW - few-shot example generation KW - hint vector KW - SQL-to-Text AB - 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.