Skip to content

Commit 4b7974f

Browse files
andre15silvaclaude
andcommitted
refactor(paper): redesign transfer table — compact gray in-dist refs, deltas on transfer rows
In-dist rows are now small/gray reference numbers. Transfer rows show value + subscript delta vs. the in-dist baseline on the same evaluation set (Verified→Pro delta vs. Pro in-dist; Pro→Verified delta vs. Verified in-dist). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4da68ff commit 4b7974f

2 files changed

Lines changed: 72 additions & 61 deletions

File tree

paper/transfer_table.tex

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
\begin{table*}[h]
22
\centering
3-
\caption{Cross-dataset transfer AUC-ROC for Laguna-XS2. \emph{In-distribution} probes are trained and evaluated on the same dataset. \emph{Transfer} probes use weights trained on one dataset and evaluated on the other.}
3+
\caption{Cross-dataset transfer AUC-ROC for Laguna-XS2. Gray rows show in-distribution (in-dist) reference performance. Transfer rows show the AUC when probe weights trained on one dataset are evaluated on the other; the subscript shows the difference relative to the in-dist baseline on the \emph{same evaluation set}.}
44
\label{tab:transfer}
55
\begin{tabular}{lcccc}
66
\toprule
77
& Layer 10 & Layer 20 & Layer 30 & Layer 39 \\
88
\midrule
99
\multicolumn{5}{l}{\textit{Syntactic correctness}} \\
10-
\quad In-distribution (Verified) & 0.698 & 0.669 & 0.679 & 0.626 \\
11-
\quad In-distribution (Pro) & \textbf{0.780} & \textbf{0.746} & \textbf{0.757} & \textbf{0.756} \\
12-
\quad Verified $\rightarrow$ Pro & 0.513 & 0.505 & 0.537 & 0.520 \\
13-
\quad Pro $\rightarrow$ Verified & 0.508 & 0.561 & 0.524 & 0.488 \\
10+
\quad\textcolor{gray}{\small In-dist (Verified)} & \textcolor{gray}{\small 0.698} & \textcolor{gray}{\small 0.669} & \textcolor{gray}{\small 0.679} & \textcolor{gray}{\small 0.626} \\
11+
\quad\textcolor{gray}{\small In-dist (Pro)} & \textcolor{gray}{\small 0.780} & \textcolor{gray}{\small 0.746} & \textcolor{gray}{\small 0.757} & \textcolor{gray}{\small 0.756} \\
12+
\quad Verified $\rightarrow$ Pro & 0.513\,{\scriptsize −0.266} & 0.505\,{\scriptsize −0.241} & 0.537\,{\scriptsize −0.220} & 0.520\,{\scriptsize −0.236} \\
13+
\quad Pro $\rightarrow$ Verified & 0.508\,{\scriptsize −0.190} & 0.561\,{\scriptsize −0.108} & 0.524\,{\scriptsize −0.155} & 0.488\,{\scriptsize −0.138} \\
1414
\midrule
1515
\multicolumn{5}{l}{\textit{Functional correctness}} \\
16-
\quad In-distribution (Verified) & \textbf{0.775} & \textbf{0.791} & \textbf{0.769} & \textbf{0.716} \\
17-
\quad In-distribution (Pro) & 0.681 & 0.726 & 0.714 & 0.670 \\
18-
\quad Verified $\rightarrow$ Pro & 0.670 & 0.693 & 0.672 & 0.616 \\
19-
\quad Pro $\rightarrow$ Verified & 0.683 & 0.742 & 0.712 & 0.650 \\
16+
\quad\textcolor{gray}{\small In-dist (Verified)} & \textcolor{gray}{\small 0.775} & \textcolor{gray}{\small 0.791} & \textcolor{gray}{\small 0.769} & \textcolor{gray}{\small 0.716} \\
17+
\quad\textcolor{gray}{\small In-dist (Pro)} & \textcolor{gray}{\small 0.681} & \textcolor{gray}{\small 0.726} & \textcolor{gray}{\small 0.714} & \textcolor{gray}{\small 0.670} \\
18+
\quad Verified $\rightarrow$ Pro & 0.670\,{\scriptsize −0.011} & 0.693\,{\scriptsize −0.033} & 0.672\,{\scriptsize −0.042} & 0.616\,{\scriptsize −0.055} \\
19+
\quad Pro $\rightarrow$ Verified & 0.683\,{\scriptsize −0.092} & 0.742\,{\scriptsize −0.049} & 0.712\,{\scriptsize −0.057} & 0.650\,{\scriptsize −0.066} \\
2020
\midrule
2121
\multicolumn{5}{l}{\textit{Reduces failures}} \\
22-
\quad In-distribution (Verified) & \textbf{0.743} & \textbf{0.769} & \textbf{0.743} & \textbf{0.674} \\
23-
\quad In-distribution (Pro) & 0.681 & 0.718 & 0.697 & 0.657 \\
24-
\quad Verified $\rightarrow$ Pro & 0.654 & 0.690 & 0.654 & 0.573 \\
25-
\quad Pro $\rightarrow$ Verified & 0.636 & 0.684 & 0.668 & 0.610 \\
22+
\quad\textcolor{gray}{\small In-dist (Verified)} & \textcolor{gray}{\small 0.743} & \textcolor{gray}{\small 0.769} & \textcolor{gray}{\small 0.743} & \textcolor{gray}{\small 0.674} \\
23+
\quad\textcolor{gray}{\small In-dist (Pro)} & \textcolor{gray}{\small 0.681} & \textcolor{gray}{\small 0.718} & \textcolor{gray}{\small 0.697} & \textcolor{gray}{\small 0.657} \\
24+
\quad Verified $\rightarrow$ Pro & 0.654\,{\scriptsize −0.026} & 0.690\,{\scriptsize −0.028} & 0.654\,{\scriptsize −0.043} & 0.573\,{\scriptsize −0.084} \\
25+
\quad Pro $\rightarrow$ Verified & 0.636\,{\scriptsize −0.107} & 0.684\,{\scriptsize −0.085} & 0.668\,{\scriptsize −0.075} & 0.610\,{\scriptsize −0.063} \\
2626
\midrule
2727
\multicolumn{5}{l}{\textit{Has regressions}} \\
28-
\quad In-distribution (Verified) & \textbf{0.688} & 0.697 & 0.675 & 0.612 \\
29-
\quad In-distribution (Pro) & 0.645 & \textbf{0.705} & \textbf{0.739} & \textbf{0.691} \\
30-
\quad Verified $\rightarrow$ Pro & 0.560 & 0.658 & 0.634 & 0.601 \\
31-
\quad Pro $\rightarrow$ Verified & 0.583 & 0.631 & 0.604 & 0.530 \\
28+
\quad\textcolor{gray}{\small In-dist (Verified)} & \textcolor{gray}{\small 0.688} & \textcolor{gray}{\small 0.697} & \textcolor{gray}{\small 0.675} & \textcolor{gray}{\small 0.612} \\
29+
\quad\textcolor{gray}{\small In-dist (Pro)} & \textcolor{gray}{\small 0.645} & \textcolor{gray}{\small 0.705} & \textcolor{gray}{\small 0.739} & \textcolor{gray}{\small 0.691} \\
30+
\quad Verified $\rightarrow$ Pro & 0.560\,{\scriptsize −0.084} & 0.658\,{\scriptsize −0.047} & 0.634\,{\scriptsize −0.105} & 0.601\,{\scriptsize −0.090} \\
31+
\quad Pro $\rightarrow$ Verified & 0.583\,{\scriptsize −0.105} & 0.631\,{\scriptsize −0.066} & 0.604\,{\scriptsize −0.071} & 0.530\,{\scriptsize −0.081} \\
3232
\bottomrule
3333
\end{tabular}
3434
\end{table*}

