Text-to-SQL은 사용자가 데이터베이스 질의를 자연어로 수행할 수 있도록 하는 핵심 기술로, 최근 대규모 언어 모델(LLM)의 문맥 학습(In-Context Learning) 능력에 의해 비약적인 발전을 이루었다. 그...

http://chineseinput.net/에서 pinyin(병음)방식으로 중국어를 변환할 수 있습니다.
변환된 중국어를 복사하여 사용하시면 됩니다.
https://www.riss.kr/link?id=T17387650
서울 : 성균관대학교 일반대학원, 2026
학위논문(석사) -- 성균관대학교 일반대학원 , 인공지능학과 , 2026. 2
2026
한국어
서울
SEG-SQL : structure-aware example generation for Text-to-SQL method with in-context learning
42 p. : 천연색삽화, 표 ; 30 cm
지도교수: 이종욱
참고문헌: p. 37-39
I804:11040-000000189345
0
상세조회0
다운로드Text-to-SQL은 사용자가 데이터베이스 질의를 자연어로 수행할 수 있도록 하는 핵심 기술로, 최근 대규모 언어 모델(LLM)의 문맥 학습(In-Context Learning) 능력에 의해 비약적인 발전을 이루었다. 그...
Text-to-SQL은 사용자가 데이터베이스 질의를 자연어로 수행할 수 있도록 하는 핵심 기술로, 최근 대규모 언어 모델(LLM)의 문맥 학습(In-Context Learning) 능력에 의해 비약적인 발전을 이루었다. 그러나 기존의 예제 선택 방식은 자연어 질의 간 의미 유사도에만 의존하기 때문에, 실제 SQL 구조적 패턴과 일치하지 않는 예제를 선택하는 문제가 발생한다. 특히 BIRD와 같은 복잡한 스키마를 포함한 고난이도 데이터셋에서는 구조적으로 유사한 예제가 학습 데이터에 존재하지 않아, LLM이 참조할 만한 유효한 Few-shot 예제를 확보하기 어렵다. 이로 인해 복잡한 조인, 중첩 서브쿼리, 집계 연산이 포함된 질의에서 성능이 크게 저하되는 한계가 있다.
이러한 문제를 해결하기 위해 본 연구는 SEG-SQL(Structure-aware Example Generation for Text-to-SQL) 프레임워크를 제안한다. SEG-SQL은 자연어 질의로부터 생성된 초기 SQL을 구조 요약 지표인 힌트 벡터(Hint Vector) 로 변환하고, 일부 비트를 변형(mutation)하여 구조적으로 유사하지만 변형된 형태의 pseudo SQL을 생성한다. 이후 각 SQL을 SQL-to-Text 변환을 통해 대응되는 자연어 질의로 재구성함으로써, 구조적으로 일관되고 표현적으로 다양한 NL-SQL 예제 쌍을 생성한다. 생성된 예제들은 LLM의 Few-shot 프롬프트에 포함되어, 자연어 표현이 아닌 SQL 구조 중심의 문맥 학습을 가능하게 한다.
BIRD 벤치마크에서 수행된 실험 결과, SEG-SQL은 기존 최신 모델인 CHESS 및 OpenSearch-SQL 대비 각각 2.5%, 3.4%의 실행 정확도 향상을 보였다. 특히 구조적으로 유사한 예제가 부족한 Challenging 난이도 구간에서는 각각 30.0%, 62.2%의 성능 향상을 기록하며, 복잡한 질의 환경에서도 일관된 성능을 유지하였다. 또한 힌트 벡터의 비트 수를 확장할수록 실행 정확도가 점진적으로 증가함을 확인하여, SQL 구조 정보의 세밀한 표현이 LLM의 질의 변환 능력에 직접적으로 기여함을 입증하였다.
결과적으로 SEG-SQL은 자연어 유사도 기반 접근이 가진 한계를 넘어, SQL 구조의 형식적 특징을 직접 활용하여 문맥 학습 기반 Text-to-SQL의 정확도와 안정성을 모두 향상시킨다. 본 연구는 LLM이 구조적 정보를 이해하고 활용할 수 있도록 하는 새로운 예제 생성 패러다임을 제시하였으며, 향후 구조 기반 프롬프트 설계 및 자동 예제 생성 연구의 기반을 제공한다.
다국어 초록 (Multilingual Abstract)
Text-to-SQL aims to translate natural language questions into executable SQL queries, enabling users to interact with databases without domain-specific expertise. Recent advances in large language models (LLMs) have substantially improved this task th...
Text-to-SQL aims to translate natural language questions into executable SQL queries, enabling users to interact with databases without domain-specific expertise. Recent advances in large language models (LLMs) have substantially improved this task through In-Context Learning (ICL), where a few examples are provided within the prompt. However, existing example selection methods rely primarily on the semantic similarity between natural language questions, which fails to ensure structural similarity between their corresponding SQL queries. As a result, when the target query involves complex joins, nested subqueries, or multi-level aggregations—especially in realistic benchmarks such as BIRD—models often fail to retrieve structurally relevant examples, leading to severe performance degradation.
To address this limitation, we propose SEG-SQL (Structure-aware Example Generation for Text-to-SQL), a novel framework that generates structure-aligned examples for ICL. SEG-SQL first generates an initial SQL query from a given question and encodes its structural characteristics into a Hint Vector, a 40-bit binary representation summarizing SQL components such as clauses, joins, subqueries, and conditions. By mutating a subset of bits—particularly those corresponding to frequently mispredicted structures—SEG-SQL produces pseudo SQLs that are structurally similar yet diverse. Each pseudo SQL is then converted into a consistent natural language question via a SQL-to-Text generation process using an LLM, resulting in diverse NL-SQL pairs that reflect both semantic fidelity and structural consistency.
Experimental results on the BIRD benchmark demonstrate that SEG-SQL consistently outperforms existing ICL-based approaches. Specifically, it achieves 2.5% and 3.4% higher execution accuracy than CHESS and OpenSearch-SQL, respectively, under the same experimental settings. In the most challenging subset, where structurally similar examples are scarce, SEG-SQL yields 30.0% and 62.2% improvements, showing robust performance even in complex schema environments. Moreover, we observe that expanding the dimensionality of the Hint Vector leads to gradual accuracy gains, indicating that richer structural representations help LLMs better reason about SQL generation.
Overall, SEG-SQL moves beyond natural-language similarity and introduces a structure-driven paradigm for example generation in Text-to-SQL. By leveraging the asymmetry between SQL-to-Text and Text-to-SQL tasks, it enables LLMs to internalize SQL structures more effectively, enhancing both accuracy and robustness. This work provides a new perspective on structure-aware prompt design and automated example construction for LLM-based database reasoning.
목차 (Table of Contents)
로그인하고 관련된 다양한 학술자료를 확인해 보세요.
로그인