Add CoSQL-S2T, SParC-S2T and Spider-S2T test sets and dataset card
Browse files
README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-sa-4.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pretty_name: SQL2Text Semantic Captioning Benchmark
|
| 6 |
+
task_categories:
|
| 7 |
+
- text-generation
|
| 8 |
+
tags:
|
| 9 |
+
- sql
|
| 10 |
+
- sql2text
|
| 11 |
+
- semantic-captioning
|
| 12 |
+
- code
|
| 13 |
+
- in-context-learning
|
| 14 |
+
size_categories:
|
| 15 |
+
- n<1K
|
| 16 |
+
configs:
|
| 17 |
+
- config_name: cosql_s2t
|
| 18 |
+
data_files:
|
| 19 |
+
- split: test
|
| 20 |
+
path: cosql_s2t/test-00000-of-00001.parquet
|
| 21 |
+
- config_name: sparc_s2t
|
| 22 |
+
data_files:
|
| 23 |
+
- split: test
|
| 24 |
+
path: sparc_s2t/test-00000-of-00001.parquet
|
| 25 |
+
- config_name: spider_s2t
|
| 26 |
+
data_files:
|
| 27 |
+
- split: test
|
| 28 |
+
path: spider_s2t/test-00000-of-00001.parquet
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
# SQL2Text: a semantic captioning benchmark
|
| 32 |
+
|
| 33 |
+
Test sets for **SQL2Text**, the task of describing a SQL query in natural language (semantic captioning, the
|
| 34 |
+
reverse of Text2SQL). They were introduced in
|
| 35 |
+
|
| 36 |
+
> Ali Al-Lawati, Jason Lucas, Prasenjit Mitra.
|
| 37 |
+
> [Semantic Captioning: Benchmark Dataset and Graph-Aware Few-Shot In-Context Learning for SQL2Text](https://aclanthology.org/2025.coling-main.536/).
|
| 38 |
+
> COLING 2025.
|
| 39 |
+
|
| 40 |
+
A SQL query can be described correctly in many ways, so a single reference question, as found in Text2SQL
|
| 41 |
+
datasets, is a weak target for the reverse task. Each query here therefore comes with several reference
|
| 42 |
+
captions: three written by GPT-4o through an iterative generate, review and refine prompt, plus the original
|
| 43 |
+
human-written question from the source dataset where that question passed validation.
|
| 44 |
+
|
| 45 |
+
## Contents
|
| 46 |
+
|
| 47 |
+
Three configurations, each with a single `test` split.
|
| 48 |
+
|
| 49 |
+
| Configuration | Source dataset | Queries | Generated captions | Original questions | Total references |
|
| 50 |
+
| --- | --- | ---: | ---: | ---: | ---: |
|
| 51 |
+
| `cosql_s2t` | CoSQL, dev | 290 | 870 | 280 | 1,150 |
|
| 52 |
+
| `sparc_s2t` | SParC, dev | 289 | 867 | 282 | 1,149 |
|
| 53 |
+
| `spider_s2t` | Spider, dev | 274 | 822 | 273 | 1,095 |
|
| 54 |
+
| Total | | 853 | 2,559 | 835 | 3,394 |
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from datasets import load_dataset
|
| 58 |
+
|
| 59 |
+
ds = load_dataset("aliwister/SQL2Text", "spider_s2t", split="test")
|
| 60 |
+
print(ds[0])
|
| 61 |
+
# {'idx': 'spider-0',
|
| 62 |
+
# 'query': 'SELECT count(*) FROM singer',
|
| 63 |
+
# 'utterances': ['How many singers are there?',
|
| 64 |
+
# 'Please provide the total number of singers.',
|
| 65 |
+
# 'Can you count the total number of singers?',
|
| 66 |
+
# 'How many singers do we have?'],
|
| 67 |
+
# 'query_type': 'aggregate'}
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
## Fields
|
| 71 |
+
|
| 72 |
+
| Field | Type | Description |
|
| 73 |
+
| --- | --- | --- |
|
| 74 |
+
| `idx` | string | Identifier of the example, for example `cosql-17`. Identifiers are unique within a configuration and are not contiguous, because some examples were removed during validation. |
|
| 75 |
+
| `query` | string | The SQL query to be captioned. |
|
| 76 |
+
| `utterances` | list of strings | The reference captions. The first three were generated by GPT-4o. When there is a fourth, it is the original question from the source dataset; it is absent where the original question did not pass validation. |
|
| 77 |
+
| `query_type` | string | `simple`, `aggregate` or `nested`, the grouping used for the per-type results in the paper. |
|
| 78 |
+
|
| 79 |
+
## How the data was built
|
| 80 |
+
|
| 81 |
+
1. **Source.** Query and question pairs from the development sets of the three source datasets: all 293
|
| 82 |
+
examples of CoSQL and random samples of 293 examples each from SParC and Spider. For the conversational
|
| 83 |
+
datasets CoSQL and SParC, the pair is the final query and utterance of each interaction.
|
| 84 |
+
2. **Generation.** For every query, GPT-4o followed a three-step prompt: generate three captions, review each
|
| 85 |
+
one for accuracy, clarity, fluency and relevance to the query, then refine them using that feedback. The
|
| 86 |
+
three references kept per query were chosen by AlignScore and BERTScore against the original question.
|
| 87 |
+
3. **Validation.** Three evaluators with NLP and database experience checked every query together with its
|
| 88 |
+
original question and generated captions for semantic accuracy, preservation of the SQL logic and technical
|
| 89 |
+
precision (Fleiss' kappa 0.802). Inconsistent queries, original questions and captions were removed, which
|
| 90 |
+
left the 853 queries above.
|
| 91 |
+
|
| 92 |
+
The prompt and the full protocol are in the paper.
|
| 93 |
+
|
| 94 |
+
## Use
|
| 95 |
+
|
| 96 |
+
The paper evaluates captions produced by a model for each `query` against the references in `utterances`, with
|
| 97 |
+
BLEU-4, BERTScore and AlignScore. Few-shot demonstrations in the paper are drawn from the training sets of the
|
| 98 |
+
source datasets, which are not redistributed here. Code for the experiments, including the graph-aware
|
| 99 |
+
demonstration selection (AST-ICL), is at [github.com/aliwister/ast-icl](https://github.com/aliwister/ast-icl).
|
| 100 |
+
|
| 101 |
+
## Source datasets and licence
|
| 102 |
+
|
| 103 |
+
The queries and original questions come from [Spider](https://yale-lily.github.io/spider),
|
| 104 |
+
[SParC](https://yale-lily.github.io/sparc) and [CoSQL](https://yale-lily.github.io/cosql), all distributed
|
| 105 |
+
under CC BY-SA 4.0. This dataset is released under the same licence. Please also cite the source datasets
|
| 106 |
+
when using it.
|
| 107 |
+
|
| 108 |
+
## Citation
|
| 109 |
+
|
| 110 |
+
```bibtex
|
| 111 |
+
@inproceedings{al-lawati-etal-2025-semantic,
|
| 112 |
+
title = "Semantic Captioning: Benchmark Dataset and Graph-Aware Few-Shot In-Context Learning for {SQL}2{T}ext",
|
| 113 |
+
author = "Al Lawati, Ali and
|
| 114 |
+
Lucas, Jason and
|
| 115 |
+
Mitra, Prasenjit",
|
| 116 |
+
booktitle = "Proceedings of the 31st International Conference on Computational Linguistics",
|
| 117 |
+
month = jan,
|
| 118 |
+
year = "2025",
|
| 119 |
+
address = "Abu Dhabi, UAE",
|
| 120 |
+
publisher = "Association for Computational Linguistics",
|
| 121 |
+
url = "https://aclanthology.org/2025.coling-main.536/",
|
| 122 |
+
pages = "8026--8042"
|
| 123 |
+
}
|
| 124 |
+
```
|
cosql_s2t/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f832e30401761ad0fa5cf760c26691b604cec50e2188000d64622928543a1b0f
|
| 3 |
+
size 49561
|
sparc_s2t/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0fb6b27e6a26377079295dce6dbdaadd8c718f4f0cd93efcf6d39935d58d58ee
|
| 3 |
+
size 44995
|
spider_s2t/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:645d51adddf61a8f62afe24825dae5fd96f55233747c84bcfeb5586ac17ef451
|
| 3 |
+
size 45879
|