SQL-R1: 강화 학습을 통한 자연어-SQL 추론 모델 학습
SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement Learning
April 11, 2025
저자: Peixian Ma, Xialie Zhuang, Chengjin Xu, Xuhui Jiang, Ran Chen, Jian Guo
cs.AI
초록
자연어를 SQL로 변환하는 기술(NL2SQL)은 자연어 쿼리를 구조화된 SQL 문으로 변환함으로써 데이터베이스와의 직관적인 상호작용을 가능하게 합니다. 데이터베이스 애플리케이션 내에서 인간-컴퓨터 상호작용을 향상시키기 위한 최근의 발전에도 불구하고, 특히 다중 테이블 조인 및 중첩 쿼리를 포함하는 복잡한 시나리오에서의 추론 성능과 관련하여 상당한 과제가 남아 있습니다. 현재의 방법론은 주로 지도 미세 조정(SFT)을 사용하여 NL2SQL 모델을 훈련시키는데, 이는 새로운 환경(예: 금융 및 헬스케어)에서의 적응성과 해석 가능성을 제한할 수 있습니다. 위와 같은 복잡한 상황에서 NL2SQL 모델의 추론 성능을 향상시키기 위해, 우리는 강화 학습(RL) 알고리즘으로 훈련된 새로운 NL2SQL 추론 모델인 SQL-R1을 소개합니다. 우리는 NL2SQL 작업에 특화된 RL 기반 보상 함수를 설계하고, 집중적인 훈련의 효과에 대한 콜드 스타트의 영향을 논의합니다. 또한, 우리는 합성된 NL2SQL 데이터의 극소량만을 사용하여 증강 훈련을 수행하면서도 경쟁력 있는 정확도를 달성하고, RL을 위한 데이터 엔지니어링을 추가로 탐구합니다. 기존 실험에서 SQL-R1은 7B 기본 모델만을 사용하여 벤치마크 Spider와 BIRD에서 각각 88.6%와 66.6%의 실행 정확도를 달성했습니다.
English
Natural Language to SQL (NL2SQL) enables intuitive interactions with
databases by transforming natural language queries into structured SQL
statements. Despite recent advancements in enhancing human-computer interaction
within database applications, significant challenges persist, particularly
regarding the inference performance in complex scenarios involving multi-table
joins and nested queries. Current methodologies primarily utilize supervised
fine-tuning (SFT) to train the NL2SQL model, which may limit adaptability and
interpretability in new environments (e.g., finance and healthcare). In order
to enhance the reasoning performance of the NL2SQL model in the above complex
situations, we introduce SQL-R1, a novel NL2SQL reasoning model trained by the
reinforcement learning (RL) algorithms. We design a specialized RL-based reward
function tailored for NL2SQL tasks and discussed the impact of cold start on
the effectiveness of intensive training. In addition, we achieve competitive
accuracy using only a tiny amount of synthetic NL2SQL data for augmented
training and further explore data engineering for RL. In existing experiments,
SQL-R1 achieves execution accuracy of 88.6% and 66.6% on the benchmark Spider
and BIRD, respectively, only using the 7B base model.Summary
AI-Generated Summary