"""Create the Typed Decisions eval YAML and open a PR on the model repo. Usage: python submit_results.py MODEL_ID [RESULTS_JSON] [--mode general|specialist] [--dry-run] Reads the summary produced by score_with_jobs.py (accuracy, kl_from_gold, brier, ece), writes the Hub eval-results YAML, and opens a pull request on the model repo (`.eval_results/.yaml`). With --dry-run the YAML is printed instead of uploaded. """ import argparse import datetime import json BENCH = "LocalLLaMA/typed-decisions" TASKS = ["accuracy", "kl_from_gold", "brier", "ece"] NOTE_SPECIALIST = ( "Model was fitted/fine-tuned on this benchmark's train split; " "not comparable with zero-shot rows." ) def build_yaml(summary: dict, mode: str, date: str) -> str: lines = [] for task_id in TASKS: value = round(float(summary[task_id]), 4) lines += [ "- dataset:", f" id: {BENCH}", f" task_id: {task_id}", f" value: {value}", f' date: "{date}"', " source:", f" url: https://huggingface.co/datasets/{BENCH}", ' name: "Typed Decisions benchmark run on HF Jobs"', ] if mode == "specialist": lines.append(f" notes: {json.dumps(NOTE_SPECIALIST)}") return "\n".join(lines) + "\n" def main(): ap = argparse.ArgumentParser(description=__doc__) ap.add_argument("model_id", help="model repo the results belong to, e.g. org/model") ap.add_argument("results", nargs="?", default="results.json", help="summary JSON from score_with_jobs.py") ap.add_argument("--mode", choices=["general", "specialist"], default="general", help="specialist = fitted on the benchmark's train split") ap.add_argument("--dry-run", action="store_true", help="print the YAML instead of opening a PR") args = ap.parse_args() with open(args.results) as f: summary = json.load(f) missing = [t for t in TASKS if t not in summary] if missing: raise SystemExit(f"results file is missing task keys: {missing}") date = datetime.date.today().isoformat() yaml_text = build_yaml(summary, args.mode, date) file_name = args.model_id.replace("/", "__") + ".yaml" if args.dry_run: print(yaml_text) return from huggingface_hub import HfApi api = HfApi() commit = api.upload_file( path_or_fileobj=yaml_text.encode(), path_in_repo=f".eval_results/{file_name}", repo_id=args.model_id, repo_type="model", create_pr=True, commit_message="Add Typed Decisions eval results", commit_description=( f"{args.mode} run on {date}: accuracy {summary['accuracy']}, " f"KL {summary['kl_from_gold']}, Brier {summary['brier']}, ECE {summary['ece']} " f"({summary['n_decisions']} decisions, one request per case)." ), ) pr_url = getattr(commit, "pr_url", None) or getattr(commit, "pull_request_url", "") print(f"[submit] eval YAML opened as a PR on {args.model_id}: {pr_url}", flush=True) if __name__ == "__main__": main()