Spaces:
Sleeping

File size: 4,482 Bytes
37a1a73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8c2a72f
 
 
 
 
37a1a73
 
 
 
 
 
 
 
 
 
 
 
 
bc37764
 
 
 
 
 
 
 
 
37a1a73
 
 
bc37764
37a1a73
 
 
 
 
 
 
bc37764
37a1a73
bc37764
37a1a73
 
 
 
 
 
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
80
81
82
83
84
85
86
87
"""Seed the leaderboard CSV with our 18 evaluated models.

Reads /projects/bfdz/xzhou10/robustbench/results/<model>/scores.json for each,
extracts the overall + by-MDP-component accuracy numbers, writes one row per
model to leaderboard.csv. Run once before the first deployment.

Usage:
    python seed_with_18_models.py
"""
from __future__ import annotations

import json
from pathlib import Path

import pandas as pd

RESULTS = Path("/projects/bfdz/xzhou10/robustbench/results")
OUT = Path(__file__).resolve().parent / "leaderboard.csv"

# Display name -> result-directory basename
MODELS = {
    # Family,                              Type,             Result dir
    "ToolRL-Qwen2.5-1.5B":                ("fine-tuned",   "chengq9__ToolRL-Qwen2.5-1.5B"),
    "ToolRL-Qwen2.5-3B":                  ("fine-tuned",   "chengq9__ToolRL-Qwen2.5-3B"),
    "ToolRL-Llama3.2-3B":                 ("fine-tuned",   "chengq9__ToolRL-Llama3.2-3B"),
    "TL-CodeLLaMA-2":                     ("fine-tuned",   "Junjie-Ye__TL-CodeLLaMA-2"),
    "LoopTool-8B":                        ("fine-tuned",   "zhuiguang-ning__LoopTool-8B"),
    "LoopTool-32B":                       ("fine-tuned",   "zhuiguang-ning__LoopTool-32B"),
    "MUA-RL-8B":                          ("fine-tuned",   "zzwkk__MUA-RL-8B"),
    "MUA-RL-14B":                         ("fine-tuned",   "zzwkk__MUA-RL-14B"),
    "MUA-RL-32B":                         ("fine-tuned",   "zzwkk__MUA-RL-32B"),
    "Qwen2.5-1.5B-Instruct":              ("open",         "Qwen__Qwen2.5-1.5B-Instruct"),
    "Qwen2.5-3B-Instruct":                ("open",         "Qwen__Qwen2.5-3B-Instruct"),
    "Llama-3.2-3B-Instruct":              ("open",         "meta-llama__Llama-3.2-3B-Instruct"),
    "Qwen3-8B (non-thinking)":            ("open",         "Qwen__Qwen3-8B"),
    "Qwen3-14B (non-thinking)":           ("open",         "Qwen__Qwen3-14B"),
    "Qwen3-32B (non-thinking)":           ("open",         "Qwen__Qwen3-32B"),
    "Qwen3.5-9B":                         ("open",         "Qwen__Qwen3.5-9B"),
    "DeepSeek-R1-Distill-Qwen-14B":       ("open",         "deepseek-ai__DeepSeek-R1-Distill-Qwen-14B"),
    "SFT-Clean-4k-Qwen2.5-3B (reproduced baseline)":
                                          ("fine-tuned",   "__projects__bfdz__xzhou10__robustbench__sft_models__SFT-Clean-4k-Qwen2.5-3B-Instruct"),
    "ToolRL-DR-Full (ours)":              ("fine-tuned",   "HeadyZhang__qwen2.5-3b-toolrl-robustbench-perturbed"),
    "ToolRL-DR-Mixed (ours)":             ("fine-tuned",   "HeadyZhang__qwen2.5-3b-toolrl-robustbench-mixed"),
    "o4-mini (OpenAI)":                   ("closed",       "openai__o4-mini"),
}


def main() -> None:
    rows = []
    for model_name, (mtype, dirname) in MODELS.items():
        scores_path = RESULTS / dirname / "scores.json"
        if not scores_path.exists():
            print(f"  SKIP {model_name}: no scores.json at {scores_path}")
            continue
        data = json.loads(scores_path.read_text())
        ov = data["overall"]["overall"]
        by_mdp = data["overall"]["by_mdp_category"]
        by_pert = data["overall"].get("by_perturbation", {})
        # Perturbed-only overall: exclude clean cell so the headline is the
        # actual sim-to-real robustness number.
        pert_correct = sum(
            v.get("correct", round(v["accuracy"] * v["n"]))
            for k, v in by_pert.items() if k != "clean"
        )
        pert_n = sum(v["n"] for k, v in by_pert.items() if k != "clean")
        pert_acc = pert_correct / pert_n if pert_n else 0.0
        rows.append({
            "Model": model_name,
            "Type": mtype,
            "Pert. Acc.": round(pert_acc, 4),
            "Clean":           round(by_mdp.get("clean",      {}).get("accuracy", 0), 4),
            "Obs Acc.":        round(by_mdp.get("observation",{}).get("accuracy", 0), 4),
            "Action Acc.":     round(by_mdp.get("action",     {}).get("accuracy", 0), 4),
            "Reward Acc.":     round(by_mdp.get("reward",     {}).get("accuracy", 0), 4),
            "Transition Acc.": round(by_mdp.get("transition", {}).get("accuracy", 0), 4),
            "Submitted": "2026-04 (seeded)",
        })
        print(f"  ✓ {model_name}: pert={rows[-1]['Pert. Acc.']:.4f} clean={rows[-1]['Clean']:.4f}")

    df = pd.DataFrame(rows).sort_values("Pert. Acc.", ascending=False)
    df.to_csv(OUT, index=False)
    print(f"\nWrote {len(df)} rows to {OUT}")


if __name__ == "__main__":
    main()