train-text2sql / README.md
Hyukkyu's picture
Card: documents cut to 1,024 reranker tokens when scored
5c2eea3 verified
|
Raw History Blame Contribute Delete
6.32 kB
---
pretty_name: Training · Gretel Synthetic Text-to-SQL
license: apache-2.0
language:
- en
multilinguality:
- monolingual
task_categories:
- text-retrieval
task_ids:
- document-retrieval
tags:
- train
- retrieval
- code
configs:
- config_name: corpus
data_files:
- split: train
path: corpus/train-*.parquet
- config_name: hard-negatives
data_files:
- split: train
path: hard-negatives/train-*.parquet
- config_name: qrels
data_files:
- split: train
path: qrels/train-*.parquet
- config_name: queries
data_files:
- split: train
path: queries/train-*.parquet
- config_name: teacher-scores
data_files:
- split: train
path: teacher-scores/train-*.parquet
---
# Gretel Synthetic Text-to-SQL — Training, unified schema
A seeded sample of [`gretelai/synthetic_text_to_sql`](https://huggingface.co/datasets/gretelai/synthetic_text_to_sql/tree/740ab236e64503fba51be1101df7a1be83bf455d), made into retrieval **training** pairs and reshaped into the strict schema shared by every dataset in this collection. One of the 15 domain sources (code, medical, science, finance, legal) added to the collection's general sources.
| | |
|---|---|
| Source | [`gretelai/synthetic_text_to_sql`](https://huggingface.co/datasets/gretelai/synthetic_text_to_sql/tree/740ab236e64503fba51be1101df7a1be83bf455d) @ `740ab236e645` |
| Task | question → schema and SQL |
| Domain · languages | code · eng |
| Queries / documents / qrels | 30,000 / 29,987 / 30,000 |
| Qrels per query | min 1 · mean 1.0 · max 1 |
| Score values | 2 ×30,000 (2: the first positive, 1: any other) |
| Layout | `queries` · `corpus` · `qrels` · `hard-negatives` · `teacher-scores`, split `train` |
| Splits | `corpus`: train · `hard-negatives`: train · `qrels`: train · `queries`: train · `teacher-scores`: train |
| Hard negatives | sources: `dense` · 2,970,047 rows |
| Teacher scores | `jinaai/jina-reranker-v3.5` · 3,000,047 rows (positives included) |
| Ids | `sha1(text)[:20]`; identical texts collapse to one document / query |
| License | `apache-2.0` |
## Schema
| config | columns | rules |
|---|---|---|
| `queries` | `id: string`, `text: string` | ids unique and non-empty; every query has ≥ 1 qrel |
| `corpus` | `id: string`, `title: string`, `text: string` | `title` is always present (`""` when the source has none) |
| `qrels` | `query-id: string`, `corpus-id: string`, `score: int32` | referential integrity to both tables; no duplicate pairs; no floats |
| `hard-negatives` | `query-id: string`, `corpus-id: string`, `rank: int32`, `source: string` | one row per negative; `(query-id, corpus-id, source)` unique; never a labelled positive of the same query |
| `teacher-scores` | `query-id: string`, `corpus-id: string`, `teacher: string`, `score: float32` | one row per scored pair (positives included); a row *means* scored — never a placeholder |
Files are Parquet, sorted by id, zstd-compressed, sharded at 500 MB. Every rule above is checked before publishing; `provenance.json` records the source revision, what changed, and the output file hashes.
## What changed from the source
- **sampled**: a seeded random sample (seed 1) of up to 30,000 pairs
- **reshaped**: the question (`sql_prompt`) is the query; the document is the schema (`sql_context`), a newline and the SQL (`sql`)
- **decontaminated (exact)**: a pair was dropped when its normalised query equals any evaluation query, or a positive equals a document of a test or dev corpus; a repeated query keeps its first pair
- **decontaminated (near-duplicates)**: 0 passages and 0 queries that nearly copy a text of an evaluation set (word 13-grams for passages, 8-grams for queries; at least half shared with one text of the 23 test corpora (BEIR, RTEB, LitSearch) and the 3 dev corpora) were removed, and with them 0 queries in total
- **text**: leading and trailing whitespace stripped; otherwise as converted above
- **ids** re-keyed to `sha1(text)[:20]`: 13 documents and 0 queries collapsed into identical texts
- added a `title` column filled with `""` (the source has none)
## Hard negatives and teacher scores
Filled by the owner's annotation pipeline (`annotation=jina35-u2`) for the `train` split of the
query set(s) below; queries without a labelled positive are left out.
- **Candidates**: dense retrieval with `jinaai/jina-embeddings-v5-text-small` over the full corpus to depth 1,000;
100 candidates per query drawn from the rank windows 1–30 (30), 31–100 (30), 101–300 (20), 301–1000 (20), the query's labelled positives excluded.
`rank` is the dense rank; `source` is `dense` for a mined row and `dataset` for a negative the source labels itself
(those are kept for every query of the split, sampled or not).
- **Teacher**: `jinaai/jina-reranker-v3.5`, listwise: a query's positive and all of its candidates are scored together in one
context of up to 32,768 tokens. `score` is the raw cosine score, one row per (query, positive) and per
(query, candidate); a labelled negative that was also mined is scored once. Every document was cut to its first
1,024 reranker tokens before scoring (`max_doc_tokens=1024`). No filtering is applied to the tables.
| configs | queries | hard negatives | teacher scores |
|---|---:|---:|---:|
| `hard-negatives` · `teacher-scores` | 30,000 (all) | 2,970,047 (2,970,047 dense) | 3,000,047 |
```python
from datasets import load_dataset
negatives = load_dataset("Hyukkyu/train-text2sql", "hard-negatives", split="train")
scores = load_dataset("Hyukkyu/train-text2sql", "teacher-scores", split="train")
```
## Load it
```python
from datasets import load_dataset
queries = load_dataset("Hyukkyu/train-text2sql", "queries", split="train")
corpus = load_dataset("Hyukkyu/train-text2sql", "corpus", split="train")
qrels = load_dataset("Hyukkyu/train-text2sql", "qrels", split="train")
negatives = load_dataset("Hyukkyu/train-text2sql", "hard-negatives", split="train")
scores = load_dataset("Hyukkyu/train-text2sql", "teacher-scores", split="train")
```
## License and attribution
The data is redistributed under the source's terms — `apache-2.0`. All credit belongs to the original authors; see the source repository (https://huggingface.co/datasets/gretelai/synthetic_text_to_sql). This repository is an independent repackaging.