Spaces:
Sleeping

xzhou10 commited on
Commit
bc37764
·
1 Parent(s): cf77118

feat: replace 'Overall Acc.' with 'Pert. Acc.' (clean-excluded), explain N

Browse files

User feedback on the live leaderboard:
1. 'n' column was opaque — added a column-guide markdown above the table
that defines N (eval), Pert. Acc., Clean explicitly. Also renamed the
column to 'N (eval)' for clarity.
2. The headline accuracy was a clean+perturbed average, which inflates
the number for any model with high clean accuracy. Replace it with
a perturbed-only weighted average (sum of correct/n across all 22
perturbation cells, clean excluded). Now Clean − Pert. Acc. is the
sim-to-real gap that the benchmark exists to measure.

score_submission(), append_entry(), seed_with_18_models.py all updated
to compute and store the perturbed-only Pert. Acc.; load_leaderboard()
includes a backward-compat rename for old CSVs (n -> N (eval),
Overall Acc. -> Pert. Acc.) so existing rows keep working.

Files changed (3) hide show
  1. app.py +50 -11
  2. leaderboard.csv +19 -19
  3. seed_with_18_models.py +13 -4
app.py CHANGED
@@ -176,10 +176,26 @@ def score_submission(payload: dict[str, Any]) -> dict[str, Any]:
176
 
177
  ov = scores["overall"]["overall"]
178
  by_mdp = scores["overall"]["by_mdp_category"]
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  return {
180
- "overall_acc": ov["accuracy"],
181
- "n_samples": ov["n"],
182
- "by_mdp": {k: v["accuracy"] for k, v in by_mdp.items()},
 
 
 
183
  }
184
 
185
 
@@ -187,9 +203,16 @@ def score_submission(payload: dict[str, Any]) -> dict[str, Any]:
187
  # Leaderboard CSV (Space-local; we will sync to HF Dataset hub in M4)
188
  # ---------------------------------------------------------------------------
189
 
 
 
 
 
 
 
 
190
  LEADERBOARD_COLUMNS = [
191
- "Model", "Type", "n", "Overall Acc.",
192
- "Clean", "Obs Acc.", "Action Acc.", "Reward Acc.", "Transition Acc.",
193
  "Submitted",
194
  ]
195
 
