Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,31 +1,116 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: cc-by-sa-4.0
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-sa-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- text2text-generation
|
| 5 |
+
- table-question-answering
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
- sql
|
| 9 |
+
tags:
|
| 10 |
+
- text-to-sql
|
| 11 |
+
- sql
|
| 12 |
+
- spider
|
| 13 |
+
- flan-t5
|
| 14 |
+
- seq2seq
|
| 15 |
+
- nlp
|
| 16 |
+
size_categories:
|
| 17 |
+
- 1K<n<10K
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# SPIDER Text-to-SQL — Easy Access Version
|
| 21 |
+
|
| 22 |
+
A clean, HuggingFace-native version of the [SPIDER](https://yale-seas.yale.edu/spider/) Text-to-SQL benchmark. The original SPIDER dataset requires manually downloading a ZIP file from the Spider website. This version makes it instantly accessible via `load_dataset`.
|
| 23 |
+
|
| 24 |
+
## What's Included
|
| 25 |
+
|
| 26 |
+
Each row contains the question, gold SQL, the database identifier, and a pre-parsed compact schema string — everything needed to train or evaluate a Text-to-SQL model without any additional preprocessing.
|
| 27 |
+
|
| 28 |
+
| Column | Description |
|
| 29 |
+
|---|---|
|
| 30 |
+
| `db_id` | Database identifier (e.g. `"concert_singer"`) |
|
| 31 |
+
| `question` | Natural language question |
|
| 32 |
+
| `query` | Gold standard SQL answer |
|
| 33 |
+
| `db_schema` | Compact schema: `"table: col (type), col (type) | table2: ..."` |
|
| 34 |
+
| `question_toks` | Tokenized question words (list of strings) |
|
| 35 |
+
|
| 36 |
+
## Splits
|
| 37 |
+
|
| 38 |
+
| Split | Source file | Examples |
|
| 39 |
+
|---|---|---|
|
| 40 |
+
| train | `train_spider.json` | 7,000 |
|
| 41 |
+
| test | `train_others.json` | 1,034 |
|
| 42 |
+
|
| 43 |
+
> **Note**: Following standard SPIDER practice, `train_others.json` is used as the held-out evaluation set. The original SPIDER test set is withheld for the official leaderboard.
|
| 44 |
+
|
| 45 |
+
## Usage
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
from datasets import load_dataset
|
| 49 |
+
|
| 50 |
+
dataset = load_dataset("YOUR_USERNAME/spider-text2sql")
|
| 51 |
+
|
| 52 |
+
train = dataset["train"]
|
| 53 |
+
test = dataset["test"]
|
| 54 |
+
|
| 55 |
+
# Access fields
|
| 56 |
+
example = train[0]
|
| 57 |
+
print(example["question"]) # "How many heads of the departments are older than 56?"
|
| 58 |
+
print(example["query"]) # "SELECT count(*) FROM head WHERE age > 56"
|
| 59 |
+
print(example["db_id"]) # "department_management"
|
| 60 |
+
print(example["db_schema"]) # "department: Department_ID (number), ... | head: ..."
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## Schema Format
|
| 64 |
+
|
| 65 |
+
The `db_schema` column uses a compact linear format widely used in the Text-to-SQL literature:
|
| 66 |
+
|
| 67 |
+
```
|
| 68 |
+
table1: col1 (type), col2 (type), col3 (type) | table2: col4 (type), col5 (type)
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
This format is:
|
| 72 |
+
- Human-readable and model-friendly
|
| 73 |
+
- Fits within typical 512-token input limits for most seq2seq models
|
| 74 |
+
- Derived directly from the official SPIDER `tables.json`
|
| 75 |
+
|
| 76 |
+
## Fine-tuning Example (Flan-T5 prompt format)
|
| 77 |
+
|
| 78 |
+
This dataset pairs naturally with prompt-based fine-tuning:
|
| 79 |
+
|
| 80 |
+
```python
|
| 81 |
+
def build_prompt(example):
|
| 82 |
+
return (
|
| 83 |
+
f"Translate to SQL: {example['question']}\n"
|
| 84 |
+
f"Database schema:\n{example['db_schema']}"
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
# example["query"] is the target output
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
## Difference from Original SPIDER
|
| 91 |
+
|
| 92 |
+
| | Original SPIDER | This Dataset |
|
| 93 |
+
|---|---|---|
|
| 94 |
+
| Download method | Manual ZIP from website | `load_dataset(...)` ✅ |
|
| 95 |
+
| Schema included | Separate `tables.json` | ✅ Pre-joined per example |
|
| 96 |
+
| Complex `sql` dict | ✅ Included | ❌ Omitted (noisy for most use cases) |
|
| 97 |
+
| `query_toks_no_value` | ✅ Included | ❌ Omitted |
|
| 98 |
+
| Ready to train | Requires preprocessing | ✅ Yes |
|
| 99 |
+
|
| 100 |
+
## Source & License
|
| 101 |
+
|
| 102 |
+
- Original dataset: [SPIDER (Yu et al., 2018)](https://yale-seas.yale.edu/spider/)
|
| 103 |
+
- License: **Creative Commons Attribution-ShareAlike 4.0 (CC BY-SA 4.0)**
|
| 104 |
+
- This derived dataset is released under the same license.
|
| 105 |
+
|
| 106 |
+
## Citation
|
| 107 |
+
|
| 108 |
+
```bibtex
|
| 109 |
+
@inproceedings{yu-etal-2018-spider,
|
| 110 |
+
title = "{S}pider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-{SQL} Task",
|
| 111 |
+
author = "Yu, Tao and others",
|
| 112 |
+
booktitle = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing",
|
| 113 |
+
year = "2018",
|
| 114 |
+
url = "https://aclanthology.org/D18-1425",
|
| 115 |
+
}
|
| 116 |
+
```
|