Download scripts/validate_dataset.py from adityan8i/TRACE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 1.66 kB
-
https://huggingface.co/datasets/adityan8i/TRACE-Bench/resolve/main/scripts/validate_dataset.py
- Command line
-
hf download hf://datasets/adityan8i/TRACE-Bench/scripts/validate_dataset.py
-
curl -L -o validate_dataset.py https://huggingface.co/datasets/adityan8i/TRACE-Bench/resolve/main/scripts/validate_dataset.py
1.66 kB
| #!/usr/bin/env python3 | |
| """Lightweight, dependency-free structural validation for release files.""" | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| REQUIRED = {"case_id", "parent_case_id", "task", "question", "prompt", "target_decision", "documents", "gold", "perturbation"} | |
| GOLD = {"condition", "status", "control", "decision", "policy_rules", "evidence_ids", "requires_human_review"} | |
| def main() -> None: | |
| files = sorted((ROOT / "data").glob("*/test.jsonl")) | |
| assert files, "No test JSONL files found. Run scripts/generate_v0_1.py first." | |
| count, instance_keys = 0, set() | |
| for path in files: | |
| for line_number, line in enumerate(path.read_text().splitlines(), 1): | |
| item = json.loads(line) | |
| assert REQUIRED <= item.keys(), f"{path}:{line_number}: missing top-level fields" | |
| assert GOLD <= item["gold"].keys(), f"{path}:{line_number}: missing gold fields" | |
| assert item["gold"]["decision"] in {"standard", "rated", "refer"} | |
| assert item["target_decision"] == item["gold"]["decision"] | |
| assert len(item["documents"]) >= 1 | |
| instance_key = (item["task"], item["case_id"]) | |
| assert instance_key not in instance_keys, f"duplicate task/case ID: {instance_key}" | |
| if item["perturbation"]["type"] != "none": | |
| assert item["parent_case_id"], f"{item['case_id']}: perturbation needs parent" | |
| instance_keys.add(instance_key); count += 1 | |
| print(f"Validated {count} unique instances across {len(files)} configurations.") | |
| if __name__ == "__main__": | |
| main() | |