NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

STAR: SQL Guided Pre-Training for Context-dependent Text-to-SQL Parsing

Zefeng Cai, Xiangyu Li, Binyuan Hui, Min Yang, Bowen Li, Binhua Li, Zheng Cao, Weijie Li, Fei Huang, Luo Si, Yongbin Li

Abstract

Translating natural language into SQL queries becomes significantly more complex in conversational settings where context-dependent phenomena like ellipsis and anaphora are prevalent. This paper introduces STAR (SQL Guided Pre-Training), a novel framework designed to enhance multi-turn text-to-SQL parsing. By leveraging SQL as a precise representation of user intent, STAR introduces two specialized objectives: Schema State Tracking (SST) and Utterance Dependency Tracking (UDT). These objectives, combined with a large-scale synthetic corpus, allow the model to maintain a "mental map" of the database state and capture long-range dependencies across dialogue turns. STAR achieves new state-of-the-art results on the SParC and CoSQL benchmarks, demonstrating superior stability in long-running conversations.

Introduction

While single-turn text-to-SQL parsing has seen significant advancement, real-world applications often require multi-turn interactions. In these scenarios, users frequently omit details (ellipsis) or refer back to previously mentioned entities using pronouns (anaphora). For instance, a user might follow the question "How many Volvo cars are there?" with the shorthand "Which has the least acceleration?"

Existing Tabular Language Models (TaLMs) often struggle with these shifts because they lack an explicit mechanism to track the conversation's state or the dependencies between non-consecutive turns. The authors of STAR identify that while natural language is ambiguous, the corresponding SQL queries are structured and precise. STAR proposes using SQL as a "silver bullet" to guide the pre-training process, anchoring ambiguous linguistic utterances to stable logical representations.

Methodology

STAR utilizes a multi-task learning approach with three primary objectives designed to bridge the gap between natural language and structured queries.

1. Schema State Tracking (SST)

Inspired by traditional dialogue state tracking, SST treats the database schema as a set of "slots" (columns) and SQL keywords (e.g., SELECT, WHERE, ORDER BY) as "values." The model is trained to predict how these values evolve from one turn to the next. This allows the model to explicitly track which parts of the database are currently relevant to the conversation.

2. Utterance Dependency Tracking (UDT)

To handle long-range dependencies, UDT employs weighted contrastive learning. The model learns to identify similar questions within a conversation by comparing their corresponding SQL queries. Similarity is calculated based on:

  • Semantics: Overlap in columns and values.
  • Structure: The tree-structure of the SQL logic. This enables the model to recognize when a user returns to a topic from several turns ago, rather than just focusing on the immediate previous utterance.

3. Masked Language Modeling (MLM)

A standard MLM objective is included to ensure the model maintains a strong grasp of general linguistic patterns and vocabulary.

Automated Loss Weighting

To balance these tasks, the framework employs homoscedastic uncertainty. This technique automatically weights the importance of each loss function during training, eliminating the need for manual hyperparameter tuning.

Datasets and Synthetic Corpus

The model was evaluated on two primary benchmarks:

  • SParC: A cross-domain context-dependent dataset containing over 12,000 questions.
  • CoSQL: A conversational version of the Spider dataset with 10,000+ questions.

Recognizing the scarcity of high-quality conversational data, the authors also introduced the Synthetic STAR Corpus. Using a BART-based generative model and template-based approaches, they synthesized 480,000 high-quality, multi-turn text-to-SQL conversations to provide a robust foundation for pre-training.

Results and Key Insights

STAR established new performance benchmarks on both major datasets:

  • SParC: Achieved 67.4% Question Match (QM) accuracy on the test set, a 2.8% improvement over previous leaders like SCORE and GRAPPA.
  • CoSQL: Achieved 57.8% QM accuracy, representing a 3.9% improvement.

One of the most significant findings was the model's stability. While baseline models typically show a sharp decline in accuracy as conversations exceed four turns, STAR’s performance remained remarkably stable. This suggests that the SST and UDT objectives successfully mitigate the "forgetting" problem common in context-heavy NLP tasks.

Conclusion

STAR demonstrates that SQL structure can serve as a powerful supervisory signal for understanding conversational natural language. By treating the database schema as a dialogue state and using SQL similarity to track dependencies, STAR effectively addresses the nuances of multi-turn parsing.

Future research directions include improving schema linking—specifically handling creative synonyms for table names—and refining structural logic to prevent the inheritance of redundant SQL clauses in complex queries. The authors also suggest exploring objectives that predict abstract syntax trees to further ensure the syntactic perfection of generated SQL.

Summary updated

BibTeX
@inproceedings{cai2022star,
  author = {Zefeng Cai and Xiangyu Li and Binyuan Hui and Min Yang and Bowen Li and Binhua Li and Zheng Cao and Weijie Li and Fei Huang and Luo Si and Yongbin Li},
  title = {{STAR: SQL Guided Pre-Training for Context-dependent Text-to-SQL Parsing}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.findings-emnlp.89},
}
Figure