lianghsun's picture
Add dataset card
b9f2424 verified
metadata
license: cc-by-sa-4.0
language:
  - en
task_categories:
  - text-generation
  - question-answering
tags:
  - text-to-sql
  - sql
  - spider
  - 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: 7000
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/spider_train.parquet

Dataset Card for spider-text2sql-bench

spider-text2sql-bench 是 Spider 1.0 官方訓練集之 OpenAI Messages 格式版本,共 7,000 筆,將原始之 question / schema / sql 重新組裝為 system / user / assistant 三 role 之對話結構。除原生之 messages 欄位外,另拆解出獨立之 system / user / assistant 字串欄位,可作為 Text-to-SQL 模型之 SFT 訓練語料,亦可直接用於 benchmark evaluation pipeline(以 user 作為 prompt,比對模型輸出與 assistant 之標準答案 SQL)。

Dataset Details

Dataset Description

Spider 1.0 為 Yale LILY Group 於 EMNLP 2018 發表之大規模跨領域 Text-to-SQL 標註資料集,涵蓋 200+ 複雜資料庫與 10K+ 問題/SQL pair,長期作為 Text-to-SQL 模型之代表性訓練與評測基準。本資料集為其 train split 之 OpenAI Messages 格式版本,不修改任何原始問題、SQL、或資料庫 schema,僅進行格式重組與欄位拆解:

  • messages:完整之 OpenAI Messages 結構(list of {role, content});
  • system:固定提示語 "You are an expert SQL assistant...";
  • user### Database Schema 區塊(由 Spider 官方 SQLite 資料庫萃取之 CREATE TABLE 語句)+ ### Question 區塊;
  • assistant:對應之標準答案 SQL。

提供拆解後之獨立欄位,方便 benchmark pipeline 直接以 user 為 prompt 餵入模型、以 assistant 為 ground truth 進行 execution accuracy 比對,而無需再次解析 messages 結構。此格式亦能與 HuggingFace 生態之 SFT trainer(TRL、Axolotl、LLaMA-Factory 等)無縫整合,並與 bird-text2sql-bench 搭配作為 Text-to-SQL 訓練與評測之主力語料。

  • Curated by: Liang Hsun Huang
  • Language(s) (NLP): English(SQL / schema / question)
  • License: CC BY-SA 4.0(繼承自 Spider 1.0)

Dataset Sources

Uses

Direct Use

本資料集主要設計用於:

  • Text-to-SQL 模型之 SFT 訓練(以 messages 欄位為訓練目標);
  • Text-to-SQL 模型之 benchmark 評測(以 system + user 組 prompt,對齊 assistant 為 ground truth);
  • 跨領域 schema generalization 能力之建立;
  • 作為 bird-text2sql-bench 搭配訓練/評測,涵蓋中小型資料庫(Spider)與大規模真實資料庫(BIRD);
  • 作為 Text-to-SQL 模型 warm-up 之基礎語料,再接續 RL 或更大規模之合成語料(如 OmniSQL 之 SynSQL-2.5M)。

Out-of-Scope Use

本資料集不適用於下列用途:

  • 作為 Spider 官方評測之測試集,本資料集僅包含 train split;
  • 作為真實商業資料庫之 schema linking 訓練唯一來源,Spider 為教學式資料庫,不完全反映生產環境;
  • 非 SQL 方言之訓練(Spider 使用 SQLite 語法);
  • 作為多輪 SQL 對話之訓練(本資料集為單輪 question→SQL)。

Dataset Structure

