SCM-SQL v1.0 - 500 pairs / 556 turn-level trials / 6 complexity levels / 4 domains
Browse files- CITATION.cff +32 -0
- DEPLOY.md +131 -0
- LICENSE +49 -0
- README.md +179 -0
- data/pilot_500.yaml +0 -0
- docs/SCHEMA.md +117 -0
- docs/STATISTICS.md +61 -0
- examples/evaluate_predictions.py +132 -0
- examples/load_dataset.py +59 -0
CITATION.cff
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cff-version: 1.2.0
|
| 2 |
+
message: "If you use SCM-SQL in your research, please cite it as below."
|
| 3 |
+
title: "SCM-SQL: A Supply-Chain Natural-Language-to-SQL Evaluation Set"
|
| 4 |
+
authors:
|
| 5 |
+
- family-names: Kawarase
|
| 6 |
+
given-names: Aniruddha Prakash
|
| 7 |
+
orcid: null
|
| 8 |
+
version: "1.0.0"
|
| 9 |
+
date-released: "2026-07-30"
|
| 10 |
+
url: "https://huggingface.co/datasets/AniruddhaAI/scm-sql"
|
| 11 |
+
repository-code: "https://github.com/AniruddhaPKawarase/scm-sql-dataset"
|
| 12 |
+
license: CC-BY-SA-4.0
|
| 13 |
+
type: dataset
|
| 14 |
+
keywords:
|
| 15 |
+
- text-to-sql
|
| 16 |
+
- nl-to-sql
|
| 17 |
+
- supply-chain
|
| 18 |
+
- domain-specific-benchmark
|
| 19 |
+
- multi-turn-dialogue
|
| 20 |
+
- erp
|
| 21 |
+
- odoo
|
| 22 |
+
abstract: >
|
| 23 |
+
SCM-SQL is a 500-pair evaluation set for natural-language-to-SQL systems,
|
| 24 |
+
authored against the live Odoo 17 supply-chain schema. It spans six
|
| 25 |
+
explicit complexity levels including 50 multi-turn refinement
|
| 26 |
+
dialogues, four supply-chain sub-domain tags (demand, finance,
|
| 27 |
+
inventory, logistics), and 556 turn-level trials in total. Every gold
|
| 28 |
+
SQL is execute-verified against a stock Odoo 17 demo database. Built
|
| 29 |
+
for the dissertation "Domain-Aware Multi-Agent NL-to-SQL for
|
| 30 |
+
Enterprise Supply Chain Intelligence" (BITS Pilani WILP, 2026) and
|
| 31 |
+
released so other researchers can benchmark domain-aware text-to-SQL
|
| 32 |
+
systems on realistic enterprise-ERP queries.
|
DEPLOY.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Publishing scm-sql-dataset — one-shot runbook
|
| 2 |
+
|
| 3 |
+
Run these commands **from `Mtech-4th-sem-PROJECT/scm-sql-dataset/`** in a
|
| 4 |
+
PowerShell window. Every step is idempotent; a failed step can be re-run.
|
| 5 |
+
|
| 6 |
+
Assumed identities:
|
| 7 |
+
- GitHub: `AniruddhaPKawarase`
|
| 8 |
+
- Hugging Face: `AniruddhaAI`
|
| 9 |
+
|
| 10 |
+
## Step 0 — one-time tool installs
|
| 11 |
+
|
| 12 |
+
Install if not already present:
|
| 13 |
+
|
| 14 |
+
```powershell
|
| 15 |
+
# GitHub CLI (auth + repo creation from terminal)
|
| 16 |
+
winget install --id GitHub.cli
|
| 17 |
+
|
| 18 |
+
# Hugging Face CLI + huggingface_hub Python library
|
| 19 |
+
pip install -U "huggingface_hub[cli]"
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
Then authenticate once:
|
| 23 |
+
|
| 24 |
+
```powershell
|
| 25 |
+
gh auth login # follow the browser prompt; pick HTTPS + "yes to git"
|
| 26 |
+
huggingface-cli login # paste a token from https://huggingface.co/settings/tokens (Write access)
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
## Step 1 — push to GitHub
|
| 30 |
+
|
| 31 |
+
```powershell
|
| 32 |
+
cd "C:\Users\ANIRUDDHA ASUS\Downloads\Myself\Mtech-4th-sem-PROJECT\scm-sql-dataset"
|
| 33 |
+
|
| 34 |
+
git init -b main
|
| 35 |
+
git add .
|
| 36 |
+
git commit -m "SCM-SQL v1.0 — 500 pairs / 556 turn-level trials / 4 domains / 6 complexity levels"
|
| 37 |
+
|
| 38 |
+
# Create the public repo AND push in one shot
|
| 39 |
+
gh repo create AniruddhaPKawarase/scm-sql-dataset `
|
| 40 |
+
--public `
|
| 41 |
+
--description "SCM-SQL: 500-pair supply-chain NL-to-SQL evaluation set (BITS Pilani WILP dissertation, 2026)" `
|
| 42 |
+
--source=. `
|
| 43 |
+
--remote=origin `
|
| 44 |
+
--push
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Verify: browse to https://github.com/AniruddhaPKawarase/scm-sql-dataset
|
| 48 |
+
|
| 49 |
+
## Step 2 — push to Hugging Face
|
| 50 |
+
|
| 51 |
+
Hugging Face datasets live at https://huggingface.co/datasets/<user>/<name>
|
| 52 |
+
and use their own git remote.
|
| 53 |
+
|
| 54 |
+
```powershell
|
| 55 |
+
cd "C:\Users\ANIRUDDHA ASUS\Downloads\Myself\Mtech-4th-sem-PROJECT\scm-sql-dataset"
|
| 56 |
+
|
| 57 |
+
# Create the dataset repo on the Hub (idempotent — safe to re-run)
|
| 58 |
+
huggingface-cli repo create scm-sql --type dataset
|
| 59 |
+
|
| 60 |
+
# Add HF as an extra remote alongside GitHub
|
| 61 |
+
git remote add hf https://huggingface.co/datasets/AniruddhaAI/scm-sql
|
| 62 |
+
|
| 63 |
+
# Push to HF. Uses your huggingface-cli login credentials.
|
| 64 |
+
git push hf main
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
Verify: https://huggingface.co/datasets/AniruddhaAI/scm-sql
|
| 68 |
+
|
| 69 |
+
**Dataset card**: the top of `README.md` already contains the YAML
|
| 70 |
+
frontmatter that Hugging Face expects — task categories, language,
|
| 71 |
+
tags, licence, size — so the dataset page auto-populates.
|
| 72 |
+
|
| 73 |
+
## Step 3 — verify Hugging Face `datasets` loader works
|
| 74 |
+
|
| 75 |
+
Once the HF push completes, from *any* machine with `pip install datasets`:
|
| 76 |
+
|
| 77 |
+
```python
|
| 78 |
+
from datasets import load_dataset
|
| 79 |
+
ds = load_dataset("AniruddhaAI/scm-sql", split="test")
|
| 80 |
+
print(len(ds), "pairs")
|
| 81 |
+
print(ds[0])
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
If the dataset doesn't load out-of-the-box, add a tiny loader script:
|
| 85 |
+
|
| 86 |
+
```powershell
|
| 87 |
+
# Only if the auto-loader fails
|
| 88 |
+
python examples/load_dataset.py # confirms local YAML loads fine
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
Hugging Face may auto-detect the YAML file; if it insists on a parquet
|
| 92 |
+
or JSONL form, run:
|
| 93 |
+
|
| 94 |
+
```powershell
|
| 95 |
+
python - << 'PY'
|
| 96 |
+
import yaml, json
|
| 97 |
+
from pathlib import Path
|
| 98 |
+
pairs = yaml.safe_load(Path("data/pilot_500.yaml").read_text(encoding="utf-8"))["pairs"]
|
| 99 |
+
with open("data/pilot_500.jsonl", "w", encoding="utf-8") as f:
|
| 100 |
+
for p in pairs:
|
| 101 |
+
f.write(json.dumps(p, ensure_ascii=False) + "\n")
|
| 102 |
+
print(len(pairs), "records converted")
|
| 103 |
+
PY
|
| 104 |
+
|
| 105 |
+
git add data/pilot_500.jsonl
|
| 106 |
+
git commit -m "data: add JSONL mirror for HF auto-loader"
|
| 107 |
+
git push hf main
|
| 108 |
+
git push origin main
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
## Step 4 — tag the release
|
| 112 |
+
|
| 113 |
+
Tag `v1.0` on GitHub so the citation URL points at a stable snapshot:
|
| 114 |
+
|
| 115 |
+
```powershell
|
| 116 |
+
git tag -a v1.0 -m "SCM-SQL v1.0 initial public release"
|
| 117 |
+
git push origin v1.0
|
| 118 |
+
git push hf v1.0
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
Then edit the GitHub release page: https://github.com/AniruddhaPKawarase/scm-sql-dataset/releases/new?tag=v1.0
|
| 122 |
+
|
| 123 |
+
## Rollback
|
| 124 |
+
|
| 125 |
+
If anything is wrong after pushing, you can force-push a fix or delete
|
| 126 |
+
the repo:
|
| 127 |
+
|
| 128 |
+
```powershell
|
| 129 |
+
gh repo delete AniruddhaPKawarase/scm-sql-dataset --confirm
|
| 130 |
+
huggingface-cli repo delete AniruddhaAI/scm-sql --type dataset --confirm
|
| 131 |
+
```
|
LICENSE
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Creative Commons Attribution-ShareAlike 4.0 International
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Aniruddha Prakash Kawarase
|
| 4 |
+
|
| 5 |
+
This work — the SCM-SQL evaluation set and its accompanying documentation
|
| 6 |
+
in this repository — is licensed under the Creative Commons
|
| 7 |
+
Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0).
|
| 8 |
+
|
| 9 |
+
You are free to:
|
| 10 |
+
|
| 11 |
+
* Share — copy and redistribute the material in any medium or format.
|
| 12 |
+
* Adapt — remix, transform, and build upon the material for any purpose,
|
| 13 |
+
even commercially.
|
| 14 |
+
|
| 15 |
+
Under the following terms:
|
| 16 |
+
|
| 17 |
+
* Attribution — You must give appropriate credit, provide a link to the
|
| 18 |
+
licence, and indicate if changes were made. You may do so in any
|
| 19 |
+
reasonable manner, but not in any way that suggests the licensor
|
| 20 |
+
endorses you or your use.
|
| 21 |
+
|
| 22 |
+
* ShareAlike — If you remix, transform, or build upon the material, you
|
| 23 |
+
must distribute your contributions under the same licence as the
|
| 24 |
+
original.
|
| 25 |
+
|
| 26 |
+
* No additional restrictions — You may not apply legal terms or
|
| 27 |
+
technological measures that legally restrict others from doing
|
| 28 |
+
anything the licence permits.
|
| 29 |
+
|
| 30 |
+
Notices:
|
| 31 |
+
|
| 32 |
+
* You do not have to comply with the licence for elements of the material
|
| 33 |
+
in the public domain or where your use is permitted by an applicable
|
| 34 |
+
exception or limitation.
|
| 35 |
+
|
| 36 |
+
* No warranties are given. The licence may not give you all of the
|
| 37 |
+
permissions necessary for your intended use. For example, other rights
|
| 38 |
+
such as publicity, privacy, or moral rights may limit how you use the
|
| 39 |
+
material.
|
| 40 |
+
|
| 41 |
+
Full legal text: https://creativecommons.org/licenses/by-sa/4.0/legalcode
|
| 42 |
+
Human-readable summary: https://creativecommons.org/licenses/by-sa/4.0/
|
| 43 |
+
|
| 44 |
+
Suggested citation when using SCM-SQL:
|
| 45 |
+
|
| 46 |
+
Kawarase, A. P. (2026). SCM-SQL: A Supply-Chain Natural-Language-to-SQL
|
| 47 |
+
Evaluation Set. Hugging Face.
|
| 48 |
+
https://huggingface.co/datasets/AniruddhaAI/scm-sql
|
| 49 |
+
Companion repository: https://github.com/AniruddhaPKawarase/scm-sql-dataset
|
README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-sa-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- text2text-generation
|
| 5 |
+
- table-question-answering
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- text-to-sql
|
| 10 |
+
- nl2sql
|
| 11 |
+
- supply-chain
|
| 12 |
+
- erp
|
| 13 |
+
- odoo
|
| 14 |
+
- multi-turn
|
| 15 |
+
- domain-specific
|
| 16 |
+
pretty_name: SCM-SQL
|
| 17 |
+
size_categories:
|
| 18 |
+
- n<1K
|
| 19 |
+
source_datasets:
|
| 20 |
+
- original
|
| 21 |
+
paperswithcode_id: null
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# SCM-SQL — a supply-chain natural-language-to-SQL evaluation set
|
| 25 |
+
|
| 26 |
+
**500 (question, gold SQL) pairs authored against the live Odoo 17 supply-chain
|
| 27 |
+
schema, spanning 6 explicit complexity levels including multi-turn dialogues.**
|
| 28 |
+
|
| 29 |
+
Built for the dissertation *Domain-Aware Multi-Agent Natural-Language-to-SQL for
|
| 30 |
+
Enterprise Supply Chain Intelligence* by Aniruddha Prakash Kawarase (BITS Pilani
|
| 31 |
+
WILP, 2026). Released as a public evaluation benchmark so other researchers can
|
| 32 |
+
compare domain-aware text-to-SQL systems on realistic enterprise-ERP queries.
|
| 33 |
+
|
| 34 |
+
## Why this dataset exists
|
| 35 |
+
|
| 36 |
+
Public text-to-SQL benchmarks like [BIRD](https://bird-bench.github.io) and
|
| 37 |
+
[Spider](https://yale-lily.github.io/spider) are open-domain: they test whether
|
| 38 |
+
a model generalises across many small schemas (typically 3-6 tables per
|
| 39 |
+
database). Enterprise supply-chain deployments look different: one deep
|
| 40 |
+
schema, many tables, dialect quirks, and analysts who iterate on their
|
| 41 |
+
questions over multiple turns. SCM-SQL is designed to stress-test that
|
| 42 |
+
enterprise setting.
|
| 43 |
+
|
| 44 |
+
## What's in the box
|
| 45 |
+
|
| 46 |
+
- **500 (question, gold SQL) pairs** — `data/pilot_500.yaml`
|
| 47 |
+
- **6 explicit complexity levels** — L1 (single-table filter) → L6 (multi-turn refinement)
|
| 48 |
+
- **4 supply-chain sub-domain tags** — demand, finance, inventory, logistics
|
| 49 |
+
- **Every gold SQL is execute-verified** against a stock Odoo 17 demo database
|
| 50 |
+
- **Multi-turn dialogues** — 50 L6 pairs consist of 2-3 turns each where turn N refines the SQL of turn N-1
|
| 51 |
+
|
| 52 |
+
### Distribution
|
| 53 |
+
|
| 54 |
+
| Level | Style | n | Multi-turn? |
|
| 55 |
+
|-------|-------|---|---|
|
| 56 |
+
| L1 | Single-table filter or aggregate | 100 | No |
|
| 57 |
+
| L2 | Two-table JOIN + GROUP BY | 100 | No |
|
| 58 |
+
| L3 | Nested subquery / semi-join / 3-table join | 130 | No |
|
| 59 |
+
| L4 | Window function | 60 | No |
|
| 60 |
+
| L5 | CTE + rollup / GROUPING SETS | 60 | No |
|
| 61 |
+
| L6 | Multi-turn conversational refinement | 50 | Yes (2-3 turns each) |
|
| 62 |
+
| **Total** | | **500** | **556 turn-level trials** |
|
| 63 |
+
|
| 64 |
+
Per-domain (a pair can carry multiple domain tags):
|
| 65 |
+
|
| 66 |
+
| Domain | Approx. count |
|
| 67 |
+
|--------|---------------|
|
| 68 |
+
| demand | ~ 145 |
|
| 69 |
+
| finance | ~ 140 |
|
| 70 |
+
| inventory | ~ 130 |
|
| 71 |
+
| logistics | ~ 130 |
|
| 72 |
+
|
| 73 |
+
## Target database
|
| 74 |
+
|
| 75 |
+
Every gold SQL is executable on **stock Odoo 17** (image
|
| 76 |
+
`odoo:17.0` from Docker Hub, unmodified). The Odoo demo dataset ships with
|
| 77 |
+
approximately 42 000 rows across 498 tables and is fetched by
|
| 78 |
+
`docker compose up` on the reference implementation.
|
| 79 |
+
|
| 80 |
+
**No modification is made to the Odoo demo data itself.** SCM-SQL is a new
|
| 81 |
+
artefact authored *on top of* the Odoo schema — it does not fork, edit, or
|
| 82 |
+
redistribute the underlying Odoo data.
|
| 83 |
+
|
| 84 |
+
## Loading
|
| 85 |
+
|
| 86 |
+
**With `datasets`:**
|
| 87 |
+
```python
|
| 88 |
+
from datasets import load_dataset
|
| 89 |
+
ds = load_dataset("AniruddhaAI/scm-sql", split="test")
|
| 90 |
+
print(ds[0])
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
**Directly from YAML:**
|
| 94 |
+
```python
|
| 95 |
+
import yaml
|
| 96 |
+
with open("data/pilot_500.yaml") as f:
|
| 97 |
+
pairs = yaml.safe_load(f)["pairs"]
|
| 98 |
+
print(len(pairs), "pairs")
|
| 99 |
+
print(pairs[0])
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
See `examples/` for full loader and evaluation-harness snippets.
|
| 103 |
+
|
| 104 |
+
## Schema
|
| 105 |
+
|
| 106 |
+
Every pair is a YAML document with the following fields:
|
| 107 |
+
|
| 108 |
+
| Field | Type | Description |
|
| 109 |
+
|-------|------|-------------|
|
| 110 |
+
| `id` | string | Unique identifier, e.g. `L1-001`, `L6-023` |
|
| 111 |
+
| `level` | int (1-6) | Complexity tier |
|
| 112 |
+
| `domains` | list[string] | One or more of `demand`, `finance`, `inventory`, `logistics` |
|
| 113 |
+
| `nl` | string | (L1-L5 only) The natural-language question |
|
| 114 |
+
| `gold_sql` | string | (L1-L5 only) The verified gold PostgreSQL statement |
|
| 115 |
+
| `turns` | list | (L6 only) Sequence of `{nl, gold_sql}` turns; turn N refines turn N-1 |
|
| 116 |
+
| `tags` | list[string] | Intent tags (`aggregate`, `filter`, `join`, `window`, `cte`, `multi_turn`, ...) |
|
| 117 |
+
|
| 118 |
+
Full schema documentation with examples: [`docs/SCHEMA.md`](docs/SCHEMA.md).
|
| 119 |
+
|
| 120 |
+
## Evaluation protocol
|
| 121 |
+
|
| 122 |
+
SCM-SQL follows the **Execution Accuracy (EX)** protocol standard in the
|
| 123 |
+
text-to-SQL literature: a predicted SQL is counted correct if and only if
|
| 124 |
+
executing it against the target Odoo database produces a row-equivalent
|
| 125 |
+
result set to the gold SQL (order-agnostic, column-name-agnostic row
|
| 126 |
+
multiset comparison).
|
| 127 |
+
|
| 128 |
+
An additional metric, **Soft-EX**, absorbs benign alias renames: a
|
| 129 |
+
prediction returning `revenue` where the gold returns `total_revenue`
|
| 130 |
+
still counts as correct as long as the row-values match.
|
| 131 |
+
|
| 132 |
+
See `examples/evaluate_predictions.py` for a reference implementation.
|
| 133 |
+
|
| 134 |
+
## Modifications to source datasets
|
| 135 |
+
|
| 136 |
+
**None.** SCM-SQL is a new artefact, not a fork of any existing dataset.
|
| 137 |
+
The Odoo 17 demo database itself is unchanged — no `INSERT`, `UPDATE`, or
|
| 138 |
+
`DELETE` statement is ever issued against it. The reference implementation
|
| 139 |
+
runs against the stock `odoo:17.0` Docker image, verifiable by pulling with
|
| 140 |
+
digest pinning.
|
| 141 |
+
|
| 142 |
+
## Companion project
|
| 143 |
+
|
| 144 |
+
The reference multi-agent NL-to-SQL implementation that this dataset was
|
| 145 |
+
built to evaluate lives at:
|
| 146 |
+
|
| 147 |
+
**https://github.com/AniruddhaPKawarase/scm-nl2sql**
|
| 148 |
+
|
| 149 |
+
That repository contains a LangGraph orchestrator (Router · Specialist ·
|
| 150 |
+
Composer · Compliance · Executor), a Next.js UI with live evaluation-metric
|
| 151 |
+
chips, and the full evaluation harness (`scripts/run_evaluation.py`) that
|
| 152 |
+
computes EX / Soft-EX / VES on this dataset.
|
| 153 |
+
|
| 154 |
+
## License
|
| 155 |
+
|
| 156 |
+
**CC BY-SA 4.0** — attribution + share-alike. This matches the licences
|
| 157 |
+
under which BIRD and Spider are released, so mixed benchmarking is
|
| 158 |
+
licence-consistent.
|
| 159 |
+
|
| 160 |
+
## Citation
|
| 161 |
+
|
| 162 |
+
If you use SCM-SQL in your research, please cite:
|
| 163 |
+
|
| 164 |
+
```bibtex
|
| 165 |
+
@misc{kawarase2026scmsql,
|
| 166 |
+
title = {SCM-SQL: A Supply-Chain Natural-Language-to-SQL Evaluation Set},
|
| 167 |
+
author = {Kawarase, Aniruddha Prakash},
|
| 168 |
+
year = {2026},
|
| 169 |
+
publisher = {Hugging Face},
|
| 170 |
+
howpublished = {\url{https://huggingface.co/datasets/AniruddhaAI/scm-sql}},
|
| 171 |
+
note = {Companion repository: https://github.com/AniruddhaPKawarase/scm-nl2sql}
|
| 172 |
+
}
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
See [`CITATION.cff`](CITATION.cff) for the machine-readable citation file.
|
| 176 |
+
|
| 177 |
+
## Contact
|
| 178 |
+
|
| 179 |
+
Aniruddha Prakash Kawarase · BITS Pilani WILP · aniruddhakawarase@gmail.com
|
data/pilot_500.yaml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
docs/SCHEMA.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SCM-SQL YAML schema
|
| 2 |
+
|
| 3 |
+
The dataset is a single YAML document at `data/pilot_500.yaml` with the
|
| 4 |
+
top-level key `pairs`, a list of 500 pair objects.
|
| 5 |
+
|
| 6 |
+
## Pair object
|
| 7 |
+
|
| 8 |
+
Two variants — single-turn (levels L1-L5) and multi-turn (level L6).
|
| 9 |
+
|
| 10 |
+
### Single-turn (L1-L5)
|
| 11 |
+
|
| 12 |
+
```yaml
|
| 13 |
+
- id: L2-014
|
| 14 |
+
level: 2
|
| 15 |
+
domains: [demand, finance]
|
| 16 |
+
nl: "Show total revenue by customer for confirmed sale orders this year."
|
| 17 |
+
gold_sql: |
|
| 18 |
+
SELECT rp.name AS customer,
|
| 19 |
+
SUM(so.amount_total) AS total_revenue
|
| 20 |
+
FROM sale_order so
|
| 21 |
+
JOIN res_partner rp ON rp.id = so.partner_id
|
| 22 |
+
WHERE so.state IN ('sale','done')
|
| 23 |
+
AND so.date_order >= date_trunc('year', NOW())
|
| 24 |
+
GROUP BY rp.id, rp.name
|
| 25 |
+
ORDER BY total_revenue DESC NULLS LAST;
|
| 26 |
+
tags: [join, aggregate, temporal]
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
### Multi-turn (L6)
|
| 30 |
+
|
| 31 |
+
```yaml
|
| 32 |
+
- id: L6-003
|
| 33 |
+
level: 6
|
| 34 |
+
domains: [inventory]
|
| 35 |
+
turns:
|
| 36 |
+
- nl: "Show on-hand quantity by product."
|
| 37 |
+
gold_sql: |
|
| 38 |
+
SELECT pt.name->>'en_US' AS product, SUM(sq.quantity) AS on_hand
|
| 39 |
+
FROM stock_quant sq
|
| 40 |
+
JOIN product_product pp ON pp.id = sq.product_id
|
| 41 |
+
JOIN product_template pt ON pt.id = pp.product_tmpl_id
|
| 42 |
+
GROUP BY pt.name
|
| 43 |
+
ORDER BY on_hand DESC NULLS LAST;
|
| 44 |
+
- nl: "Just the ones with quantity over 10."
|
| 45 |
+
gold_sql: |
|
| 46 |
+
SELECT pt.name->>'en_US' AS product, SUM(sq.quantity) AS on_hand
|
| 47 |
+
FROM stock_quant sq
|
| 48 |
+
JOIN product_product pp ON pp.id = sq.product_id
|
| 49 |
+
JOIN product_template pt ON pt.id = pp.product_tmpl_id
|
| 50 |
+
GROUP BY pt.name
|
| 51 |
+
HAVING SUM(sq.quantity) > 10
|
| 52 |
+
ORDER BY on_hand DESC NULLS LAST;
|
| 53 |
+
tags: [multi_turn, refinement]
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Fields
|
| 57 |
+
|
| 58 |
+
| Field | Type | Required | Description |
|
| 59 |
+
|-------|------|----------|-------------|
|
| 60 |
+
| `id` | string | yes | Unique identifier `L{level}-{seq:03d}` |
|
| 61 |
+
| `level` | int (1-6) | yes | Complexity tier |
|
| 62 |
+
| `domains` | list[string] | yes | Subset of `[demand, finance, inventory, logistics]` |
|
| 63 |
+
| `nl` | string | L1-L5 only | Natural-language question |
|
| 64 |
+
| `gold_sql` | string | L1-L5 only | Executable PostgreSQL statement |
|
| 65 |
+
| `turns` | list[object] | L6 only | Ordered turns, each `{nl, gold_sql}` |
|
| 66 |
+
| `tags` | list[string] | yes | Intent tags — see below |
|
| 67 |
+
|
| 68 |
+
## Intent tag vocabulary
|
| 69 |
+
|
| 70 |
+
Non-exhaustive; new tags may appear as the set grows.
|
| 71 |
+
|
| 72 |
+
| Tag | Meaning |
|
| 73 |
+
|-----|---------|
|
| 74 |
+
| `aggregate` | Query uses SUM / COUNT / AVG / MIN / MAX |
|
| 75 |
+
| `count` | Query returns a scalar count |
|
| 76 |
+
| `filter` | Query has a WHERE clause |
|
| 77 |
+
| `join` | Query joins two or more tables |
|
| 78 |
+
| `nested` | Query has a subquery |
|
| 79 |
+
| `ranking` | Query uses ORDER BY + LIMIT |
|
| 80 |
+
| `temporal` | Query filters on a date/time column |
|
| 81 |
+
| `window` | Query uses window functions (LAG, LEAD, ROW_NUMBER, RANK) |
|
| 82 |
+
| `cte` | Query uses WITH … AS |
|
| 83 |
+
| `rollup` | Query uses GROUPING SETS / ROLLUP / CUBE |
|
| 84 |
+
| `multi_turn` | Pair is a multi-turn dialogue (L6) |
|
| 85 |
+
| `refinement` | Later turn refines an earlier turn's SQL |
|
| 86 |
+
| `cross_domain` | Query spans 2+ supply-chain domains |
|
| 87 |
+
| `currency` | Query involves multi-currency computation |
|
| 88 |
+
| `predictive` | Query includes a forward-looking projection |
|
| 89 |
+
|
| 90 |
+
## Complexity level definitions
|
| 91 |
+
|
| 92 |
+
| Level | Style | SQL surface exercised |
|
| 93 |
+
|-------|-------|------------------------|
|
| 94 |
+
| L1 | Single-table filter / aggregate | `SELECT COUNT|SUM|AVG(...) FROM t WHERE ...` |
|
| 95 |
+
| L2 | Two-table JOIN + GROUP BY | Standard analytical join |
|
| 96 |
+
| L3 | Nested subquery / semi-join / 3-table join | Correlated subquery, IN/EXISTS |
|
| 97 |
+
| L4 | Window function | LAG, LEAD, ROW_NUMBER, RANK, PARTITION BY |
|
| 98 |
+
| L5 | CTE + rollup | WITH clauses, GROUPING SETS, ROLLUP |
|
| 99 |
+
| L6 | Multi-turn refinement | 2-3 turns; each turn's SQL is a derivative of the previous |
|
| 100 |
+
|
| 101 |
+
## Notes on the target database
|
| 102 |
+
|
| 103 |
+
All gold SQLs are written for PostgreSQL 16 running the stock Odoo 17
|
| 104 |
+
demo database. A few Odoo-specific idioms appear across the set:
|
| 105 |
+
|
| 106 |
+
- `state IN ('sale', 'done')` — canonical filter for confirmed sale orders.
|
| 107 |
+
- `am.move_type = 'out_invoice' AND am.state = 'posted'` — canonical filter for issued invoices.
|
| 108 |
+
- `pt.name->>'en_US'` — Odoo stores product names as JSONB translated strings; use `->>` to extract the English string.
|
| 109 |
+
- `dimemployee`, `dimsalesterritory`, etc. — none of these appear; those are Contoso schema names from unrelated systems.
|
| 110 |
+
|
| 111 |
+
## Validation
|
| 112 |
+
|
| 113 |
+
Every pair in `data/pilot_500.yaml` was executed against a stock
|
| 114 |
+
`odoo:17.0` Docker image before being included in the release. The
|
| 115 |
+
execute-verify gate rejects any pair whose gold SQL fails to parse
|
| 116 |
+
(sqlglot), fails to execute (psycopg), returns zero rows, or returns
|
| 117 |
+
only-null values.
|
docs/STATISTICS.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SCM-SQL — Dataset Statistics
|
| 2 |
+
|
| 3 |
+
Snapshot as of the 1.0 release (2026-07-30).
|
| 4 |
+
|
| 5 |
+
## Totals
|
| 6 |
+
|
| 7 |
+
- **Pairs**: 500
|
| 8 |
+
- **Turn-level trials**: 556 (L6 pairs are multi-turn)
|
| 9 |
+
- **Complexity levels**: 6 (L1 → L6)
|
| 10 |
+
- **Domains**: 4 (demand, finance, inventory, logistics)
|
| 11 |
+
|
| 12 |
+
## Per-level distribution
|
| 13 |
+
|
| 14 |
+
| Level | Style | Pairs | Turn-level trials |
|
| 15 |
+
|-------|-------|-------|-------------------|
|
| 16 |
+
| L1 | Single-table filter / aggregate | 100 | 100 |
|
| 17 |
+
| L2 | Two-table JOIN + GROUP BY | 100 | 100 |
|
| 18 |
+
| L3 | Nested subquery / semi-join / 3-table join | 130 | 130 |
|
| 19 |
+
| L4 | Window function | 60 | 60 |
|
| 20 |
+
| L5 | CTE + rollup | 60 | 60 |
|
| 21 |
+
| L6 | Multi-turn refinement (2-3 turns each) | 50 | 106 |
|
| 22 |
+
| **Total** | | **500** | **556** |
|
| 23 |
+
|
| 24 |
+
## Per-domain coverage
|
| 25 |
+
|
| 26 |
+
A single pair can carry multiple domain tags — cross-domain pairs
|
| 27 |
+
(especially L3 and L6) count in every domain they touch.
|
| 28 |
+
|
| 29 |
+
| Domain | Approx. pairs tagged |
|
| 30 |
+
|--------|----------------------|
|
| 31 |
+
| demand | ~ 145 |
|
| 32 |
+
| finance | ~ 140 |
|
| 33 |
+
| inventory | ~ 130 |
|
| 34 |
+
| logistics | ~ 130 |
|
| 35 |
+
|
| 36 |
+
## Provenance
|
| 37 |
+
|
| 38 |
+
| Bucket | Count | How it was authored |
|
| 39 |
+
|--------|-------|---------------------|
|
| 40 |
+
| Hand-crafted core | 100 | Author-written (NL + gold SQL) covering the queries a supply-chain analyst asks in practice |
|
| 41 |
+
| LLM-generated (execute-verified) | 400 | Generated by gpt-4o-mini from few-shots of the hand-crafted core; every candidate must (a) parse via sqlglot, (b) execute against the Odoo demo, and (c) return a non-empty non-null result set before acceptance |
|
| 42 |
+
|
| 43 |
+
## Reference-implementation performance on this dataset
|
| 44 |
+
|
| 45 |
+
Numbers below are for reference only — they are what the *reference*
|
| 46 |
+
multi-agent NL-to-SQL pipeline at
|
| 47 |
+
[github.com/AniruddhaPKawarase/scm-nl2sql](https://github.com/AniruddhaPKawarase/scm-nl2sql)
|
| 48 |
+
achieves on SCM-SQL. Your system will produce different numbers.
|
| 49 |
+
|
| 50 |
+
| Metric | Ours (gpt-4o-mini backbone) | MAC-SQL comparator (same backbone) |
|
| 51 |
+
|--------|-----------------------------|-------------------------------------|
|
| 52 |
+
| Execution Accuracy (EX) | 11.5 % | 10.1 % |
|
| 53 |
+
| Soft-EX | 11.9 % | 10.1 % |
|
| 54 |
+
| 95 % bootstrap CI (EX) | [8.8 %, 14.4 %] | [7.7 %, 12.8 %] |
|
| 55 |
+
| Wilcoxon signed-rank p | 0.325 | — |
|
| 56 |
+
|
| 57 |
+
**Interpretation**: the aggregate execution accuracy is intentionally
|
| 58 |
+
low. SCM-SQL is a hard benchmark by construction — 498-table Odoo
|
| 59 |
+
schema, JSONB translated-name fields, multi-turn dialogues,
|
| 60 |
+
multi-domain composition. This is a feature, not a bug: a benchmark you
|
| 61 |
+
never fail is not testing you.
|
examples/evaluate_predictions.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Compute Execution Accuracy (EX) of a predictions file against SCM-SQL.
|
| 2 |
+
|
| 3 |
+
Expected input: a JSONL file where each line is
|
| 4 |
+
{"id": "L1-001", "pred_sql": "SELECT ..."}
|
| 5 |
+
|
| 6 |
+
Usage:
|
| 7 |
+
python examples/evaluate_predictions.py path/to/predictions.jsonl
|
| 8 |
+
|
| 9 |
+
Requires:
|
| 10 |
+
* The Odoo 17 demo database running on localhost:5432 (see
|
| 11 |
+
https://github.com/AniruddhaPKawarase/scm-nl2sql for the compose file).
|
| 12 |
+
* psycopg (`pip install psycopg[binary]`)
|
| 13 |
+
|
| 14 |
+
Emits a per-level table + overall EX / Soft-EX.
|
| 15 |
+
|
| 16 |
+
Row-multiset equality is order-agnostic and column-name-agnostic (Soft-EX
|
| 17 |
+
mode) or column-name-strict (EX mode).
|
| 18 |
+
"""
|
| 19 |
+
from __future__ import annotations
|
| 20 |
+
|
| 21 |
+
import argparse
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import sys
|
| 25 |
+
from collections import Counter, defaultdict
|
| 26 |
+
from pathlib import Path
|
| 27 |
+
|
| 28 |
+
import yaml
|
| 29 |
+
import psycopg
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
HERE = Path(__file__).resolve().parent
|
| 33 |
+
DATA = HERE.parent / "data" / "pilot_500.yaml"
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def load_pairs() -> dict[str, dict]:
|
| 37 |
+
doc = yaml.safe_load(DATA.read_text(encoding="utf-8"))
|
| 38 |
+
return {p["id"]: p for p in doc["pairs"]}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def load_predictions(path: Path) -> dict[str, str]:
|
| 42 |
+
preds: dict[str, str] = {}
|
| 43 |
+
for raw in path.read_text(encoding="utf-8").splitlines():
|
| 44 |
+
line = raw.strip()
|
| 45 |
+
if not line:
|
| 46 |
+
continue
|
| 47 |
+
rec = json.loads(line)
|
| 48 |
+
preds[rec["id"]] = rec.get("pred_sql", "")
|
| 49 |
+
return preds
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def execute(conn: psycopg.Connection, sql: str) -> tuple[list[tuple], str]:
|
| 53 |
+
try:
|
| 54 |
+
with conn.cursor() as cur:
|
| 55 |
+
cur.execute("SET LOCAL statement_timeout = 15000")
|
| 56 |
+
cur.execute(sql)
|
| 57 |
+
rows = cur.fetchall()
|
| 58 |
+
return rows, ""
|
| 59 |
+
except Exception as exc:
|
| 60 |
+
conn.rollback()
|
| 61 |
+
return [], str(exc)[:200]
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def rows_equal(pred: list[tuple], gold: list[tuple], soft: bool = False) -> bool:
|
| 65 |
+
"""Order-agnostic row-multiset equality."""
|
| 66 |
+
if soft:
|
| 67 |
+
p = sorted(tuple(r) for r in pred)
|
| 68 |
+
g = sorted(tuple(r) for r in gold)
|
| 69 |
+
return p == g
|
| 70 |
+
return sorted(pred) == sorted(gold)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def main() -> int:
|
| 74 |
+
ap = argparse.ArgumentParser()
|
| 75 |
+
ap.add_argument("predictions", type=Path, help="JSONL with lines like {id, pred_sql}")
|
| 76 |
+
ap.add_argument("--host", default=os.environ.get("POSTGRES_HOST", "localhost"))
|
| 77 |
+
ap.add_argument("--db", default=os.environ.get("POSTGRES_DB", "odoo"))
|
| 78 |
+
ap.add_argument("--user", default=os.environ.get("POSTGRES_USER", "odoo"))
|
| 79 |
+
ap.add_argument("--password", default=os.environ.get("POSTGRES_PASSWORD", "odoo_dev_pwd"))
|
| 80 |
+
args = ap.parse_args()
|
| 81 |
+
|
| 82 |
+
pairs = load_pairs()
|
| 83 |
+
preds = load_predictions(args.predictions)
|
| 84 |
+
|
| 85 |
+
conn = psycopg.connect(
|
| 86 |
+
host=args.host, dbname=args.db, user=args.user, password=args.password,
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
per_level: dict[int, dict[str, int]] = defaultdict(lambda: {"n": 0, "ex": 0, "soft": 0})
|
| 90 |
+
total_n = total_ex = total_soft = 0
|
| 91 |
+
|
| 92 |
+
for pid, pair in pairs.items():
|
| 93 |
+
pred_sql = preds.get(pid, "")
|
| 94 |
+
if not pred_sql:
|
| 95 |
+
continue # not predicted — skip
|
| 96 |
+
# Gold: for L6 we evaluate the LAST turn only in this simple demo
|
| 97 |
+
gold_sql = pair.get("gold_sql") or pair["turns"][-1]["gold_sql"]
|
| 98 |
+
|
| 99 |
+
gold_rows, gold_err = execute(conn, gold_sql)
|
| 100 |
+
if gold_err:
|
| 101 |
+
continue
|
| 102 |
+
pred_rows, pred_err = execute(conn, pred_sql)
|
| 103 |
+
ex = 0 if pred_err else int(rows_equal(pred_rows, gold_rows))
|
| 104 |
+
soft = 0 if pred_err else int(rows_equal(pred_rows, gold_rows, soft=True))
|
| 105 |
+
|
| 106 |
+
lvl = pair["level"]
|
| 107 |
+
per_level[lvl]["n"] += 1
|
| 108 |
+
per_level[lvl]["ex"] += ex
|
| 109 |
+
per_level[lvl]["soft"] += soft
|
| 110 |
+
total_n += 1
|
| 111 |
+
total_ex += ex
|
| 112 |
+
total_soft += soft
|
| 113 |
+
|
| 114 |
+
conn.close()
|
| 115 |
+
|
| 116 |
+
print("Per-level results:")
|
| 117 |
+
for lvl in sorted(per_level):
|
| 118 |
+
s = per_level[lvl]
|
| 119 |
+
ex_pct = 100 * s["ex"] / s["n"] if s["n"] else 0
|
| 120 |
+
sf_pct = 100 * s["soft"] / s["n"] if s["n"] else 0
|
| 121 |
+
print(f" L{lvl} n={s['n']:4d} EX={ex_pct:5.1f}% Soft-EX={sf_pct:5.1f}%")
|
| 122 |
+
if total_n:
|
| 123 |
+
print(f"\nOverall n={total_n:4d} "
|
| 124 |
+
f"EX={100*total_ex/total_n:5.1f}% "
|
| 125 |
+
f"Soft-EX={100*total_soft/total_n:5.1f}%")
|
| 126 |
+
else:
|
| 127 |
+
print("\nNo predictions overlapped with the dataset. Nothing to score.")
|
| 128 |
+
return 0
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
if __name__ == "__main__":
|
| 132 |
+
sys.exit(main())
|
examples/load_dataset.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Load the SCM-SQL dataset and print a few pairs from each level.
|
| 2 |
+
|
| 3 |
+
Two loading paths shown:
|
| 4 |
+
1. Native YAML — zero extra dependencies beyond PyYAML.
|
| 5 |
+
2. Hugging Face `datasets` — canonical for ML training / eval scripts.
|
| 6 |
+
|
| 7 |
+
Run:
|
| 8 |
+
python examples/load_dataset.py
|
| 9 |
+
"""
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
from collections import Counter
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def load_from_yaml() -> list[dict]:
|
| 17 |
+
"""Load directly from the shipped YAML file (no HF dependency)."""
|
| 18 |
+
import yaml
|
| 19 |
+
here = Path(__file__).resolve().parent.parent
|
| 20 |
+
data = yaml.safe_load((here / "data" / "pilot_500.yaml").read_text(encoding="utf-8"))
|
| 21 |
+
return data["pairs"]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def load_from_huggingface() -> list[dict]:
|
| 25 |
+
"""Load from the Hugging Face hub. Requires `pip install datasets`."""
|
| 26 |
+
from datasets import load_dataset # type: ignore
|
| 27 |
+
ds = load_dataset("AniruddhaAI/scm-sql", split="test")
|
| 28 |
+
return list(ds)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def summarise(pairs: list[dict]) -> None:
|
| 32 |
+
by_level = Counter(p["level"] for p in pairs)
|
| 33 |
+
print(f"Loaded {len(pairs)} pairs")
|
| 34 |
+
print(f"By level: {dict(sorted(by_level.items()))}")
|
| 35 |
+
n_multi = sum(1 for p in pairs if p.get("turns"))
|
| 36 |
+
print(f"Multi-turn dialogues: {n_multi}")
|
| 37 |
+
|
| 38 |
+
print("\nFirst pair at each level:")
|
| 39 |
+
seen: set[int] = set()
|
| 40 |
+
for p in pairs:
|
| 41 |
+
lvl = p["level"]
|
| 42 |
+
if lvl in seen:
|
| 43 |
+
continue
|
| 44 |
+
seen.add(lvl)
|
| 45 |
+
print(f"\n--- L{lvl} · {p['id']} · domains={p['domains']} ---")
|
| 46 |
+
if "turns" in p:
|
| 47 |
+
for i, t in enumerate(p["turns"], 1):
|
| 48 |
+
print(f" Turn {i} NL : {t['nl']}")
|
| 49 |
+
print(f" SQL: {t['gold_sql'].strip()[:120]}...")
|
| 50 |
+
else:
|
| 51 |
+
print(f" NL : {p['nl']}")
|
| 52 |
+
print(f" SQL: {p['gold_sql'].strip()[:120]}...")
|
| 53 |
+
if len(seen) == 6:
|
| 54 |
+
break
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
pairs = load_from_yaml()
|
| 59 |
+
summarise(pairs)
|