Release reviewed Mini-Dev update with archived 2025 annotations and baseline inputs
38818fc verified Download baseline_inference/validate_baseline_inference.py from birdsql/bird_mini_dev: direct link, hf CLI and curl.
- Browser
- Download file 3.88 kB
-
https://huggingface.co/datasets/birdsql/bird_mini_dev/resolve/main/baseline_inference/validate_baseline_inference.py
- Command line
-
hf download hf://datasets/birdsql/bird_mini_dev/baseline_inference/validate_baseline_inference.py
-
curl -L -o validate_baseline_inference.py https://huggingface.co/datasets/birdsql/bird_mini_dev/resolve/main/baseline_inference/validate_baseline_inference.py
3.88 kB
| """Validate all 1,500 fixed prompts offline, without auxiliary manifests.""" | |
| from __future__ import annotations | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| FOLDER = Path(__file__).resolve().parent | |
| ROOT = FOLDER.parent | |
| CORE_FIELDS = ('question_id', 'db_id', 'question', 'evidence', 'SQL', 'difficulty') | |
| ENGINE_NAMES = {'sqlite': 'SQLite', 'mysql': 'MySQL', 'postgresql': 'PostgreSQL'} | |
| TEMPLATE_SHA256 = '62b75a140957583fb04f9cfa8962f704332f3e3cb437ddd2784783e9ee7b176a' | |
| SCHEMA_SHA256 = { | |
| 'sqlite': '5176e324a72e80a8a37a12285596d123e0ba6c310dceaa9f13a1e413ee88ff5b', | |
| 'mysql': '5b02cc1dcef5d505687ed5e02964fe6c7708aa755e9abc70a17a1243f858e0ce', | |
| 'postgresql': '32b57c6e29601c6b6da629f38472c63b057279a14c4bb2678a20d4663a1d0799', | |
| } | |
| OUTPUT_SHA256 = { | |
| 'sqlite': 'b060ee9cb69be62a052f5e40367afeb2cf08f345f15ca318fd9a0f9bf52d53ef', | |
| 'mysql': '0c40ce1a936f5348a4f30dc4c8f409bb811ab2c166f92434a4d7e4569271efc4', | |
| 'postgresql': 'f745c324fe3ddc6d1f683d9713e9afe480addf59d71e413dfbccc1333eb11dab', | |
| } | |
| def require(condition: bool, message: str) -> None: | |
| if not condition: | |
| raise ValueError(message) | |
| def digest(data: bytes) -> str: | |
| return hashlib.sha256(data).hexdigest() | |
| def records(path: Path) -> list[dict]: | |
| rows = [json.loads(line) for line in path.read_text(encoding='utf-8').splitlines()] | |
| require(len(rows) == 500 and [r['question_id'] for r in rows] == list(range(500)), | |
| f'Expected exactly 500 ordered IDs 0–499: {path.name}') | |
| return rows | |
| def main() -> None: | |
| template = (FOLDER / 'prompt_template.txt').read_text(encoding='utf-8') | |
| require(digest(template.encode()) == TEMPLATE_SHA256, 'Prompt template hash mismatch') | |
| non_sql = None | |
| for dialect, engine in ENGINE_NAMES.items(): | |
| source = records(ROOT / 'data' / f'mini_dev_{dialect}.jsonl') | |
| output = FOLDER / f'mini_dev_{dialect}.jsonl' | |
| require(digest(output.read_bytes()) == OUTPUT_SHA256[dialect], f'Input hash mismatch: {dialect}') | |
| rows = records(output) | |
| schema_bytes = (FOLDER / 'schemas' / f'{dialect}.json').read_bytes() | |
| require(digest(schema_bytes) == SCHEMA_SHA256[dialect], f'Schema hash mismatch: {dialect}') | |
| schemas = json.loads(schema_bytes) | |
| require(len(schemas) == 11 and set(schemas) == {r['db_id'] for r in source}, | |
| f'Incomplete schema coverage: {dialect}') | |
| annotations = [{k: r[k] for k in CORE_FIELDS if k != 'SQL'} for r in source] | |
| if non_sql is None: | |
| non_sql = annotations | |
| require(annotations == non_sql, f'Non-SQL annotations differ: {dialect}') | |
| for gold, row in zip(source, rows, strict=True): | |
| require(set(gold) == set(CORE_FIELDS), f'Unexpected annotation fields: {dialect}') | |
| require(set(row) == set(CORE_FIELDS) | {'dialect', 'prompt'}, | |
| f'Unexpected input fields: {dialect}') | |
| require({k: row[k] for k in CORE_FIELDS} == gold and row['dialect'] == dialect, | |
| f'Annotation mismatch: {dialect}/{gold["question_id"]}') | |
| block = (gold['evidence'] + '\n' if gold['evidence'] else '') + gold['question'] | |
| # Gold SQL is deliberately not supplied to the prompt template. | |
| expected = template.format(engine=engine, schema=schemas[gold['db_id']], question_block=block) | |
| require(row['prompt'] == expected, f'Prompt mismatch: {dialect}/{gold["question_id"]}') | |
| question_block = row['prompt'].split('Question:\n', 1)[1].split('\n\nInstructions:\n', 1)[0] | |
| require(question_block == block, f'Question/evidence mismatch: {dialect}/{gold["question_id"]}') | |
| print(f'{dialect}: all 500 annotation rows, prompts and 11 schema texts passed') | |
| print('Total: 1,500 aligned inputs. No database writes or model calls performed.') | |
| if __name__ == '__main__': | |
| main() | |