File size: 3,583 Bytes
453b36d
dcef129
 
 
 
 
 
 
 
 
 
 
453b36d
dcef129
ae9e249
 
 
dcef129
 
 
ae9e249
 
 
 
 
 
 
 
 
 
 
 
 
 
dcef129
 
 
 
 
 
 
 
 
 
 
ae9e249
 
 
 
dcef129
 
 
 
 
 
 
 
 
ae9e249
 
 
 
 
 
 
 
 
 
dcef129
 
 
 
 
 
 
 
453b36d
dcef129
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
79
"""Assemble the Hugging Face dataset folder for Five Desks v2 and v3 (same image; v3 trains a subset)."""

import json
import shutil
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
sys.path.insert(0, str(ROOT / "scripts"))

from diligence.environment import TASK_IDS, DiligenceEnvironment, build  # noqa: E402
from selection_v3 import SELECTED  # noqa: E402

TIP = "put your working in the action"
# final calibration: runs a and b, with math-reasoning from the rerun after its brief was fixed
RUNS = {"a": None, "b": lambda t: not t.startswith("math-reasoning"), "reasoning2": None}
out = ROOT / "dataset"
shutil.rmtree(out, ignore_errors=True)
(out / "calibration").mkdir(parents=True)
calib = {}
for run, keep in RUNS.items():
    for line in open(ROOT / f"reports/calibration-v2/{run}/episodes.jsonl"):
        ep = json.loads(line)
        if keep and not keep(ep["task_id"]):
            continue
        hinted = TIP in ep["turns"][0]["obs"]
        calib.setdefault(ep["task_id"], []).append((ep["reward"], hinted))
    shutil.copy(ROOT / f"reports/calibration-v2/{run}/summary.json", out / f"calibration/v2_{run}_summary.json")
    shutil.copy(ROOT / f"reports/calibration-v2/{run}/episodes.jsonl", out / f"calibration/v2_{run}_episodes.jsonl")


def mean_of(pairs):
    return round(sum(r for r, _ in pairs) / len(pairs), 3) if pairs else None

with open(out / "tasks.jsonl", "w") as f:
    for task_id in TASK_IDS:
        task = build(task_id, 0)
        prompt = DiligenceEnvironment().reset(task_id=task_id, seed=0).output
        f.write(json.dumps({
            "task_id": task_id,
            "family": task.family,
            "domain": task.domain,
            "level": int(task_id[-1]),
            "submitted_for_training": task_id in SELECTED,
            "qwen3_8_27b_mean_reward": mean_of(calib.get(task_id, [])),
            "qwen3_8_27b_mean_with_hint": mean_of([p for p in calib.get(task_id, []) if p[1]]),
            "qwen3_8_27b_mean_without_hint": mean_of([p for p in calib.get(task_id, []) if not p[1]]),
            "qwen3_8_27b_rewards": [r for r, _ in calib.get(task_id, [])],
            "example_seed": 0,
            "example_prompt": prompt,
            "example_files": json.dumps(task.files),
            "example_solution": json.dumps(task.oracle()),
            "example_caveat_missed": json.dumps(task.naive()),
            "max_tool_calls": task.max_steps,
        }) + "\n")

shutil.copy(ROOT / "reports/proxy/FINDINGS.md", out / "calibration/stand_in_test_findings.md")
transfer = out / "calibration/transfer"
for item in sorted((ROOT / "reports/transfer").iterdir()):
    if item.is_dir() and (item / "summary.json").exists():
        (transfer / item.name).mkdir(parents=True)
        for name in ["summary.json", "episodes.jsonl"]:
            if (item / name).exists():
                shutil.copy(item / name, transfer / item.name / name)
    elif item.suffix == ".txt":
        transfer.mkdir(parents=True, exist_ok=True)
        shutil.copy(item, transfer / item.name)
src = out / "source"
for item in ["diligence", "server", "scripts", "tests", "proxy_eval", "five_desks", "openenv.yaml",
             "requirements.in", "requirements.lock", ".dockerignore"]:
    path = ROOT / item
    if path.is_dir():
        shutil.copytree(path, src / item, ignore=shutil.ignore_patterns("__pycache__", "*.pyc"))
    else:
        shutil.copy(path, src / item)
shutil.copy(ROOT / "card_v3.md", out / "README.md")
print("dataset at", out, sorted(p.name for p in out.iterdir()))