acceptodds
Under review as a conference paper at ICLR 2027

SARank: Structure-Aware Demonstration Reranking for Text-to-SQL

Abstract

Text-to-SQL translates natural-language questions into executable SQL queries. Existing retrieval-augmented methods usually rank demonstrations by semantic or schema similarity. However, semantically similar questions may require different SQL operations, causing structurally relevant demonstrations to fall outside the limited Top- context. We call this problem the demonstration exposure bottleneck. To address it, we propose SARank, a structure-aware demonstration reranking method. SARank first uses a schema-aware retriever to construct a high-recall candidate pool. It then abstracts SQL literals and learns question–SQL compatibility with a shared encoder trained by a candidate-aware contrastive objective using retrieval-based, same-database, and random negatives. The resulting scores reorder the candidates before prompt construction, without requiring a predicted target SQL or execution feedback. Experiments across Spider, BIRD, BEAVER, and Dr.Spider, including evaluations with multiple LLMs, show that SARank improves , , and downstream execution accuracy. Candidate-budget analysis and case studies further show that SARank promotes lower-ranked but structurally aligned demonstrations into the Top-, providing more effective guidance for SQL generation.

Then back it, or bet against it.

Related papers

Open the market on this paper to see 7 more related papers.