Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Shivam commited on
Commit ·
751af19
1
Parent(s): cd368da
Visualization fixes
Browse files- analytics.py +85 -62
- app.py +31 -32
- backends/_model_utils.py +36 -0
- backends/granite_speech.py +4 -0
- backends/speechbrain_asr.py +4 -0
- backends/transformers_ctc.py +4 -0
- backends/transformers_pipeline.py +3 -0
- backends/universal.py +3 -0
- constants.py +1 -0
- evaluation/orchestrator.py +4 -0
- init.py +10 -1
- utils_display.py +1 -0
analytics.py
CHANGED
|
@@ -76,15 +76,18 @@ def _log_normalize(values: np.ndarray, *, inverse: bool) -> np.ndarray:
|
|
| 76 |
return out
|
| 77 |
|
| 78 |
|
| 79 |
-
# Axis spec: (
|
| 80 |
-
#
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
("
|
| 86 |
-
("
|
| 87 |
-
("
|
|
|
|
|
|
|
|
|
|
| 88 |
)
|
| 89 |
|
| 90 |
|
|
@@ -143,11 +146,13 @@ def _raw_to_analytics_df(raw: list[dict]) -> pd.DataFrame:
|
|
| 143 |
df[k] = np.nan
|
| 144 |
else:
|
| 145 |
df[k] = pd.to_numeric(df[k], errors="coerce")
|
| 146 |
-
for k in ("eval_wall_time_s", "eval_rtf", "eval_audio_seconds"):
|
| 147 |
if k not in df.columns:
|
| 148 |
df[k] = np.nan
|
| 149 |
else:
|
| 150 |
df[k] = pd.to_numeric(df[k], errors="coerce")
|
|
|
|
|
|
|
| 151 |
live_cols = [c for c in LIVE_SCENARIO_KEYS if c in df.columns]
|
| 152 |
df["avg_wer"] = df[live_cols].mean(axis=1, skipna=True) if live_cols else np.nan
|
| 153 |
df["model_size_mb"] = df["model_id"].apply(_cached_model_size_mb)
|
|
@@ -169,26 +174,31 @@ def plot_robustness_radar(
|
|
| 169 |
title: str = "Model robustness profile — log-normalized, farther from center = stronger",
|
| 170 |
) -> go.Figure:
|
| 171 |
"""
|
| 172 |
-
Fixed 6-axis radar
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
"""
|
| 183 |
if df.empty:
|
| 184 |
return _empty_fig("No leaderboard data yet.")
|
| 185 |
|
| 186 |
d = df.copy().reset_index(drop=True)
|
| 187 |
|
| 188 |
-
axes: list[tuple[str, np.ndarray]] = []
|
| 189 |
-
for label, primary, fallback, inverse in _RADAR_AXES:
|
| 190 |
col_label = label
|
| 191 |
col_name = primary
|
|
|
|
| 192 |
col = (
|
| 193 |
pd.to_numeric(d[primary], errors="coerce")
|
| 194 |
if primary in d.columns
|
|
@@ -198,8 +208,11 @@ def plot_robustness_radar(
|
|
| 198 |
col = pd.to_numeric(d[fallback], errors="coerce")
|
| 199 |
col_label = f"{label}*"
|
| 200 |
col_name = fallback
|
|
|
|
| 201 |
strength = _log_normalize(col.to_numpy(), inverse=inverse)
|
| 202 |
-
axes.append(
|
|
|
|
|
|
|
| 203 |
|
| 204 |
labels = [a[0] for a in axes]
|
| 205 |
labels_closed = labels + [labels[0]]
|
|
@@ -217,35 +230,35 @@ def plot_robustness_radar(
|
|
| 217 |
continue
|
| 218 |
idx = rows[0]
|
| 219 |
r_vals: list[float] = []
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
for _, strength, raw_series, _src, inv in axes:
|
| 223 |
s = strength[idx]
|
| 224 |
rv = raw_series[idx]
|
| 225 |
r_vals.append(float(s) if np.isfinite(s) else 0.0)
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
r_closed = r_vals + [r_vals[0]]
|
| 229 |
-
raw_closed =
|
| 230 |
-
raw_text = [
|
| 231 |
-
("—" if not np.isfinite(v) else f"{v:.4f}")
|
| 232 |
-
for v in raw_closed
|
| 233 |
-
]
|
| 234 |
|
| 235 |
short = mid.split("/")[-1][:28]
|
| 236 |
fig.add_trace(
|
| 237 |
go.Scatterpolar(
|
| 238 |
r=r_closed,
|
| 239 |
theta=labels_closed,
|
| 240 |
-
customdata=
|
| 241 |
fill="toself",
|
| 242 |
name=short,
|
| 243 |
line=dict(width=2, color=palette[i % len(palette)]),
|
| 244 |
fillcolor=palette[i % len(palette)],
|
| 245 |
opacity=0.35,
|
| 246 |
hovertemplate=(
|
| 247 |
-
f"<b>{short}</b><br>
|
| 248 |
-
"strength: %{r:.2f}<br>
|
|
|
|
| 249 |
),
|
| 250 |
)
|
| 251 |
)
|
|
@@ -282,55 +295,65 @@ def plot_compare_models_across_scenarios(
|
|
| 282 |
df: pd.DataFrame,
|
| 283 |
model_ids: Sequence[str],
|
| 284 |
metric_keys: Sequence[str],
|
| 285 |
-
title: str = "WER
|
| 286 |
) -> go.Figure:
|
| 287 |
"""
|
| 288 |
-
Line chart: x =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
"""
|
| 290 |
metric_keys = [k for k in metric_keys if k in df.columns]
|
| 291 |
-
model_ids = [m for m in model_ids if m]
|
| 292 |
if df.empty or not metric_keys:
|
| 293 |
return _empty_fig("Not enough data.")
|
| 294 |
|
| 295 |
-
|
|
|
|
| 296 |
if sub.empty:
|
| 297 |
return _empty_fig("No matching models.")
|
| 298 |
|
| 299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
fig = go.Figure()
|
| 301 |
palette = qualitative.Plotly * 3
|
| 302 |
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
row = sub[sub["model_id"] == mid]
|
| 308 |
-
if row.empty:
|
| 309 |
-
continue
|
| 310 |
-
ys = []
|
| 311 |
-
for k in metric_keys:
|
| 312 |
-
v = row[k].iloc[0]
|
| 313 |
-
ys.append(float(v) if pd.notna(v) else None)
|
| 314 |
-
short = mid.split("/")[-1][:32]
|
| 315 |
fig.add_trace(
|
| 316 |
go.Scatter(
|
| 317 |
x=x_labels,
|
| 318 |
y=ys,
|
| 319 |
mode="lines+markers",
|
| 320 |
-
name=
|
|
|
|
| 321 |
line=dict(width=2, color=palette[i % len(palette)]),
|
| 322 |
marker=dict(size=8),
|
| 323 |
-
hovertemplate=
|
|
|
|
|
|
|
| 324 |
)
|
| 325 |
)
|
| 326 |
|
|
|
|
|
|
|
| 327 |
fig.update_layout(
|
| 328 |
title=dict(text=title, x=0.5, xanchor="center"),
|
| 329 |
-
xaxis=dict(title="
|
| 330 |
yaxis=dict(title="WER (lower is better)", rangemode="tozero"),
|
| 331 |
template=_TEMPLATE,
|
| 332 |
height=_FIG_HEIGHT,
|
| 333 |
-
margin=dict(l=60, r=120, t=60, b=
|
| 334 |
**_plotly_legend_config(),
|
| 335 |
)
|
| 336 |
return fig
|
|
@@ -416,11 +439,11 @@ def plot_latency_vs_wer(
|
|
| 416 |
|
| 417 |
xm = metric_by_key(y_metric_key)
|
| 418 |
y_label = (xm.short if xm else y_metric_key) + " WER"
|
| 419 |
-
x_title =
|
| 420 |
-
"Total inference wall time (s)"
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
)
|
| 424 |
|
| 425 |
short = d["model_id"].str.split("/").str[-1].str[:28]
|
| 426 |
fig = go.Figure(
|
|
|
|
| 76 |
return out
|
| 77 |
|
| 78 |
|
| 79 |
+
# Axis spec: (strength_label, primary col, fallback col, inverse, raw_display_name, raw_unit)
|
| 80 |
+
# strength_label : what the axis is called on the chart — always phrased so "farther = better".
|
| 81 |
+
# inverse : True if *lower* raw value is better (e.g. WER, memory); False if higher is better (RTF).
|
| 82 |
+
# raw_display_name: human-readable name of the underlying metric, shown in the hover tooltip.
|
| 83 |
+
# raw_unit : optional unit suffix for the raw value in the tooltip.
|
| 84 |
+
_RADAR_AXES: tuple[tuple[str, str, str | None, bool, str, str], ...] = (
|
| 85 |
+
("Overall accuracy", "avg_wer", None, True, "Avg WER", ""),
|
| 86 |
+
("High-SNR accuracy", "wer_high_snr", "wer_clean", True, "High-SNR WER", ""),
|
| 87 |
+
("Distance robustness", "wer_distant", None, True, "Distant WER", ""),
|
| 88 |
+
("Reverb robustness", "wer_highly_reverberant", "wer_reverberant", True, "Reverb WER", ""),
|
| 89 |
+
("Speed", "eval_rtf", None, False, "RTF", "× realtime"),
|
| 90 |
+
("Compactness", "model_size_mb", None, True, "Model size", " MB"),
|
| 91 |
)
|
| 92 |
|
| 93 |
|
|
|
|
| 146 |
df[k] = np.nan
|
| 147 |
else:
|
| 148 |
df[k] = pd.to_numeric(df[k], errors="coerce")
|
| 149 |
+
for k in ("eval_wall_time_s", "eval_rtf", "eval_audio_seconds", "num_params"):
|
| 150 |
if k not in df.columns:
|
| 151 |
df[k] = np.nan
|
| 152 |
else:
|
| 153 |
df[k] = pd.to_numeric(df[k], errors="coerce")
|
| 154 |
+
# Millions of parameters — small, easy to read.
|
| 155 |
+
df["num_params_m"] = df["num_params"] / 1e6
|
| 156 |
live_cols = [c for c in LIVE_SCENARIO_KEYS if c in df.columns]
|
| 157 |
df["avg_wer"] = df[live_cols].mean(axis=1, skipna=True) if live_cols else np.nan
|
| 158 |
df["model_size_mb"] = df["model_id"].apply(_cached_model_size_mb)
|
|
|
|
| 174 |
title: str = "Model robustness profile — log-normalized, farther from center = stronger",
|
| 175 |
) -> go.Figure:
|
| 176 |
"""
|
| 177 |
+
Fixed 6-axis radar — **strength** view. Every axis is phrased so that farther
|
| 178 |
+
from the centre = better, regardless of the raw metric direction:
|
| 179 |
+
|
| 180 |
+
Overall accuracy (lower Avg WER → higher strength)
|
| 181 |
+
High-SNR accuracy (lower High-SNR WER → higher strength; falls back to Clean WER)
|
| 182 |
+
Distance robustness (lower Distant WER → higher strength)
|
| 183 |
+
Reverb robustness (lower Reverb WER → higher strength; falls back to reverb WER)
|
| 184 |
+
Speed (higher RTF → higher strength)
|
| 185 |
+
Compactness (smaller model size → higher strength)
|
| 186 |
+
|
| 187 |
+
Strength is a 0-1 score computed per-axis across **all** leaderboard rows with
|
| 188 |
+
a log transform + global min/max, so axes and hexagon areas are directly
|
| 189 |
+
comparable across models. Axes marked with `*` fall back to a live proxy when
|
| 190 |
+
the planned column is empty; missing values plot as 0 (honestly empty).
|
| 191 |
"""
|
| 192 |
if df.empty:
|
| 193 |
return _empty_fig("No leaderboard data yet.")
|
| 194 |
|
| 195 |
d = df.copy().reset_index(drop=True)
|
| 196 |
|
| 197 |
+
axes: list[tuple[str, np.ndarray, np.ndarray, str, bool, str, str, bool]] = []
|
| 198 |
+
for label, primary, fallback, inverse, raw_disp, raw_unit in _RADAR_AXES:
|
| 199 |
col_label = label
|
| 200 |
col_name = primary
|
| 201 |
+
using_fallback = False
|
| 202 |
col = (
|
| 203 |
pd.to_numeric(d[primary], errors="coerce")
|
| 204 |
if primary in d.columns
|
|
|
|
| 208 |
col = pd.to_numeric(d[fallback], errors="coerce")
|
| 209 |
col_label = f"{label}*"
|
| 210 |
col_name = fallback
|
| 211 |
+
using_fallback = True
|
| 212 |
strength = _log_normalize(col.to_numpy(), inverse=inverse)
|
| 213 |
+
axes.append(
|
| 214 |
+
(col_label, strength, col.to_numpy(), col_name, inverse, raw_disp, raw_unit, using_fallback)
|
| 215 |
+
)
|
| 216 |
|
| 217 |
labels = [a[0] for a in axes]
|
| 218 |
labels_closed = labels + [labels[0]]
|
|
|
|
| 230 |
continue
|
| 231 |
idx = rows[0]
|
| 232 |
r_vals: list[float] = []
|
| 233 |
+
raw_text: list[str] = []
|
| 234 |
+
for _lab, strength, raw_series, _src, inv, raw_disp, raw_unit, using_fb in axes:
|
|
|
|
| 235 |
s = strength[idx]
|
| 236 |
rv = raw_series[idx]
|
| 237 |
r_vals.append(float(s) if np.isfinite(s) else 0.0)
|
| 238 |
+
direction = "lower is better" if inv else "higher is better"
|
| 239 |
+
if not np.isfinite(rv):
|
| 240 |
+
raw_text.append(f"{raw_disp}: — ({direction})")
|
| 241 |
+
else:
|
| 242 |
+
raw_text.append(f"{raw_disp}: {rv:.4f}{raw_unit} ({direction})")
|
| 243 |
+
|
| 244 |
r_closed = r_vals + [r_vals[0]]
|
| 245 |
+
raw_closed = raw_text + [raw_text[0]]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
|
| 247 |
short = mid.split("/")[-1][:28]
|
| 248 |
fig.add_trace(
|
| 249 |
go.Scatterpolar(
|
| 250 |
r=r_closed,
|
| 251 |
theta=labels_closed,
|
| 252 |
+
customdata=raw_closed,
|
| 253 |
fill="toself",
|
| 254 |
name=short,
|
| 255 |
line=dict(width=2, color=palette[i % len(palette)]),
|
| 256 |
fillcolor=palette[i % len(palette)],
|
| 257 |
opacity=0.35,
|
| 258 |
hovertemplate=(
|
| 259 |
+
f"<b>{short}</b><br>"
|
| 260 |
+
"%{theta} strength: %{r:.2f}<br>"
|
| 261 |
+
"%{customdata}<extra></extra>"
|
| 262 |
),
|
| 263 |
)
|
| 264 |
)
|
|
|
|
| 295 |
df: pd.DataFrame,
|
| 296 |
model_ids: Sequence[str],
|
| 297 |
metric_keys: Sequence[str],
|
| 298 |
+
title: str = "WER across models — one line per scenario (click legend to show/hide scenarios)",
|
| 299 |
) -> go.Figure:
|
| 300 |
"""
|
| 301 |
+
Line chart: x = model (sorted by Average WER), y = WER, one trace per scenario.
|
| 302 |
+
|
| 303 |
+
Scaling to more models now just extends the x axis instead of adding more traces,
|
| 304 |
+
which keeps the legend small (≤ #scenarios) and makes cross-scenario comparisons
|
| 305 |
+
for the same model trivial (read a vertical slice).
|
| 306 |
+
|
| 307 |
+
`model_ids` filters which models appear on the x axis; empty / None → all rows.
|
| 308 |
"""
|
| 309 |
metric_keys = [k for k in metric_keys if k in df.columns]
|
|
|
|
| 310 |
if df.empty or not metric_keys:
|
| 311 |
return _empty_fig("Not enough data.")
|
| 312 |
|
| 313 |
+
selected = [m for m in (model_ids or []) if m]
|
| 314 |
+
sub = df[df["model_id"].isin(selected)].copy() if selected else df.copy()
|
| 315 |
if sub.empty:
|
| 316 |
return _empty_fig("No matching models.")
|
| 317 |
|
| 318 |
+
# Sort models by Average WER ascending so the x axis reads best → worst.
|
| 319 |
+
if "avg_wer" in sub.columns:
|
| 320 |
+
sub = sub.sort_values("avg_wer", ascending=True, na_position="last")
|
| 321 |
+
sub = sub.reset_index(drop=True)
|
| 322 |
+
|
| 323 |
+
x_labels = sub["model_id"].str.split("/").str[-1].str[:32].tolist()
|
| 324 |
+
full_ids = sub["model_id"].tolist()
|
| 325 |
+
|
| 326 |
fig = go.Figure()
|
| 327 |
palette = qualitative.Plotly * 3
|
| 328 |
|
| 329 |
+
for i, k in enumerate(metric_keys):
|
| 330 |
+
m = metric_by_key(k)
|
| 331 |
+
scen_label = m.short if m else k
|
| 332 |
+
ys = [float(v) if pd.notna(v) else None for v in sub[k].tolist()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
fig.add_trace(
|
| 334 |
go.Scatter(
|
| 335 |
x=x_labels,
|
| 336 |
y=ys,
|
| 337 |
mode="lines+markers",
|
| 338 |
+
name=scen_label,
|
| 339 |
+
customdata=full_ids,
|
| 340 |
line=dict(width=2, color=palette[i % len(palette)]),
|
| 341 |
marker=dict(size=8),
|
| 342 |
+
hovertemplate=(
|
| 343 |
+
f"<b>%{{customdata}}</b><br>{scen_label}: %{{y:.4f}}<extra></extra>"
|
| 344 |
+
),
|
| 345 |
)
|
| 346 |
)
|
| 347 |
|
| 348 |
+
n_models = len(x_labels)
|
| 349 |
+
tickangle = -45 if n_models > 8 else -25
|
| 350 |
fig.update_layout(
|
| 351 |
title=dict(text=title, x=0.5, xanchor="center"),
|
| 352 |
+
xaxis=dict(title="Model (sorted by Average WER)", tickangle=tickangle, automargin=True),
|
| 353 |
yaxis=dict(title="WER (lower is better)", rangemode="tozero"),
|
| 354 |
template=_TEMPLATE,
|
| 355 |
height=_FIG_HEIGHT,
|
| 356 |
+
margin=dict(l=60, r=120, t=60, b=140),
|
| 357 |
**_plotly_legend_config(),
|
| 358 |
)
|
| 359 |
return fig
|
|
|
|
| 439 |
|
| 440 |
xm = metric_by_key(y_metric_key)
|
| 441 |
y_label = (xm.short if xm else y_metric_key) + " WER"
|
| 442 |
+
x_title = {
|
| 443 |
+
"eval_wall_time_s": "Total inference wall time (s)",
|
| 444 |
+
"eval_rtf": "RTF (audio seconds / inference seconds)",
|
| 445 |
+
"num_params_m": "Parameters (millions)",
|
| 446 |
+
}.get(x_key, x_key)
|
| 447 |
|
| 448 |
short = d["model_id"].str.split("/").str[-1].str[:28]
|
| 449 |
fig = go.Figure(
|
app.py
CHANGED
|
@@ -164,6 +164,7 @@ _METRIC_CHOICES = [
|
|
| 164 |
_LATENCY_X_CHOICES = [
|
| 165 |
("Total eval wall time (s)", "eval_wall_time_s"),
|
| 166 |
("RTF (audio sec ÷ inference sec)", "eval_rtf"),
|
|
|
|
| 167 |
]
|
| 168 |
_LATENCY_Y_CHOICES = [
|
| 169 |
(f"{m.short} WER", m.key)
|
|
@@ -182,7 +183,6 @@ def _analytics_initial():
|
|
| 182 |
sel = ids[: min(5, len(ids))]
|
| 183 |
fig_r = analytics.plot_robustness_radar(df, sel)
|
| 184 |
fig_cmp = analytics.plot_compare_models_across_scenarios(df, sel, line_default)
|
| 185 |
-
fig_clean = analytics.plot_clean_vs_reverb_scatter(df)
|
| 186 |
fig_lat = analytics.plot_latency_vs_wer(df, "eval_wall_time_s", "wer_reverberant")
|
| 187 |
fig_b = analytics.plot_scenario_bar_summary(df, 8)
|
| 188 |
return (
|
|
@@ -192,7 +192,6 @@ def _analytics_initial():
|
|
| 192 |
gr.update(choices=_LATENCY_Y_CHOICES, value="wer_reverberant"),
|
| 193 |
fig_r,
|
| 194 |
fig_cmp,
|
| 195 |
-
fig_clean,
|
| 196 |
fig_lat,
|
| 197 |
fig_b,
|
| 198 |
)
|
|
@@ -209,14 +208,13 @@ def _analytics_apply(models, line_keys, top_n, latency_x, latency_y):
|
|
| 209 |
avail = analytics.available_metric_keys(df)
|
| 210 |
if not lk:
|
| 211 |
lk = avail
|
| 212 |
-
lx = latency_x if latency_x in ("eval_wall_time_s", "eval_rtf") else "eval_wall_time_s"
|
| 213 |
ly = latency_y if latency_y in [m.key for m in SCENARIO_METRICS] else "wer_reverberant"
|
| 214 |
fig_r = analytics.plot_robustness_radar(df, valid_models)
|
| 215 |
fig_cmp = analytics.plot_compare_models_across_scenarios(df, valid_models, lk)
|
| 216 |
-
fig_clean = analytics.plot_clean_vs_reverb_scatter(df)
|
| 217 |
fig_lat = analytics.plot_latency_vs_wer(df, lx, ly)
|
| 218 |
fig_b = analytics.plot_scenario_bar_summary(df, int(top_n))
|
| 219 |
-
return fig_r, fig_cmp,
|
| 220 |
|
| 221 |
|
| 222 |
# ---------------------------------------------------------------------------
|
|
@@ -459,14 +457,20 @@ with gr.Blocks(title=APP_TITLE, theme=_theme, css=LEADERBOARD_CSS) as demo:
|
|
| 459 |
gr.Markdown(
|
| 460 |
"Charts are **interactive (Plotly)**: use the **legend** to show or hide traces "
|
| 461 |
"(single click toggles, double‑click isolates), drag to **zoom**, and **hover** for values. "
|
| 462 |
-
"**Robustness radar** plots each selected model on 6 fixed
|
| 463 |
-
"**
|
| 464 |
-
"
|
| 465 |
-
"
|
| 466 |
-
"
|
| 467 |
-
"
|
| 468 |
-
"
|
| 469 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
"**Bars** group core scenarios for the top models."
|
| 471 |
)
|
| 472 |
with gr.Row():
|
|
@@ -494,23 +498,20 @@ with gr.Blocks(title=APP_TITLE, theme=_theme, css=LEADERBOARD_CSS) as demo:
|
|
| 494 |
an_apply = gr.Button("Apply / refresh charts", variant="primary")
|
| 495 |
with gr.Row():
|
| 496 |
an_plot_radar = gr.Plot(label="Robustness radar (6 axes, strength 0–1)")
|
| 497 |
-
an_plot_compare = gr.Plot(label="WER
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
value="wer_reverberant",
|
| 512 |
-
)
|
| 513 |
-
an_plot_latency = gr.Plot(label="Latency vs WER")
|
| 514 |
an_plot_bar = gr.Plot(label="Core scenarios — top models (grouped)")
|
| 515 |
|
| 516 |
an_apply.click(
|
|
@@ -525,7 +526,6 @@ with gr.Blocks(title=APP_TITLE, theme=_theme, css=LEADERBOARD_CSS) as demo:
|
|
| 525 |
outputs=[
|
| 526 |
an_plot_radar,
|
| 527 |
an_plot_compare,
|
| 528 |
-
an_plot_clean,
|
| 529 |
an_plot_latency,
|
| 530 |
an_plot_bar,
|
| 531 |
],
|
|
@@ -571,7 +571,6 @@ with gr.Blocks(title=APP_TITLE, theme=_theme, css=LEADERBOARD_CSS) as demo:
|
|
| 571 |
an_latency_y,
|
| 572 |
an_plot_radar,
|
| 573 |
an_plot_compare,
|
| 574 |
-
an_plot_clean,
|
| 575 |
an_plot_latency,
|
| 576 |
an_plot_bar,
|
| 577 |
],
|
|
|
|
| 164 |
_LATENCY_X_CHOICES = [
|
| 165 |
("Total eval wall time (s)", "eval_wall_time_s"),
|
| 166 |
("RTF (audio sec ÷ inference sec)", "eval_rtf"),
|
| 167 |
+
("Parameters (millions)", "num_params_m"),
|
| 168 |
]
|
| 169 |
_LATENCY_Y_CHOICES = [
|
| 170 |
(f"{m.short} WER", m.key)
|
|
|
|
| 183 |
sel = ids[: min(5, len(ids))]
|
| 184 |
fig_r = analytics.plot_robustness_radar(df, sel)
|
| 185 |
fig_cmp = analytics.plot_compare_models_across_scenarios(df, sel, line_default)
|
|
|
|
| 186 |
fig_lat = analytics.plot_latency_vs_wer(df, "eval_wall_time_s", "wer_reverberant")
|
| 187 |
fig_b = analytics.plot_scenario_bar_summary(df, 8)
|
| 188 |
return (
|
|
|
|
| 192 |
gr.update(choices=_LATENCY_Y_CHOICES, value="wer_reverberant"),
|
| 193 |
fig_r,
|
| 194 |
fig_cmp,
|
|
|
|
| 195 |
fig_lat,
|
| 196 |
fig_b,
|
| 197 |
)
|
|
|
|
| 208 |
avail = analytics.available_metric_keys(df)
|
| 209 |
if not lk:
|
| 210 |
lk = avail
|
| 211 |
+
lx = latency_x if latency_x in ("eval_wall_time_s", "eval_rtf", "num_params_m") else "eval_wall_time_s"
|
| 212 |
ly = latency_y if latency_y in [m.key for m in SCENARIO_METRICS] else "wer_reverberant"
|
| 213 |
fig_r = analytics.plot_robustness_radar(df, valid_models)
|
| 214 |
fig_cmp = analytics.plot_compare_models_across_scenarios(df, valid_models, lk)
|
|
|
|
| 215 |
fig_lat = analytics.plot_latency_vs_wer(df, lx, ly)
|
| 216 |
fig_b = analytics.plot_scenario_bar_summary(df, int(top_n))
|
| 217 |
+
return fig_r, fig_cmp, fig_lat, fig_b
|
| 218 |
|
| 219 |
|
| 220 |
# ---------------------------------------------------------------------------
|
|
|
|
| 457 |
gr.Markdown(
|
| 458 |
"Charts are **interactive (Plotly)**: use the **legend** to show or hide traces "
|
| 459 |
"(single click toggles, double‑click isolates), drag to **zoom**, and **hover** for values. "
|
| 460 |
+
"**Robustness radar** plots each selected model on 6 fixed **strength** axes — "
|
| 461 |
+
"**Overall accuracy**, **High‑SNR accuracy**, **Distance robustness**, **Reverb robustness**, "
|
| 462 |
+
"**Speed**, **Compactness**. Every axis is phrased so that farther from the centre = better "
|
| 463 |
+
"(e.g. Overall accuracy inverts WER, Compactness inverts model size). Strength is a 0–1 score "
|
| 464 |
+
"computed globally across all leaderboard rows with a log transform, so axes and hexagons are "
|
| 465 |
+
"directly comparable. Axes marked with `*` fall back to a live proxy when the planned column is "
|
| 466 |
+
"empty (High‑SNR → Clean; Reverb → Reverberant). Hover any vertex to see the raw metric value "
|
| 467 |
+
"and its direction. **WER across models** plots one line per scenario with models on the x axis "
|
| 468 |
+
"(sorted by Average WER, best→worst). Adding more models extends the x axis instead of cluttering "
|
| 469 |
+
"the legend, and a vertical slice gives you that model's numbers at a glance. "
|
| 470 |
+
"**Speed vs accuracy** uses total inference wall time, RTF, or parameter count on the x axis and a "
|
| 471 |
+
"chosen scenario WER on the y axis "
|
| 472 |
+
"(timing appears after new evaluations that record `eval_wall_time_s` / `eval_rtf`, and parameter "
|
| 473 |
+
"counts after evaluations that record `num_params`). "
|
| 474 |
"**Bars** group core scenarios for the top models."
|
| 475 |
)
|
| 476 |
with gr.Row():
|
|
|
|
| 498 |
an_apply = gr.Button("Apply / refresh charts", variant="primary")
|
| 499 |
with gr.Row():
|
| 500 |
an_plot_radar = gr.Plot(label="Robustness radar (6 axes, strength 0–1)")
|
| 501 |
+
an_plot_compare = gr.Plot(label="WER across models — one line per scenario")
|
| 502 |
+
gr.Markdown("### Speed vs accuracy")
|
| 503 |
+
with gr.Row():
|
| 504 |
+
an_latency_x = gr.Dropdown(
|
| 505 |
+
label="X axis (speed)",
|
| 506 |
+
choices=_LATENCY_X_CHOICES,
|
| 507 |
+
value="eval_wall_time_s",
|
| 508 |
+
)
|
| 509 |
+
an_latency_y = gr.Dropdown(
|
| 510 |
+
label="Y axis (WER scenario)",
|
| 511 |
+
choices=_LATENCY_Y_CHOICES,
|
| 512 |
+
value="wer_reverberant",
|
| 513 |
+
)
|
| 514 |
+
an_plot_latency = gr.Plot(label="Speed vs WER")
|
|
|
|
|
|
|
|
|
|
| 515 |
an_plot_bar = gr.Plot(label="Core scenarios — top models (grouped)")
|
| 516 |
|
| 517 |
an_apply.click(
|
|
|
|
| 526 |
outputs=[
|
| 527 |
an_plot_radar,
|
| 528 |
an_plot_compare,
|
|
|
|
| 529 |
an_plot_latency,
|
| 530 |
an_plot_bar,
|
| 531 |
],
|
|
|
|
| 571 |
an_latency_y,
|
| 572 |
an_plot_radar,
|
| 573 |
an_plot_compare,
|
|
|
|
| 574 |
an_plot_latency,
|
| 575 |
an_plot_bar,
|
| 576 |
],
|
backends/_model_utils.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Model-introspection helpers shared across backends."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def count_params(module) -> int:
|
| 7 |
+
"""
|
| 8 |
+
Return the total number of parameters of a PyTorch `nn.Module`-like object.
|
| 9 |
+
|
| 10 |
+
Works for standard Transformers models (they are `nn.Module` subclasses) and for
|
| 11 |
+
SpeechBrain's `Pretrained` base class (also an `nn.Module` subclass). Returns 0 if
|
| 12 |
+
the object has no `.parameters()` method or counting fails for any reason — we
|
| 13 |
+
treat parameter counts as best-effort metadata, never a hard requirement.
|
| 14 |
+
"""
|
| 15 |
+
if module is None:
|
| 16 |
+
return 0
|
| 17 |
+
params_fn = getattr(module, "parameters", None)
|
| 18 |
+
if not callable(params_fn):
|
| 19 |
+
return 0
|
| 20 |
+
try:
|
| 21 |
+
total = 0
|
| 22 |
+
for p in params_fn():
|
| 23 |
+
numel = getattr(p, "numel", None)
|
| 24 |
+
if callable(numel):
|
| 25 |
+
total += int(numel())
|
| 26 |
+
return total
|
| 27 |
+
except Exception:
|
| 28 |
+
return 0
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def attach_params(fn, module) -> None:
|
| 32 |
+
"""Convenience: attach the param count of `module` to `fn._num_params`."""
|
| 33 |
+
try:
|
| 34 |
+
fn._num_params = count_params(module)
|
| 35 |
+
except Exception:
|
| 36 |
+
fn._num_params = 0
|
backends/granite_speech.py
CHANGED
|
@@ -14,6 +14,8 @@ import numpy as np
|
|
| 14 |
import torch
|
| 15 |
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor
|
| 16 |
|
|
|
|
|
|
|
| 17 |
_DEFAULT_PROMPT = "<|audio|>can you transcribe the speech into a written format?"
|
| 18 |
|
| 19 |
|
|
@@ -65,6 +67,8 @@ def build_transcriber(model_id: str, device_str: str) -> tuple[Callable[..., str
|
|
| 65 |
)
|
| 66 |
return str(output_text[0]).strip() if output_text else ""
|
| 67 |
|
|
|
|
|
|
|
| 68 |
def cleanup() -> None:
|
| 69 |
nonlocal model, processor
|
| 70 |
del model, processor
|
|
|
|
| 14 |
import torch
|
| 15 |
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor
|
| 16 |
|
| 17 |
+
from ._model_utils import attach_params
|
| 18 |
+
|
| 19 |
_DEFAULT_PROMPT = "<|audio|>can you transcribe the speech into a written format?"
|
| 20 |
|
| 21 |
|
|
|
|
| 67 |
)
|
| 68 |
return str(output_text[0]).strip() if output_text else ""
|
| 69 |
|
| 70 |
+
attach_params(transcribe, model)
|
| 71 |
+
|
| 72 |
def cleanup() -> None:
|
| 73 |
nonlocal model, processor
|
| 74 |
del model, processor
|
backends/speechbrain_asr.py
CHANGED
|
@@ -21,6 +21,8 @@ from collections.abc import Callable
|
|
| 21 |
import numpy as np
|
| 22 |
import torch
|
| 23 |
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def _load_model(model_id: str, device_str: str, savedir: str):
|
| 26 |
"""Try the two common SpeechBrain ASR interfaces."""
|
|
@@ -61,6 +63,8 @@ def build_transcriber(model_id: str, device_str: str) -> tuple[Callable[..., str
|
|
| 61 |
preds, _tokens = model.transcribe_batch(wav, wav_lens)
|
| 62 |
return str(preds[0]).strip() if preds else ""
|
| 63 |
|
|
|
|
|
|
|
| 64 |
def cleanup() -> None:
|
| 65 |
nonlocal model
|
| 66 |
del model
|
|
|
|
| 21 |
import numpy as np
|
| 22 |
import torch
|
| 23 |
|
| 24 |
+
from ._model_utils import attach_params
|
| 25 |
+
|
| 26 |
|
| 27 |
def _load_model(model_id: str, device_str: str, savedir: str):
|
| 28 |
"""Try the two common SpeechBrain ASR interfaces."""
|
|
|
|
| 63 |
preds, _tokens = model.transcribe_batch(wav, wav_lens)
|
| 64 |
return str(preds[0]).strip() if preds else ""
|
| 65 |
|
| 66 |
+
attach_params(transcribe, model)
|
| 67 |
+
|
| 68 |
def cleanup() -> None:
|
| 69 |
nonlocal model
|
| 70 |
del model
|
backends/transformers_ctc.py
CHANGED
|
@@ -10,6 +10,8 @@ import numpy as np
|
|
| 10 |
import torch
|
| 11 |
from transformers import AutoModelForCTC, AutoProcessor
|
| 12 |
|
|
|
|
|
|
|
| 13 |
|
| 14 |
def build_transcriber(model_id: str, device_str: str) -> tuple[Callable[..., str], Callable[[], None]]:
|
| 15 |
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
|
@@ -30,6 +32,8 @@ def build_transcriber(model_id: str, device_str: str) -> tuple[Callable[..., str
|
|
| 30 |
text = processor.batch_decode(pred_ids)[0]
|
| 31 |
return text
|
| 32 |
|
|
|
|
|
|
|
| 33 |
def cleanup() -> None:
|
| 34 |
nonlocal model, processor
|
| 35 |
del model, processor
|
|
|
|
| 10 |
import torch
|
| 11 |
from transformers import AutoModelForCTC, AutoProcessor
|
| 12 |
|
| 13 |
+
from ._model_utils import attach_params
|
| 14 |
+
|
| 15 |
|
| 16 |
def build_transcriber(model_id: str, device_str: str) -> tuple[Callable[..., str], Callable[[], None]]:
|
| 17 |
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
|
|
|
| 32 |
text = processor.batch_decode(pred_ids)[0]
|
| 33 |
return text
|
| 34 |
|
| 35 |
+
attach_params(transcribe, model)
|
| 36 |
+
|
| 37 |
def cleanup() -> None:
|
| 38 |
nonlocal model, processor
|
| 39 |
del model, processor
|
backends/transformers_pipeline.py
CHANGED
|
@@ -10,6 +10,7 @@ from typing import Any
|
|
| 10 |
import numpy as np
|
| 11 |
|
| 12 |
from ._audio_utils import safe_pad_audio
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
def build_transcriber(model_id: str, device_int: int) -> tuple[Callable[..., str], Callable[[], None]]:
|
|
@@ -28,6 +29,8 @@ def build_transcriber(model_id: str, device_int: int) -> tuple[Callable[..., str
|
|
| 28 |
out = pipe({"raw": padded, "sampling_rate": sampling_rate})
|
| 29 |
return str(out["text"])
|
| 30 |
|
|
|
|
|
|
|
| 31 |
def cleanup() -> None:
|
| 32 |
nonlocal pipe
|
| 33 |
del pipe
|
|
|
|
| 10 |
import numpy as np
|
| 11 |
|
| 12 |
from ._audio_utils import safe_pad_audio
|
| 13 |
+
from ._model_utils import attach_params
|
| 14 |
|
| 15 |
|
| 16 |
def build_transcriber(model_id: str, device_int: int) -> tuple[Callable[..., str], Callable[[], None]]:
|
|
|
|
| 29 |
out = pipe({"raw": padded, "sampling_rate": sampling_rate})
|
| 30 |
return str(out["text"])
|
| 31 |
|
| 32 |
+
attach_params(transcribe, getattr(pipe, "model", None))
|
| 33 |
+
|
| 34 |
def cleanup() -> None:
|
| 35 |
nonlocal pipe
|
| 36 |
del pipe
|
backends/universal.py
CHANGED
|
@@ -30,6 +30,7 @@ import torch
|
|
| 30 |
from transformers import AutoModel, AutoModelForSpeechSeq2Seq, AutoProcessor
|
| 31 |
|
| 32 |
from ._audio_utils import safe_pad_audio
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
def _safe_max_new_tokens(model, env_override: int | None, default_cap: int = 256) -> int:
|
|
@@ -200,6 +201,8 @@ def build_transcriber(model_id: str, device_str: str) -> tuple[Callable[..., str
|
|
| 200 |
outputs = _generate(model, batch, max_new, language)
|
| 201 |
return _decode(processor, outputs, meta, language)
|
| 202 |
|
|
|
|
|
|
|
| 203 |
def cleanup() -> None:
|
| 204 |
nonlocal model, processor
|
| 205 |
del model, processor
|
|
|
|
| 30 |
from transformers import AutoModel, AutoModelForSpeechSeq2Seq, AutoProcessor
|
| 31 |
|
| 32 |
from ._audio_utils import safe_pad_audio
|
| 33 |
+
from ._model_utils import attach_params
|
| 34 |
|
| 35 |
|
| 36 |
def _safe_max_new_tokens(model, env_override: int | None, default_cap: int = 256) -> int:
|
|
|
|
| 201 |
outputs = _generate(model, batch, max_new, language)
|
| 202 |
return _decode(processor, outputs, meta, language)
|
| 203 |
|
| 204 |
+
attach_params(transcribe, model)
|
| 205 |
+
|
| 206 |
def cleanup() -> None:
|
| 207 |
nonlocal model, processor
|
| 208 |
del model, processor
|
constants.py
CHANGED
|
@@ -82,6 +82,7 @@ convention). That is why scores across models are directly comparable.
|
|
| 82 |
| **WER Clean / Noisy / Reverberant** | WER per condition (lower is better). |
|
| 83 |
| **Eval wall time (s)** | Total server‑side inference time for the full condition set. |
|
| 84 |
| **RTF** | *Audio seconds ÷ inference seconds*. Higher is faster; >1 means faster than real time. |
|
|
|
|
| 85 |
|
| 86 |
Timing depends on the hardware this Space runs on, so treat RTF and wall time as **comparative between submissions**
|
| 87 |
on this leaderboard, not as absolute hardware numbers.
|
|
|
|
| 82 |
| **WER Clean / Noisy / Reverberant** | WER per condition (lower is better). |
|
| 83 |
| **Eval wall time (s)** | Total server‑side inference time for the full condition set. |
|
| 84 |
| **RTF** | *Audio seconds ÷ inference seconds*. Higher is faster; >1 means faster than real time. |
|
| 85 |
+
| **Params (M)** | Total trainable parameters in the loaded model, in millions. |
|
| 86 |
|
| 87 |
Timing depends on the hardware this Space runs on, so treat RTF and wall time as **comparative between submissions**
|
| 88 |
on this leaderboard, not as absolute hardware numbers.
|
evaluation/orchestrator.py
CHANGED
|
@@ -45,9 +45,13 @@ def run_evaluation(
|
|
| 45 |
|
| 46 |
transcribe, cleanup = build_transcriber(family_id, model_id, device_str, device_int)
|
| 47 |
try:
|
|
|
|
|
|
|
|
|
|
| 48 |
results: dict = {
|
| 49 |
"model_id": model_id,
|
| 50 |
"eval_family": resolve_label(family_id),
|
|
|
|
| 51 |
}
|
| 52 |
total_samples = 0
|
| 53 |
total_audio_s = 0.0
|
|
|
|
| 45 |
|
| 46 |
transcribe, cleanup = build_transcriber(family_id, model_id, device_str, device_int)
|
| 47 |
try:
|
| 48 |
+
# Backends attach `transcribe._num_params` via `_model_utils.attach_params`; defaults to 0
|
| 49 |
+
# if the backend couldn't introspect a module.
|
| 50 |
+
num_params = int(getattr(transcribe, "_num_params", 0) or 0)
|
| 51 |
results: dict = {
|
| 52 |
"model_id": model_id,
|
| 53 |
"eval_family": resolve_label(family_id),
|
| 54 |
+
"num_params": num_params,
|
| 55 |
}
|
| 56 |
total_samples = 0
|
| 57 |
total_audio_s = 0.0
|
init.py
CHANGED
|
@@ -49,6 +49,7 @@ CSV_FIELDS = [
|
|
| 49 |
"eval_audio_seconds",
|
| 50 |
"eval_wall_time_s",
|
| 51 |
"eval_rtf",
|
|
|
|
| 52 |
"submission_notes",
|
| 53 |
"submitted_at",
|
| 54 |
]
|
|
@@ -67,7 +68,7 @@ def leaderboard_row_from_eval_result(
|
|
| 67 |
if key in result and result[key] is not None:
|
| 68 |
row[key] = str(result[key])
|
| 69 |
row["num_samples"] = str(result.get("num_samples", ""))
|
| 70 |
-
for k in ("eval_audio_seconds", "eval_wall_time_s", "eval_rtf"):
|
| 71 |
if k in result and result[k] is not None and result[k] != "":
|
| 72 |
row[k] = str(result[k])
|
| 73 |
row["submission_notes"] = (submission_notes or "").strip()[:4000]
|
|
@@ -203,6 +204,14 @@ def load_results() -> pd.DataFrame:
|
|
| 203 |
else:
|
| 204 |
display_df["RTF"] = "NA"
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
display_df["Submitted"] = raw_df["submitted_at"].apply(_format_timestamp)
|
| 207 |
|
| 208 |
return display_df
|
|
|
|
| 49 |
"eval_audio_seconds",
|
| 50 |
"eval_wall_time_s",
|
| 51 |
"eval_rtf",
|
| 52 |
+
"num_params",
|
| 53 |
"submission_notes",
|
| 54 |
"submitted_at",
|
| 55 |
]
|
|
|
|
| 68 |
if key in result and result[key] is not None:
|
| 69 |
row[key] = str(result[key])
|
| 70 |
row["num_samples"] = str(result.get("num_samples", ""))
|
| 71 |
+
for k in ("eval_audio_seconds", "eval_wall_time_s", "eval_rtf", "num_params"):
|
| 72 |
if k in result and result[k] is not None and result[k] != "":
|
| 73 |
row[k] = str(result[k])
|
| 74 |
row["submission_notes"] = (submission_notes or "").strip()[:4000]
|
|
|
|
| 204 |
else:
|
| 205 |
display_df["RTF"] = "NA"
|
| 206 |
|
| 207 |
+
if "num_params" in raw_df.columns:
|
| 208 |
+
params = pd.to_numeric(raw_df["num_params"], errors="coerce")
|
| 209 |
+
display_df["Params (M)"] = params.apply(
|
| 210 |
+
lambda v: round(float(v) / 1e6, 2) if pd.notna(v) and float(v) > 0 else "NA"
|
| 211 |
+
)
|
| 212 |
+
else:
|
| 213 |
+
display_df["Params (M)"] = "NA"
|
| 214 |
+
|
| 215 |
display_df["Submitted"] = raw_df["submitted_at"].apply(_format_timestamp)
|
| 216 |
|
| 217 |
return display_df
|
utils_display.py
CHANGED
|
@@ -23,6 +23,7 @@ class AutoEvalColumn:
|
|
| 23 |
wer_reverb = ColumnContent("WER Reverberant", "number")
|
| 24 |
eval_wall_s = ColumnContent("Eval wall time (s)", "number")
|
| 25 |
eval_rtf = ColumnContent("RTF", "number")
|
|
|
|
| 26 |
submitted = ColumnContent("Submitted", "str")
|
| 27 |
|
| 28 |
|
|
|
|
| 23 |
wer_reverb = ColumnContent("WER Reverberant", "number")
|
| 24 |
eval_wall_s = ColumnContent("Eval wall time (s)", "number")
|
| 25 |
eval_rtf = ColumnContent("RTF", "number")
|
| 26 |
+
params_m = ColumnContent("Params (M)", "number")
|
| 27 |
submitted = ColumnContent("Submitted", "str")
|
| 28 |
|
| 29 |
|