bird-text2sql-bench / README.md
lianghsun's picture
Add dataset card
8d4aff1 verified
---
license: cc-by-sa-4.0
language:
- en
task_categories:
- text-generation
- question-answering
tags:
- text-to-sql
- sql
- bird
- bench
- benchmark
- openai-format
size_categories:
- 1K<n<10K
dataset_info:
features:
- name: messages
list:
- name: role
dtype: string
- name: content
dtype: string
- name: system
dtype: string
- name: user
dtype: string
- name: assistant
dtype: string
splits:
- name: train
num_examples: 9428
configs:
- config_name: default
data_files:
- split: train
path: data/bird_train.parquet
---
# Dataset Card for bird-text2sql-bench
<!-- Provide a quick summary of the dataset. -->
bird-text2sql-bench 是 [BIRD(BIg Bench for Large-Scale Database Grounded Text-to-SQL)](https://bird-bench.github.io/) 官方訓練集之 OpenAI Messages 格式版本,共 9,428 筆。相較於 Spider 1.0,BIRD 使用真實大型資料庫(70 個,涵蓋電商、運動、教育、醫療等 37+ 領域),並提供 `evidence`(數值提示)欄位,本資料集將 `evidence``### Hint` 段落併入 `user` prompt,形成可直接餵入 SFT pipeline 之 `system / user / assistant` 三 role 對話。除原生之 `messages` 欄位外,另拆解出獨立之 `system` / `user` / `assistant` 字串欄位,可同時作為 SFT 語料與 benchmark evaluation pipeline 之直接輸入。
## Dataset Details
### Dataset Description
<!-- Provide a longer summary of what this dataset is. -->
BIRD benchmark 由香港大學與微軟研究院合作於 NeurIPS 2023 發表,目的為測試 LLM 在真實資料庫之 Text-to-SQL 能力。其訓練集之特色:
1. 資料庫為真實世界之大型 schema,包含髒資料、寬表、外部知識需求;
2. 每題附帶 `evidence` 欄位,提供回答問題所需之外部知識或數值對應(例如「age refers to column `birth_year`」),模擬實務中 analyst 手上之 domain hint;
3. 涵蓋之領域遠比 Spider 廣泛,適合訓練需要處理實務資料庫之 Text-to-SQL 模型。
本資料集為其 train split 之 OpenAI Messages 格式版本,不修改任何原始問題、SQL、evidence 或資料庫 schema,僅進行格式重組與欄位拆解:
* `messages`:完整之 OpenAI Messages 結構(list of {role, content});
* `system`:固定提示語 "You are an expert SQL assistant...";
* `user``### Database Schema``### Question` +(若有)`### Hint`
* `assistant`:標準答案 SQL。
提供拆解後之獨立欄位,方便 benchmark pipeline 直接以 `user` 為 prompt 餵入模型、以 `assistant` 為 ground truth 進行 execution accuracy 比對,而無需再次解析 `messages` 結構。
- **Curated by:** [Liang Hsun Huang](https://www.linkedin.com/in/lianghsunhuang/?locale=en_US)
- **Language(s) (NLP):** English
- **License:** CC BY-SA 4.0(繼承自 BIRD benchmark)
### Dataset Sources
<!-- Provide the basic links for the dataset. -->
- **Repository:** [lianghsun/bird-text2sql-bench](https://huggingface.co/datasets/lianghsun/bird-text2sql-bench/)
- **Upstream Benchmark:** [bird-bench.github.io](https://bird-bench.github.io/)
- **Paper:** [Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLs (NeurIPS 2023)](https://arxiv.org/abs/2305.03111)
## Uses
<!-- Address questions around how the dataset is intended to be used. -->
### Direct Use
<!-- This section describes suitable use cases for the dataset. -->
本資料集主要設計用於:
* Text-to-SQL 模型之 SFT 訓練(以 `messages` 為訓練目標),特別是需要處理真實大型 schema 之情境;
* Text-to-SQL 模型之 benchmark 評測(以 `system` + `user` 組 prompt,對齊 `assistant` 為 ground truth);
* 學習如何運用 external hint / evidence 進行 SQL 生成;
* 與 [spider-text2sql-bench](https://huggingface.co/datasets/lianghsun/spider-text2sql-bench) 搭配作為 Text-to-SQL 之完整訓練/評測組合;
* 作為 GRPO / RL-based Text-to-SQL 訓練之 reference policy 初始化語料。
### Out-of-Scope Use
<!-- This section addresses misuse, malicious use, and uses that the dataset will not work well for. -->
本資料集不適用於下列用途:
* 作為 BIRD 官方評測之測試集使用,本資料集僅為 train split;
* 作為非 SQLite 方言之訓練來源;
* 作為中文 Text-to-SQL 之直接訓練資料;
* 作為不含 evidence 之純語意解析任務之唯一來源。
## Dataset Structure
<!-- This section provides a description of the dataset fields, and additional information about the dataset structure such as criteria used to create the splits, relationships between data points, etc. -->
```json
{
"messages": [
{"role": "system", "content": "You are an expert SQL assistant. Given a database schema and a question, generate the correct SQL query. Output only the SQL query, no explanation."},
{"role": "user", "content": "### Database Schema\nCREATE TABLE ...\n\n### Question\nWhat is the average age?\n\n### Hint\nage refers to column `birth_year`"},
{"role": "assistant", "content": "SELECT AVG(birth_year) FROM person"}
],
"system": "You are an expert SQL assistant. Given a database schema and a question, generate the correct SQL query. Output only the SQL query, no explanation.",
"user": "### Database Schema\nCREATE TABLE ...\n\n### Question\nWhat is the average age?\n\n### Hint\nage refers to column `birth_year`",
"assistant": "SELECT AVG(birth_year) FROM person"
}
```
無 evidence 之樣本則省略 `### Hint` 區塊。
| 欄位 | 型別 | 說明 |
|---|---|---|
| `messages` | list[{role, content}] | OpenAI Messages 結構(system / user / assistant) |
| `system` | string | 拆解後之 system prompt(同 `messages[0].content`) |
| `user` | string | 拆解後之 user prompt(同 `messages[1].content`) |
| `assistant` | string | 拆解後之 assistant 標準答案 SQL(同 `messages[2].content`) |
| 統計項目 | 數值 |
|---|---|
| 筆數 | 9,428 |
| 來源 split | BIRD train |
| 資料庫數量 | 70(真實大型資料庫) |
| 領域數量 | 37+ |
| 特色 | evidence 欄位併入 user prompt |
| SQL 方言 | SQLite |
| 格式 | Parquet |
### 使用此原始資料集之知名模型
| 模型 | 機構 | 使用方式 |
|---|---|---|
| [OmniSQL](https://arxiv.org/abs/2503.02240) | Renmin University | SFT 訓練資料之一(搭配 SynSQL-2.5M、Spider) |
| [XiYan-SQL](https://arxiv.org/abs/2411.08599) | Alibaba | Stage 1 + Stage 2 SFT 訓練資料 |
| [CodeS](https://arxiv.org/abs/2402.16347) | RUC (SIGMOD 2024) | Spider + BIRD train SFT |
| [CHESS](https://arxiv.org/abs/2408.09674) | Stanford | 訓練 Schema Selector 與 SQL Generator |
| [Arctic-Text2SQL-R1](https://huggingface.co/Snowflake/Arctic-Text2SQL-R1) | Snowflake | GRPO RL 亦使用 BIRD train |
## Dataset Creation
### Curation Rationale
<!-- Motivation for the creation of this dataset. -->
BIRD 原始釋出格式需依照官方 harness 組裝才能用於訓練,且 evidence 欄位之納入方式各論文做法不一。本資料集將 evidence 以固定之 `### Hint` 區塊併入 user prompt,並於 `messages` 之外同時提供拆解後之 `system` / `user` / `assistant` 欄位,讓 benchmark pipeline 可直接取用,提供一個可直接使用之 SFT 與 benchmark 基準格式。
### Source Data
#### Data Collection and Processing
1. 從 BIRD benchmark 官方釋出之 `train.json` 讀取 question / SQL / evidence / db_id;
2. 從官方提供之 SQLite 資料庫以 `sqlite_master` 萃取 `CREATE TABLE` 語句作為 schema;
3. 組裝為 OpenAI Messages 格式,evidence 以 `### Hint` 併入 user prompt(若 evidence 為空則省略);
4. 另外將每筆對話拆解為獨立之 `system` / `user` / `assistant` 字串欄位;
5. 儲存為單檔 parquet。
#### Who are the source data producers?
原始問題、SQL 與 evidence 由 BIRD benchmark 之標註團隊(香港大學 / 微軟研究院)產出,詳見原始論文。
### Annotations
#### Annotation process
本資料集不包含額外人工標註。
#### Who are the annotators?
不適用。
#### Personal and Sensitive Information
<!-- State whether the dataset contains data that might be considered personal, sensitive, or private (e.g., data that reveals addresses, uniquely identifiable names or aliases, racial or ethnic origins, sexual orientations, religious beliefs, political opinions, financial or health data, etc.). If efforts were made to anonymize the data, describe the anonymization process. -->
BIRD 之資料庫皆為公開或授權之資料來源,詳見原始論文與授權條款。
## Bias, Risks, and Limitations
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
* **evidence 品質差異**:部分 evidence 為關鍵知識,部分僅為次要提示,訓練時模型可能對 evidence 過度依賴;
* **真實資料庫之髒資料**:schema 中可能含有拼錯之欄位、不一致之命名,對模型之 schema linking 為挑戰亦為特色;
* **SQL 方言限定**:SQLite,其他方言不適用;
* **資料規模中等**:9,428 筆屬中等規模,大規模訓練時建議與合成資料搭配。
### Recommendations
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
建議使用者:
* 將本資料集與 `spider-text2sql-bench` 合併作為 Text-to-SQL SFT 主力語料或 benchmark 組合;
*`### Hint` 之使用方式進行 ablation,觀察模型是否過度依賴 evidence;
* 作為 RL 訓練(GRPO / DPO)之 SFT 基線,再接續 reward-based 優化;
* 遵循原始 BIRD benchmark 之 CC BY-SA 4.0 授權規則。
## Citation
```bibtex
@inproceedings{li2023bird,
title={Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLs},
author={Li, Jinyang and Hui, Binyuan and Qu, Ge and Yang, Jiaxi and Li, Binhua and Li, Bowen and Wang, Bailin and Qin, Bowen and Geng, Ruiying and Huo, Nan and others},
booktitle={NeurIPS},
year={2023}
}
@misc{bird-text2sql-bench,
title = {bird-text2sql-bench: BIRD in OpenAI Messages + Split Columns Format for Text-to-SQL SFT and Benchmark},
author = {Liang Hsun Huang},
year = {2024},
howpublished = {\url{https://huggingface.co/datasets/lianghsun/bird-text2sql-bench}},
note = {Reformatted from BIRD benchmark train split (CC BY-SA 4.0) with additional system/user/assistant columns for benchmark pipelines.}
}
```
## Dataset Card Authors
[Liang Hsun Huang](https://www.linkedin.com/in/lianghsunhuang/?locale=en_US)
## Dataset Card Contact
[Liang Hsun Huang](https://www.linkedin.com/in/lianghsunhuang/?locale=en_US)