run_paper_figures.py

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,6 @@ def plot_layer_auc(
331331
# Transfer table (cross-dataset generalisation)
332332
# ---------------------------------------------------------------------------
333333

334-
TRANSFER_ROW_LABELS = {
335-
"in_dist_verified": "In-distribution (Verified)",
336-
"in_dist_pro": "In-distribution (Pro)",
337-
"verified_to_pro": "Verified $\\rightarrow$ Pro",
338-
"pro_to_verified": "Pro $\\rightarrow$ Verified",
339-
}
340-
341-
342334
def build_transfer_table(
343335
verified_results_dir: Path,
344336
pro_results_dir: Path,
@@ -351,26 +343,35 @@ def build_transfer_table(
351343
) -> str:
352344
"""Return a LaTeX table comparing in-distribution vs cross-dataset transfer AUC.
353345
354-
Rows: in-dist Verified, in-dist Pro, Verified→Pro, Pro→Verified.
355-
Columns: probe × layer.
346+
Layout per probe:
347+
- Two compact gray reference rows: in-dist Verified / in-dist Pro
348+
- Two main rows showing transfer AUC and delta vs. the corresponding in-dist
349+
baseline (same evaluation set):
350+
Verified→Pro value (±Δ vs. Pro in-dist)
351+
Pro→Verified value (±Δ vs. Verified in-dist)
356352
"""
357353
n_layer_cols = len(layers)
358354
col_spec = "l" + "c" * n_layer_cols
359355
layer_header = " & ".join(f"Layer {l}" for l in layers)
360356

361-
rows = [
362-
("in_dist_verified", verified_results_dir, verified_pooled_run_id),
363-
("in_dist_pro", pro_results_dir, pro_pooled_run_id),
364-
("verified_to_pro", pro_results_dir, verified_to_pro_run_id),
365-
("pro_to_verified", verified_results_dir, pro_to_verified_run_id),
366-
]
357+
def _fmt_delta(delta: float) -> str:
358+
sign = "+" if delta >= 0 else "−"
359+
return rf"{{\scriptsize {sign}{abs(delta):.3f}}}"
360+
361+
def _get_aucs(res_dir, run_id, probe):
362+
res = _load(res_dir, run_id, probe)
363+
if res is None:
364+
return {l: float("nan") for l in layers}
365+
return {l: _weighted_mean(res.get(l, []), "test_auc") for l in layers}
367366

368367
lines = [
369368
r"\begin{table*}[h]",
370369
r"\centering",
371370
r"\caption{Cross-dataset transfer AUC-ROC for Laguna-XS2. "
372-
r"\emph{In-distribution} probes are trained and evaluated on the same dataset. "
373-
r"\emph{Transfer} probes use weights trained on one dataset and evaluated on the other.}",
371+
r"Gray rows show in-distribution (in-dist) reference performance. "
372+
r"Transfer rows show the AUC when probe weights trained on one dataset are "
373+
r"evaluated on the other; the subscript shows the difference relative to the "
374+
r"in-dist baseline on the \emph{same evaluation set}.}",
374375
r"\label{tab:transfer}",
375376
rf"\begin{{tabular}}{{{col_spec}}}",
376377
r"\toprule",
@@ -382,33 +383,43 @@ def build_transfer_table(
382383
probe_label = PROBE_LABELS.get(probe, probe)
383384
lines.append(rf"\multicolumn{{{1 + n_layer_cols}}}{{l}}{{\textit{{{probe_label}}}}} \\")
384385

385-
# Find global best AUC across all rows for bolding
386-
best: dict[int, float] = {}
387-
for _, res_dir, run_id in rows:
388-
res = _load(res_dir, run_id, probe)
389-
if res is None:
390-
continue
391-
for l in layers:
392-
v = _weighted_mean(res.get(l, []), "test_auc")
393-
if not math.isnan(v) and v > best.get(l, float("-inf")):
394-
best[l] = v
386+
# Load all four result sets
387+
v_aucs = _get_aucs(verified_results_dir, verified_pooled_run_id, probe) # in-dist Verified
388+
p_aucs = _get_aucs(pro_results_dir, pro_pooled_run_id, probe) # in-dist Pro
389+
vp_aucs = _get_aucs(pro_results_dir, verified_to_pro_run_id, probe) # Verified→Pro
390+
pv_aucs = _get_aucs(verified_results_dir, pro_to_verified_run_id, probe) # Pro→Verified
395391

396-
for row_key, res_dir, run_id in rows:
397-
res = _load(res_dir, run_id, probe)
398-
row_label = TRANSFER_ROW_LABELS[row_key]
399-
cells = []
400-
for l in layers:
401-
if res is None:
402-
cells.append("—")
403-
continue
404-
v = _weighted_mean(res.get(l, []), "test_auc")
405-
if math.isnan(v):
406-
cells.append("—")
407-
elif not math.isnan(best.get(l, float("nan"))) and abs(v - best[l]) < 1e-9:
408-
cells.append(rf"\textbf{{{v:.3f}}}")
409-
else:
410-
cells.append(f"{v:.3f}")
411-
lines.append(f"\\quad {row_label} & " + " & ".join(cells) + r" \\")
392+
# --- compact gray reference rows ---
393+
def _ref_cell(v):
394+
return rf"\textcolor{{gray}}{{\small {v:.3f}}}" if not math.isnan(v) else "—"
395+
396+
lines.append(
397+
r"\quad\textcolor{gray}{\small In-dist (Verified)} & "
398+
+ " & ".join(_ref_cell(v_aucs[l]) for l in layers) + r" \\"
399+
)
400+
lines.append(
401+
r"\quad\textcolor{gray}{\small In-dist (Pro)} & "
402+
+ " & ".join(_ref_cell(p_aucs[l]) for l in layers) + r" \\"
403+
)
404+
405+
# --- transfer rows with deltas ---
406+
def _transfer_cell(transfer_v, ref_v):
407+
if math.isnan(transfer_v):
408+
return "—"
409+
delta = transfer_v - ref_v if not math.isnan(ref_v) else float("nan")
410+
delta_str = _fmt_delta(delta) if not math.isnan(delta) else ""
411+
return rf"{transfer_v:.3f}\,{delta_str}"
412+
413+
lines.append(
414+
r"\quad Verified $\rightarrow$ Pro & "
415+
+ " & ".join(_transfer_cell(vp_aucs[l], p_aucs[l]) for l in layers)
416+
+ r" \\"
417+
)
418+
lines.append(
419+
r"\quad Pro $\rightarrow$ Verified & "
420+
+ " & ".join(_transfer_cell(pv_aucs[l], v_aucs[l]) for l in layers)
421+
+ r" \\"
422+
)
412423

413424
lines.append(r"\midrule")
414425

0 commit comments

Comments
 (0)