CYANSQL: Unlock the Power of NL2SQL Via Clustering-Based Test-Time Scaling
Haoyu Qin, Tonghui Ren, Zhenying He, X. Sean Wang, Jiashu Xing, Yanghuan Ye, Shifei Huang, Jinbao Li
Abstract
Large language models (LLMs) are playing an increasingly important role in the Natural Language to SQL (NL2SQL) task. Although LLMs exhibit strong inherent reasoning abilities, they often fail to generate correct SQL because they lack knowledge of the target logical operator composition. Few-shot learning is a commonly employed approach to provide relevant knowledge to LLMs, and many studies focus on how to select effective demonstrations. However, these methods are often limited by the quality of the selected demonstrations, resulting in a failure to fully exploit the rich logical operation information contained in the demonstrations. In this work, we propose CYANSQL (Cluster-aware Yielded Augmentation for NL2SQL), a method that leverages parallel test-time scaling to strengthen LLM reasoning. We first cluster the demonstrations based on SQL logical operator composition, then perform multi-path generation by injecting demonstrations from each cluster during LLM inference, followed by a ranking stage to identify the optimal SQL. CYANSQL achieves an execution accuracy of 73.47% and a state-of-the-art recall of 87.22% on the development set of the popular NL2SQL benchmark BIRD. The source code of this project is available at: https://github.com/zyddqhy/CYANSQL
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Related papers
- DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-CorrectionMohammadreza Pourreza, Davood RafieiNeurIPS 2023 · 909 citations
- CHASE-SQL: Multi-Path Reasoning and Preference Optimized Candidate Selection in Text-to-SQLMohammadreza Pourreza, Hailong Li, Ruoxi Sun, Yeounoh Chung et al.ICLR 2025
- PURPLE: Making a Large Language Model a Better SQL WriterTonghui Ren, Yuankai Fan, Zhenying He, Ren Huang et al.ICDE 2024 · 49 citations
- Alpha-SQL: Zero-Shot Text-to-SQL using Monte Carlo Tree SearchBoyan Li, Jiayi Zhang, Ju Fan, Yanwei Xu et al.ICML 2025
- SchemaRAG: A Schema-aware Retrieval-Augmented Generation Framework for Text-to-SQLDi Wu, Zetong Tang, Yi He, Xin LuoSIGMOD 2026 · 9 citations