{
  "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 department (...);\n\n### Question\nHow many heads are older than 56?"},
    {"role": "assistant", "content": "SELECT COUNT(*) FROM head WHERE age > 56"}
  ],
  "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 department (...);\n\n### Question\nHow many heads are older than 56?",
  "assistant": "SELECT COUNT(*) FROM head WHERE age > 56"
}
欄位 型別 說明
messages list[{role, content}] OpenAI Messages 結構,含 system / user / assistant 三 role
system string 拆解後之 system prompt(同 messages[0].content
user string 拆解後之 user prompt(同 messages[1].content
assistant string 拆解後之 assistant 標準答案 SQL(同 messages[2].content
統計項目 數值
筆數 7,000
來源 split Spider 1.0 train
資料庫數量 166
領域數量 138
SQL 複雜度 easy / medium / hard / extra hard
SQL 方言 SQLite
格式 Parquet

使用此原始資料集之知名模型

模型 機構 使用方式
OmniSQL Renmin University SFT 訓練資料之一
SQLCoder Defog Spider train 為基礎訓練資料
CodeS RUC (SIGMOD 2024) Spider + BIRD train SFT
DAIL-SQL Few-shot prompt 範例來源
Arctic-Text2SQL-R1 Snowflake 透過 OmniSQL checkpoint 間接使用

Dataset Creation

Curation Rationale

原始 Spider 1.0 之 JSON 格式需要額外處理方能餵入當代 SFT pipeline(特別是基於 OpenAI messages 格式之工具鏈)。本資料集直接完成此轉換,確保:

  1. Schema 以 CREATE TABLE 語句之形式提供(與 LLM 預訓練語料中常見之 SQL DDL 分布一致);
  2. System prompt 固定,便於控制實驗變項;
  3. messages 外同時提供拆解後之 system / user / assistant 欄位,讓 benchmark pipeline 可直接取用,無需再解析對話結構;
  4. 單檔 parquet 便於流式讀取與訓練 pipeline 整合。

Source Data

Data Collection and Processing

  1. 從 Spider 官方釋出之 train 資料(train_spider.json + train_others.json)讀取 question/SQL/db_id;
  2. 從 Spider 官方提供之 SQLite 資料庫中以 sqlite_master 萃取對應之 CREATE TABLE 語句作為 schema;
  3. 組裝為 OpenAI Messages 格式;
  4. 另外將每筆對話拆解為獨立之 system / user / assistant 字串欄位;
  5. 儲存為單檔 parquet。

本資料集不修改任何原始 SQL、問題或資料庫結構。

Who are the source data producers?

原始問題與 SQL 由 Yale LILY Group 招募之 CS 學生標註,標註流程詳見 Spider 原始論文。

Annotations

Annotation process

不適用(本資料集不包含額外人工標註)。

Who are the annotators?

不適用。

Personal and Sensitive Information

Spider 1.0 使用之資料庫均為教學用合成或公開資料,不含個人敏感資料。

Bias, Risks, and Limitations

  • 資料庫規模偏小:Spider 之 166 個資料庫多為教學式小型 schema,與真實商業環境(數百張表、極端欄位命名)差異大;
  • SQL 方言限定:僅為 SQLite,MySQL / PostgreSQL / T-SQL 特有語法不在涵蓋範圍;
  • 問題語言為英文:非英文 Text-to-SQL 任務需另外蒐集或翻譯;
  • 系統提示固定:可能導致模型對提示過度擬合,實務訓練時建議混合多種 prompt 變體;
  • 單輪:不涵蓋多輪 clarification 或對話式 Text-to-SQL。

Recommendations

建議使用者:

  • 將本資料集與 bird-text2sql-bench 共同訓練或評測,補足真實大型資料庫之覆蓋;
  • 實務部署前以目標 SQL 方言之範例進行額外微調;
  • 對 system prompt 加以變化以減少過擬合;
  • 遵循原始 Spider 1.0 之 CC BY-SA 4.0 授權規則。

Citation

@inproceedings{yu2018spider,
  title={Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task},
  author={Yu, Tao and Zhang, Rui and Yang, Kai and Yasunaga, Michihiro and Wang, Dongxu and Li, Zifan and Ma, James and Li, Irene and Yao, Qingning and Roman, Shanelle and others},
  booktitle={EMNLP},
  year={2018}
}

@misc{spider-text2sql-bench,
  title        = {spider-text2sql-bench: Spider 1.0 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/spider-text2sql-bench}},
  note         = {Reformatted from xlangai/spider train split (CC BY-SA 4.0) with additional system/user/assistant columns for benchmark pipelines.}
}

Dataset Card Authors

Liang Hsun Huang

Dataset Card Contact

Liang Hsun Huang