Download code/harness/nm_smoke.py from quocbao747/embedding-model-benchmark: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/quocbao747/embedding-model-benchmark/resolve/main/code/harness/nm_smoke.py
- Command line
-
hf download hf://quocbao747/embedding-model-benchmark/code/harness/nm_smoke.py
-
curl -L -o nm_smoke.py https://huggingface.co/quocbao747/embedding-model-benchmark/resolve/main/code/harness/nm_smoke.py
1.13 kB
| """Smoke test for the 19-model run: each model on two small datasets, prints nDCG@10 / dim / NaN rows / docs per s. | |
| Usage: RESULTS=<results dir> python nm_smoke.py model1,model2,...""" | |
| import sys, json, time, traceback, gc | |
| models = sys.argv[1].split(","); sys.argv = [sys.argv[0], "smoke"] | |
| import worker, torch | |
| for m in models: | |
| try: | |
| t = time.time(); enc = worker.make_enc(m); tl = time.time() - t | |
| for task in ("PublicHealthQA:vietnamese", "XQuADRetrieval:vi"): | |
| r = worker.run_job(enc, {"model": m, "task": task})[0] | |
| print(json.dumps({"model": m, "task": task, "ndcg10": round(r["ndcg10"], 2), "dim": r.get("dim"), "nan": r.get("nan_rows"), | |
| "max_len": r["max_len"], "docs_s": round(r["docs_per_s"]), "peak": round(r["peak_vram_gib"], 2), | |
| "trunc": round(r.get("frac_truncated", -1), 3), "load_s": round(tl)}), flush=True) | |
| except Exception as e: | |
| print(json.dumps({"model": m, "error": f"{type(e).__name__}: {str(e)[:400]}"}), flush=True); traceback.print_exc() | |
| enc = None; gc.collect(); torch.cuda.empty_cache() | |