Datasets:
Download score.py from duckwork-ai/mallard-data: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/datasets/duckwork-ai/mallard-data/resolve/main/score.py
- Command line
-
hf download hf://datasets/duckwork-ai/mallard-data/score.py
-
curl -L -o score.py https://huggingface.co/datasets/duckwork-ai/mallard-data/resolve/main/score.py
1.39 kB
| """Score a model's raw outputs on the duckwork-test tasks. | |
| python score.py outputs.jsonl [--sample] | |
| `outputs.jsonl` has one line per task: {"id": ..., "output": "<raw model text>"}. | |
| Render each task with your model's chat template (system prompt, tools, | |
| messages; thinking off), generate greedily, and keep the raw text, tool-call | |
| markup included. `--sample` scores only the 308 tasks in the published | |
| benchmark sample. Needs checks.py next to this file. | |
| """ | |
| import collections | |
| import json | |
| import pathlib | |
| import sys | |
| from checks import check | |
| HERE = pathlib.Path(__file__).parent | |
| def main() -> None: | |
| outputs = {(r := json.loads(l))["id"]: r["output"] for l in open(sys.argv[1]) if l.strip()} | |
| only_sample = "--sample" in sys.argv | |
| passed, total = collections.Counter(), collections.Counter() | |
| for line in open(HERE / "duckwork-test" / "test.jsonl"): | |
| task = json.loads(line) | |
| if (only_sample and not task["in_benchmark_sample"]) or task["id"] not in outputs: | |
| continue | |
| result = check({"expect": json.loads(task["expect"])}, outputs[task["id"]]) | |
| total[task["kind"]] += 1 | |
| passed[task["kind"]] += result["passed"] | |
| for kind in sorted(total): | |
| print(f"{kind:20} {passed[kind]:4} / {total[kind]}") | |
| print(f"{'total':20} {sum(passed.values()):4} / {sum(total.values())}") | |
| if __name__ == "__main__": | |
| main() | |