File size: 3,183 Bytes
10f3201 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | """Apply the AW-23 selection rule to a base-model measurement and write the v13 request.
Rule (registered in the lab notebook before any measurement):
- keep base rate in [0.25, 0.50]; up to 3 per domain, closest to 0.375 first;
- a domain with fewer than 3 in band tops up from [0.125, 0.625], nearest to the band first;
- order round-robin across domains.
python3 select.py MEASUREMENT_LOG.jsonl TASKS_DIR SCHEMA_URL OUT.json [--image IMAGE] [--id ID]
"""
import argparse
import json
import tomllib
from collections import defaultdict
from pathlib import Path
from urllib.request import urlopen
LIMITS = {"split": "train", "reset_wall_s": 180, "rollout_wall_s": 1800, "verifier_wall_s": 120,
"tool_wall_s": 120, "tool_calls_total": 32, "completion_tokens": 4096, "context_tokens": 8192}
def band_distance(rate):
return max(0.25 - rate, rate - 0.50, 0.0)
def main():
p = argparse.ArgumentParser()
p.add_argument("log")
p.add_argument("tasks")
p.add_argument("schema_url")
p.add_argument("out")
p.add_argument("--image", default="docker.io/aji28/analyst-workbench:v13")
p.add_argument("--id", default="analyst-workbench-v13")
a = p.parse_args()
runs = defaultdict(list)
for line in open(a.log):
e = json.loads(line)
if "task_id" in e and e["reward"] is not None:
runs[e["task_id"]].append(e["reward"] >= 1.0)
domain = {t: tomllib.loads((Path(a.tasks) / t / "task.toml").read_text())["metadata"]["domain"] for t in runs}
by_domain = defaultdict(list)
for t, r in sorted(runs.items()):
by_domain[domain[t]].append((t, sum(r) / len(r), len(r)))
picked = {}
for d, rows in sorted(by_domain.items()):
inband = sorted((x for x in rows if 0.25 <= x[1] <= 0.50), key=lambda x: (abs(x[1] - 0.375), x[0]))
near = sorted((x for x in rows if 0.125 <= x[1] <= 0.625 and not 0.25 <= x[1] <= 0.50),
key=lambda x: (band_distance(x[1]), x[0]))
picked[d] = (inband + near)[:3]
for t, rate, n in sorted(rows, key=lambda x: x[0]):
mark = "KEEP" if any(t == x[0] for x in picked[d]) else " "
print(f"{mark} {d[:12]:12} {t:32} {rate:.3f} (n={n})")
order, rnd = [], 0
while any(len(v) > rnd for v in picked.values()):
order += [v[rnd][0] for _, v in sorted(picked.items()) if len(v) > rnd]
rnd += 1
schema = json.load(urlopen(a.schema_url + "/schema"))
body = {
"submission_id": a.id,
"name": "Analyst Workbench",
"image": a.image,
"schema": {"action": schema["action"], "observation": schema["observation"]},
"tasks": [dict(LIMITS, task_id=t) for t in order],
"example_actions": [{"action_type": "evaluate"}],
"finish_action": {"action_type": "evaluate"},
"dataset": "ajinkyamulay/analyst-workbench",
"source": "https://huggingface.co/datasets/ajinkyamulay/analyst-workbench/tree/main/v13",
}
Path(a.out).write_text(json.dumps(body, indent=2) + "\n")
print(f"wrote {a.out}: {len(order)} tasks", {d: len(v) for d, v in sorted(picked.items())})
if __name__ == "__main__":
main()
|