Download analysis/construct.py from tresbientech/skinsuit-behavioral-tests: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/datasets/tresbientech/skinsuit-behavioral-tests/resolve/main/analysis/construct.py
- Command line
-
hf download hf://datasets/tresbientech/skinsuit-behavioral-tests/analysis/construct.py
-
curl -L -o construct.py https://huggingface.co/datasets/tresbientech/skinsuit-behavioral-tests/resolve/main/analysis/construct.py
2.46 kB
| """Checks of the construct flaws of the reviews, from the caches of cache.py, with the counted judges: | |
| rubric items with the same pass rate of 0% or 100% in every arm, the weight of the two French cases in the | |
| score of each model, and the chance that a one-case metric has no answer in a bootstrap draw. | |
| Usage: python3 construct.py DATA REPO.""" | |
| import collections | |
| import pathlib | |
| import pickle | |
| import sys | |
| sys.dont_write_bytecode = True | |
| DATA, REPO = pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2]) # the folder of the data, a clone of the repo at eb30ca8 | |
| sys.path.insert(0, str(REPO / "evals")) | |
| import run # noqa: E402 | |
| for name in ("round5", "round6", "round7"): | |
| # The cache is written by cache.py in DATA/report-work. | |
| d = pickle.load(open(DATA / "report-work" / f"{name}.pkl", "rb")) | |
| rows, det, language_of = d["rows"], d["det"], d["language_of"] | |
| rate = collections.defaultdict(lambda: [0, 0]) | |
| share = collections.defaultdict(lambda: [0, 0]) | |
| for r, s in zip(rows, det): | |
| judge = run.COUNTED[r["model"].split(":")[0]] | |
| scored = {**s, **{f"judge:{k}": v for k, v in r["judges"][judge]["items"].items()}} | |
| for m, v in scored.items(): | |
| rate[(m, r["arm"])][0] += v | |
| rate[(m, r["arm"])][1] += 1 | |
| if r["arm"] == "final": | |
| share[(r["model"], m)][0] += language_of[r["case"]] == "fr" | |
| share[(r["model"], m)][1] += 1 | |
| arms = sorted({r["arm"] for r in rows}) | |
| items = sorted({m for m, _ in rate if m.startswith("judge:")}) | |
| constant = {m: rate[(m, arms[0])][0] / rate[(m, arms[0])][1] for m in items | |
| if all(rate[(m, a)][0] in (0, rate[(m, a)][1]) for a in arms) | |
| and len({rate[(m, a)][0] == 0 for a in arms}) == 1} | |
| print(f"{name}: rubric items at the same 0% or 100% in every arm, over all models: " | |
| + ", ".join(f"{m} {100 * v:.0f}%" for m, v in constant.items())) | |
| weight = {} | |
| for model in sorted({r["model"] for r in rows}): | |
| metrics = [m for (mo, m) in share if mo == model] | |
| weight[model] = 100 * sum(share[(model, m)][0] / share[(model, m)][1] for m in metrics) / len(metrics) | |
| print(f"{name}: weight of the French cases in the score of final, % by model: " | |
| + ", ".join(f"{m.split(':')[1]} {w:.1f}" for m, w in weight.items())) | |
| cases = 23 | |
| print(f"chance that one case is absent from a draw of {cases} cases with replacement: {(1 - 1 / cases) ** cases:.3f}") | |