@@ -200,9 +223,9 @@ def append_entry(model_name: str, model_type: str,
200
  row = {
201
  "Model": model_name,
202
  "Type": model_type,
203
- "n": summary.get("n_samples"),
204
- "Overall Acc.": round(summary.get("overall_acc", 0), 4),
205
- "Clean": round(by_mdp.get("clean", 0), 4),
206
  "Obs Acc.": round(by_mdp.get("observation",0), 4),
207
  "Action Acc.": round(by_mdp.get("action", 0), 4),
208
  "Reward Acc.": round(by_mdp.get("reward", 0), 4),
@@ -220,8 +243,12 @@ def append_entry(model_name: str, model_type: str,
220
  def load_leaderboard() -> pd.DataFrame:
221
  if LEADERBOARD_PATH.exists():
222
  df = pd.read_csv(LEADERBOARD_PATH)
223
- if "Overall Acc." in df.columns and df["Overall Acc."].notna().any():
224
- df = df.sort_values("Overall Acc.", ascending=False)
 
 
 
 
225
  return df
226
  return pd.DataFrame(columns=LEADERBOARD_COLUMNS)
227
 
@@ -246,7 +273,8 @@ def submit(file) -> tuple[str, pd.DataFrame]:
246
  append_entry(payload["model_name"], payload["model_type"], summary)
247
  return (
248
  f"✅ accepted: {payload['model_name']} — "
249
- f"overall acc {summary['overall_acc']:.4f} on {summary['n_samples']} samples",
 
250
  load_leaderboard(),
251
  )
252
 
@@ -262,6 +290,17 @@ with gr.Blocks(title="RobustBench-TC Leaderboard") as demo:
262
  "Inference helper: `scripts/run_eval.py` in the project repo."
263
  )
264
  with gr.Tab("Leaderboard"):
 
 
 
 
 
 
 
 
 
 
 
265
  leaderboard = gr.Dataframe(
266
  value=load_leaderboard(), interactive=False, wrap=True,
267
  )
 
176
 
177
  ov = scores["overall"]["overall"]
178
  by_mdp = scores["overall"]["by_mdp_category"]
179
+ by_pert = scores["overall"].get("by_perturbation", {})
180
+
181
+ # Perturbed-only overall: exclude the clean cell so the headline number
182
+ # reflects sim-to-real gap rather than clean-task ability. Sum (correct, n)
183
+ # across every cell whose key isn't 'clean', then ratio.
184
+ pert_correct = sum(
185
+ v.get("correct", round(v["accuracy"] * v["n"]))
186
+ for k, v in by_pert.items() if k != "clean"
187
+ )
188
+ pert_n = sum(v["n"] for k, v in by_pert.items() if k != "clean")
189
+ overall_pert_acc = pert_correct / pert_n if pert_n > 0 else 0.0
190
+
191
+ clean_acc = by_mdp.get("clean", {}).get("accuracy", 0.0) if isinstance(by_mdp.get("clean"), dict) else by_mdp.get("clean", 0.0)
192
  return {
193
+ "overall_acc": overall_pert_acc, # perturbed-only avg (used as headline)
194
+ "overall_acc_with_clean": ov["accuracy"], # full average kept for reference
195
+ "n_samples": ov["n"], # total predictions across 23 cells
196
+ "n_perturbed": pert_n, # predictions excluding clean
197
+ "clean_acc": clean_acc,
198
+ "by_mdp": {k: (v["accuracy"] if isinstance(v, dict) else v) for k, v in by_mdp.items()},
199
  }
200
 
201
 
 
203
  # Leaderboard CSV (Space-local; we will sync to HF Dataset hub in M4)
204
  # ---------------------------------------------------------------------------
205
 
206
+ # Column header glossary (tooltip text in the gradio Dataframe headers below):
207
+ # N (eval) = number of predictions across all 23 cells (clean + 22 perturbations).
208
+ # For RobustBench-TC the canonical eval set this is 3721.
209
+ # Pert. Acc. = overall accuracy on perturbed cells ONLY (clean excluded), so the
210
+ # number reflects sim-to-real robustness rather than clean-task ability.
211
+ # Clean = accuracy on the clean baseline (199 samples). Compare against
212
+ # Pert. Acc. to see the sim-to-real gap.
213
  LEADERBOARD_COLUMNS = [
214
+ "Model", "Type", "N (eval)", "Pert. Acc.", "Clean",
215
+ "Obs Acc.", "Action Acc.", "Reward Acc.", "Transition Acc.",
216
  "Submitted",
217
  ]
218
 
 
223
  row = {
224
  "Model": model_name,
225
  "Type": model_type,
226
+ "N (eval)": summary.get("n_samples"),
227
+ "Pert. Acc.": round(summary.get("overall_acc", 0), 4),
228
+ "Clean": round(summary.get("clean_acc", by_mdp.get("clean", 0)), 4),
229
  "Obs Acc.": round(by_mdp.get("observation",0), 4),
230
  "Action Acc.": round(by_mdp.get("action", 0), 4),
231
  "Reward Acc.": round(by_mdp.get("reward", 0), 4),
 
243
  def load_leaderboard() -> pd.DataFrame:
244
  if LEADERBOARD_PATH.exists():
245
  df = pd.read_csv(LEADERBOARD_PATH)
246
+ # Backward-compat: rename legacy headers (n, Overall Acc.) to current names
247
+ # so old leaderboard.csv files keep working after the schema change.
248
+ df = df.rename(columns={"n": "N (eval)", "Overall Acc.": "Pert. Acc."})
249
+ sort_col = "Pert. Acc." if "Pert. Acc." in df.columns else "Overall Acc."
250
+ if sort_col in df.columns and df[sort_col].notna().any():
251
+ df = df.sort_values(sort_col, ascending=False)
252
  return df
253
  return pd.DataFrame(columns=LEADERBOARD_COLUMNS)
254
 
 
273
  append_entry(payload["model_name"], payload["model_type"], summary)
274
  return (
275
  f"✅ accepted: {payload['model_name']} — "
276
+ f"perturbed acc {summary['overall_acc']:.4f} ({summary['n_perturbed']} perturbed samples), "
277
+ f"clean acc {summary['clean_acc']:.4f} (199 samples)",
278
  load_leaderboard(),
279
  )
280
 
 
290
  "Inference helper: `scripts/run_eval.py` in the project repo."
291
  )
292
  with gr.Tab("Leaderboard"):
293
+ gr.Markdown(
294
+ "**Column guide.** "
295
+ "**N (eval)** = total predictions across all 23 cells (clean baseline + 22 perturbations); "
296
+ "the canonical RobustBench-TC eval set has 3{,}721. "
297
+ "**Pert. Acc.** = accuracy on perturbed cells ONLY (clean excluded) — this is the "
298
+ "headline robustness number. "
299
+ "**Clean** = accuracy on the 199 clean samples; "
300
+ "the gap **Clean − Pert. Acc.** quantifies sim-to-real degradation. "
301
+ "Per-MDP-component columns (Obs / Action / Reward / Transition) average across "
302
+ "the perturbations in that component only."
303
+ )
304
  leaderboard = gr.Dataframe(
305
  value=load_leaderboard(), interactive=False, wrap=True,
306
  )
leaderboard.csv CHANGED
@@ -1,19 +1,19 @@
1
- Model,Type,n,Overall Acc.,Clean,Obs Acc.,Action Acc.,Reward Acc.,Transition Acc.,Submitted
2
- Qwen3-32B (non-thinking),open,2726,0.6009,0.7538,0.7299,0.6495,0.3879,0.4724,2026-04 (seeded)
3
- LoopTool-32B,fine-tuned,2726,0.5851,0.7789,0.745,0.6591,0.2701,0.5427,2026-04 (seeded)
4
- Qwen3-14B (non-thinking),open,3721,0.541,0.7487,0.7098,0.6053,0.2845,0.4983,2026-04 (seeded)
5
- MUA-RL-32B,fine-tuned,3721,0.5356,0.6834,0.6558,0.6938,0.2859,0.4657,2026-04 (seeded)
6
- MUA-RL-8B,fine-tuned,3721,0.4899,0.6784,0.6558,0.5227,0.2773,0.4489,2026-04 (seeded)
7
- LoopTool-8B,fine-tuned,3721,0.4891,0.7136,0.6646,0.5407,0.2845,0.4179,2026-04 (seeded)
8
- MUA-RL-14B,fine-tuned,3721,0.4784,0.6281,0.6168,0.5383,0.2945,0.4263,2026-04 (seeded)
9
- Qwen3-8B (non-thinking),open,3721,0.4604,0.6734,0.6545,0.5024,0.2644,0.3802,2026-04 (seeded)
10
- DeepSeek-R1-Distill-Qwen-14B,open,3721,0.4518,0.6181,0.6055,0.4581,0.3003,0.4054,2026-04 (seeded)
11
- Qwen3.5-9B,open,3721,0.4515,0.7085,0.6683,0.5407,0.2974,0.2915,2026-04 (seeded)
12
- ToolRL-Qwen2.5-1.5B,fine-tuned,3721,0.4461,0.7035,0.6709,0.5299,0.2227,0.325,2026-04 (seeded)
13
- TL-CodeLLaMA-2,fine-tuned,3721,0.4184,0.6533,0.6294,0.4868,0.1968,0.3199,2026-04 (seeded)
14
- ToolRL-Qwen2.5-3B,fine-tuned,3721,0.4166,0.6382,0.6181,0.4952,0.1882,0.3233,2026-04 (seeded)
15
- ToolRL-Llama3.2-3B,fine-tuned,3721,0.4026,0.6281,0.603,0.4569,0.1652,0.3317,2026-04 (seeded)
16
- Qwen2.5-3B-Instruct,open,3721,0.4018,0.608,0.5942,0.4127,0.1624,0.371,2026-04 (seeded)
17
- Qwen2.5-1.5B-Instruct,open,3721,0.3779,0.5729,0.5327,0.3732,0.1681,0.3677,2026-04 (seeded)
18
- Llama-3.2-3B-Instruct,open,3721,0.3504,0.5176,0.5088,0.3409,0.1451,0.3434,2026-04 (seeded)
19
- SFT-Clean-4k-Qwen2.5-3B (ours),fine-tuned,3721,0.2846,0.598,0.5791,0.4139,0.1552,0.0209,2026-04 (seeded)
 
1
+ Model,Type,N (eval),Pert. Acc.,Clean,Obs Acc.,Action Acc.,Reward Acc.,Transition Acc.,Submitted
2
+ Qwen3-14B (non-thinking),open,3721,0.5292,0.7487,0.7098,0.6053,0.2845,0.4983,2026-04 (seeded)
3
+ MUA-RL-32B,fine-tuned,3721,0.5273,0.6834,0.6558,0.6938,0.2859,0.4657,2026-04 (seeded)
4
+ Qwen3-32B (non-thinking),open,3721,0.5236,0.7538,0.7299,0.6495,0.3879,0.3769,2026-04 (seeded)
5
+ LoopTool-32B,fine-tuned,3721,0.508,0.7789,0.745,0.6591,0.2701,0.3827,2026-04 (seeded)
6
+ MUA-RL-8B,fine-tuned,3721,0.4793,0.6784,0.6558,0.5227,0.2773,0.4489,2026-04 (seeded)
7
+ LoopTool-8B,fine-tuned,3721,0.4764,0.7136,0.6646,0.5407,0.2845,0.4179,2026-04 (seeded)
8
+ MUA-RL-14B,fine-tuned,3721,0.4699,0.6281,0.6168,0.5383,0.2945,0.4263,2026-04 (seeded)
9
+ Qwen3-8B (non-thinking),open,3721,0.4483,0.6734,0.6545,0.5024,0.2644,0.3802,2026-04 (seeded)
10
+ DeepSeek-R1-Distill-Qwen-14B,open,3721,0.4424,0.6181,0.6055,0.4581,0.3003,0.4054,2026-04 (seeded)
11
+ Qwen3.5-9B,open,3721,0.437,0.7085,0.6683,0.5407,0.2974,0.2915,2026-04 (seeded)
12
+ ToolRL-Qwen2.5-1.5B,fine-tuned,3721,0.4316,0.7035,0.6709,0.5299,0.2227,0.325,2026-04 (seeded)
13
+ TL-CodeLLaMA-2,fine-tuned,3721,0.4052,0.6533,0.6294,0.4868,0.1968,0.3199,2026-04 (seeded)
14
+ ToolRL-Qwen2.5-3B,fine-tuned,3721,0.404,0.6382,0.6181,0.4952,0.1882,0.3233,2026-04 (seeded)
15
+ Qwen2.5-3B-Instruct,open,3721,0.3901,0.608,0.5942,0.4127,0.1624,0.371,2026-04 (seeded)
16
+ ToolRL-Llama3.2-3B,fine-tuned,3721,0.3898,0.6281,0.603,0.4569,0.1652,0.3317,2026-04 (seeded)
17
+ Qwen2.5-1.5B-Instruct,open,3721,0.3668,0.5729,0.5327,0.3732,0.1681,0.3677,2026-04 (seeded)
18
+ Llama-3.2-3B-Instruct,open,3721,0.341,0.5176,0.5088,0.3409,0.1451,0.3434,2026-04 (seeded)
19
+ SFT-Clean-4k-Qwen2.5-3B (ours),fine-tuned,3721,0.2669,0.598,0.5791,0.4139,0.1552,0.0209,2026-04 (seeded)
seed_with_18_models.py CHANGED
@@ -51,11 +51,20 @@ def main() -> None:
51
  data = json.loads(scores_path.read_text())
52
  ov = data["overall"]["overall"]
53
  by_mdp = data["overall"]["by_mdp_category"]
 
 
 
 
 
 
 
 
 
54
  rows.append({
55
  "Model": model_name,
56
  "Type": mtype,
57
- "n": ov["n"],
58
- "Overall Acc.": round(ov["accuracy"], 4),
59
  "Clean": round(by_mdp.get("clean", {}).get("accuracy", 0), 4),
60
  "Obs Acc.": round(by_mdp.get("observation",{}).get("accuracy", 0), 4),
61
  "Action Acc.": round(by_mdp.get("action", {}).get("accuracy", 0), 4),
@@ -63,9 +72,9 @@ def main() -> None:
63
  "Transition Acc.": round(by_mdp.get("transition", {}).get("accuracy", 0), 4),
64
  "Submitted": "2026-04 (seeded)",
65
  })
66
- print(f" ✓ {model_name}: overall={rows[-1]['Overall Acc.']}")
67
 
68
- df = pd.DataFrame(rows).sort_values("Overall Acc.", ascending=False)
69
  df.to_csv(OUT, index=False)
70
  print(f"\nWrote {len(df)} rows to {OUT}")
71
 
 
51
  data = json.loads(scores_path.read_text())
52
  ov = data["overall"]["overall"]
53
  by_mdp = data["overall"]["by_mdp_category"]
54
+ by_pert = data["overall"].get("by_perturbation", {})
55
+ # Perturbed-only overall: exclude clean cell so the headline is the
56
+ # actual sim-to-real robustness number.
57
+ pert_correct = sum(
58
+ v.get("correct", round(v["accuracy"] * v["n"]))
59
+ for k, v in by_pert.items() if k != "clean"
60
+ )
61
+ pert_n = sum(v["n"] for k, v in by_pert.items() if k != "clean")
62
+ pert_acc = pert_correct / pert_n if pert_n else 0.0
63
  rows.append({
64
  "Model": model_name,
65
  "Type": mtype,
66
+ "N (eval)": ov["n"],
67
+ "Pert. Acc.": round(pert_acc, 4),
68
  "Clean": round(by_mdp.get("clean", {}).get("accuracy", 0), 4),
69
  "Obs Acc.": round(by_mdp.get("observation",{}).get("accuracy", 0), 4),
70
  "Action Acc.": round(by_mdp.get("action", {}).get("accuracy", 0), 4),
 
72
  "Transition Acc.": round(by_mdp.get("transition", {}).get("accuracy", 0), 4),
73
  "Submitted": "2026-04 (seeded)",
74
  })
75
+ print(f" ✓ {model_name}: pert={rows[-1]['Pert. Acc.']:.4f} clean={rows[-1]['Clean']:.4f}")
76
 
77
+ df = pd.DataFrame(rows).sort_values("Pert. Acc.", ascending=False)
78
  df.to_csv(OUT, index=False)
79
  print(f"\nWrote {len(df)} rows to {OUT}")
80