CSS: A Large-scale Cross-schema Chinese Text-to-SQL Medical Dataset

Hanchong Zhang, Jieyu Li, Lu Chen, Ruisheng Cao, Yunyan Zhang, Yu Huang, Yefeng Zheng, Kai Yu

Abstract

This paper introduces CSS, the largest Chinese text-to-SQL dataset specifically designed for the medical domain. Unlike traditional benchmarks that focus on single-domain or broad cross-domain tasks, CSS introduces a "cross-schema" setup to address the fragmented nature of real-world hospital databases. By evaluating models on unseen database structures within the same specialized domain, the authors provide a more realistic assessment of AI deployment in healthcare. The dataset comprises over 33,000 question/SQL pairs across 21 databases, featuring high structural complexity. Additionally, the authors propose a Syntactic Role Prediction (SRP) task to enhance model generalization across varying schemas.

Introduction

The task of converting natural language into SQL queries (text-to-SQL) is critical for making database information accessible to non-technical users. However, existing benchmarks often fail to capture the nuances of specialized industries like healthcare. Single-domain datasets often lead to models that "memorize" specific schemas, while cross-domain datasets may overlook the importance of domain-specific terminology.

In real-world medical settings, while different hospitals store similar data (e.g., patient records, treatments), their underlying database schemas vary significantly. CSS bridges this gap by focusing on cross-schema generalization within the medical domain: can a model trained on one set of medical databases generalize to a different medical database structure?

The CSS Dataset and Construction

CSS (CrosS-Schema) is a large-scale Chinese medical dataset containing 33,620 question/SQL pairs. It is characterized by its significant complexity, with an average of 28.5 columns per table—far exceeding common benchmarks like Spider (5.1) or DuSQL (5.3). The SQL queries themselves are exceptionally long, averaging 55 tokens and reaching up to 243 tokens.

The multi-step pipeline for CSS dataset generation, including template creation, value filling, and schema extension.

The construction of CSS followed a rigorous multi-step pipeline to ensure both linguistic variety and structural complexity:

  1. Seed Databases: Two real-world Chinese medical databases (insurance and clinical records) were used as a foundation, populated with high-quality pseudo-values.
  2. Schema Extension: The seed databases were expanded into 21 distinct versions by altering their structures—merging tables, splitting them based on categories, or adding complex relation tables.
  3. Data Generation: 434 templates were used to generate initial pairs, which were then manually paraphrased by human annotators to ensure natural language diversity.

Methodology: Schema Extension and SRP

To simulate the structural variety of hospital databases, the authors employed schema extension techniques. This involves transforming a simple database structure into a more complex one while preserving the underlying data relationships, forcing models to rely on logic rather than fixed table names.

An example of database schema extension where a direct relationship is transformed into a many-to-many relation table.

Furthermore, the authors introduced Syntactic Role Prediction (SRP) as an auxiliary training task. In SRP, the model is trained to predict the syntactic role of each word in the input question (e.g., whether it corresponds to a SELECT column or a WHERE condition). This "pre-computation" helps the model map natural language components to SQL clauses more effectively, especially when encountering unfamiliar schemas.

Experimental Results

The researchers benchmarked state-of-the-art models including RATSQL, LGESQL, and PICARD. While models achieved high accuracy (over 90% Exact Match) on seen databases, performance dropped significantly on unseen schemas. For instance, RATSQL's accuracy fell to 43.4% in the database-split setting.

Key findings include:

  • The SRP Boost: The inclusion of the SRP task provided a consistent performance boost (approx. 3.8%) on unseen databases, proving that explicit syntactic mapping helps navigation.
  • PICARD's Struggle: Despite its power, the seq2seq model PICARD struggled with the long medical queries compared to AST-based (Abstract Syntax Tree) approaches like LGESQL.

Conclusion

CSS represents a significant advancement in medical NLP, highlighting that structural generalization remains a major hurdle for current text-to-SQL models. There remains a 40-50% performance gap between "seen" and "unseen" schemas. The findings suggest that future research should prioritize robust graph-based schema representations and decoding strategies capable of handling the exceptionally long and nested queries typical of the medical field.

Summary updated

BibTeX
@inproceedings{zhang2023css,
  author = {Hanchong Zhang and Jieyu Li and Lu Chen and Ruisheng Cao and Yunyan Zhang and Yu Huang and Yefeng Zheng and Kai Yu},
  title = {{CSS: A Large-scale Cross-schema Chinese Text-to-SQL Medical Dataset}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.435},
}
Figure