Download build_inference_jsonl.py from legexbenchmark/code: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/datasets/legexbenchmark/code/resolve/main/build_inference_jsonl.py
- Command line
-
hf download hf://datasets/legexbenchmark/code/build_inference_jsonl.py
-
curl -L -o build_inference_jsonl.py https://huggingface.co/datasets/legexbenchmark/code/resolve/main/build_inference_jsonl.py
2.34 kB
| """Build the published inference-results bundle from the cleaned working JSONL. | |
| For every annotated jurisdiction (one with a ``goldenset_<cc>.jsonl`` under | |
| ``--gold-dir/<cc>/``) copy each model's cleaned inference file | |
| ``<data-dir>/<cc>/Goldenset_*_v3_full_text_<slug>.jsonl`` to | |
| ``--out-dir/<cc>/inference_<model>.jsonl``. The records are already clean, | |
| single-typed JSONL with ``comment`` / ``original_input`` provenance (see | |
| ``legex.evaluation.cleaning``), so this is a faithful copy — no transformation, | |
| no CSV type-inference hazard. | |
| python build_inference_jsonl.py --data-dir ../data \\ | |
| --gold-dir goldensets/data --out-dir inference-results/data | |
| """ | |
| import argparse | |
| import re | |
| from pathlib import Path | |
| # working model slug -> published short name | |
| SLUG_TO_MODEL = { | |
| "harvey": "harvey", | |
| "harvey-2": "harvey_2", | |
| "gpt-5.4-mini": "gpt", | |
| "gemini_gemini-3.1-flash-lite": "gemini", | |
| "legora-1": "legora_1", | |
| "legora-2": "legora_2", | |
| } | |
| _SLUG_RE = re.compile(r"_v3_full_text_(.+)\.jsonl$") | |
| def main(argv: list[str] | None = None) -> int: | |
| parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) | |
| parser.add_argument("--data-dir", type=Path, default=Path("../data")) | |
| parser.add_argument("--gold-dir", type=Path, default=Path("goldensets/data"), | |
| help="Where goldenset_<cc>.jsonl live; used to enumerate annotated jurisdictions.") | |
| parser.add_argument("--out-dir", type=Path, default=Path("inference-results/data")) | |
| parser.add_argument("--prompt_version", default="v3") | |
| args = parser.parse_args(argv) | |
| written = 0 | |
| for gs in sorted(args.gold_dir.glob("*/goldenset_*.jsonl")): | |
| cc = gs.parent.name | |
| for src in sorted((args.data_dir / cc).glob(f"Goldenset_*_{args.prompt_version}_full_text_*.jsonl")): | |
| m = _SLUG_RE.search(src.name) | |
| model = SLUG_TO_MODEL.get(m.group(1)) if m else None | |
| if model is None: | |
| continue | |
| dst = args.out_dir / cc / f"inference_{model}.jsonl" | |
| dst.parent.mkdir(parents=True, exist_ok=True) | |
| dst.write_text(src.read_text(encoding="utf-8"), encoding="utf-8") | |
| written += 1 | |
| print(f"wrote {written} inference JSONL file(s) to {args.out_dir}") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |