Datasets:
Tasks:
Text Classification
Formats:
parquet
Languages:
English
Size:
1K - 10K
Tags:
Synthetic
structured-decisions
calibration
probabilistic-classification
system-one
workflow-evaluation
License:
Add HF Jobs how-to for benchmarking a model
#42
by SaylorTwift HF Staff - opened
Files changed (3)
- README.md+5-2
- bench/score_with_jobs.sh+8-1
- bench/submit_results.pyAdded+85
152 unmodified lines153154155156157158159160161162163164165166167168152 unmodified lines```bashhf jobs run --flavor a100-large --timeout 2h \\--env MODEL_ID=your-org/your-model \\--volume hf://datasets/LocalLLaMA/typed-decisions:/repo:ro \\pytorch/pytorch:2.9.1-cuda12.8-cudnn9-devel \\bash /repo/bench/score_with_jobs.sh```- Pick the `--flavor` for the model's size: `l4x1` up to ~2B, `l40sx1` or`a100-large` for ~27B, `h200` above. Gated models also need `--secrets HF_TOKEN`.- `bench/score_with_jobs.sh` installs vLLM nightly, serves the model, scores all400 cases, and writes `results.json`.- Then open a discussion with the numbers and the mode (specialist or general).### Notes on the rows152 unmodified lines153154155156157158159160161162163164165166167168169170171152 unmodified lines```bashhf jobs run --flavor a100-large --timeout 2h \\--env MODEL_ID=your-org/your-model \\--secrets HF_TOKEN \\--volume hf://datasets/LocalLLaMA/typed-decisions:/repo:ro \\pytorch/pytorch:2.9.1-cuda12.8-cudnn9-devel \\bash /repo/bench/score_with_jobs.sh```- Pick the `--flavor` for the model's size: `l4x1` up to ~2B, `l40sx1` or`a100-large` for ~27B, `h200` above.- `bench/score_with_jobs.sh` installs vLLM nightly, serves the model, scores all400 cases, and writes `results.json`.- The run finishes by creating the eval YAML and opening a PR on the model repowith the four scores, so they show on the Hub leaderboard once merged. Add`--env MODE=specialist` if you fitted the model on `train`.### Notes on the rows
1234561 unmodified line8910#!/usr/bin/env bash# Bootstrap for `hf jobs run`: install deps, then score $MODEL_ID on the test split.# Reads $MODEL_ID (required). Optional: $SERVE_FLAGS (extra `vllm serve` flags).set -euo pipefailMODEL_ID=${MODEL_ID:?set --env MODEL_ID=org/model}1 unmodified linepip install -q datasets requestspip install -q -U vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightlypython "$SCRIPT_DIR/score_with_jobs.py" "$MODEL_ID"12345671 unmodified line91011121314151617#!/usr/bin/env bash# Bootstrap for `hf jobs run`: install deps, then score $MODEL_ID on the test split.# Reads $MODEL_ID (required). Optional: $SERVE_FLAGS (extra `vllm serve` flags),# $MODE=general|specialist, $HF_TOKEN (opens the eval-results PR automatically).set -euo pipefailMODEL_ID=${MODEL_ID:?set --env MODEL_ID=org/model}1 unmodified linepip install -q datasets requestspip install -q -U vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightlypython "$SCRIPT_DIR/score_with_jobs.py" "$MODEL_ID"if [ -n "${HF_TOKEN:-}" ]; thenpython "$SCRIPT_DIR/submit_results.py" "$MODEL_ID" results.json --mode "${MODE:-general}"elseecho "[submit] pass --secrets HF_TOKEN to also open a PR with the eval results on the model repo"fi
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485"""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 onthe model repo (`.eval_results/<model>.yaml`). With --dry-run the YAML isprinted instead of uploaded."""import argparseimport datetimeimport 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()README.md+5-2
bench/score_with_jobs.sh+8-1
bench/submit_results.pyAdded+85