Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 5,973 Bytes
5f0f535 | 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | """
Full-duplex voice agent benchmark: conditions, metrics, CSV columns.
Import-light (no torch, pandas, or gradio) so a future Hub Job worker can share it.
Two acoustic conditions:
farfield agent on a device across the room (reverberant room, distant user)
glasses agent on smart glasses (mics near the wearer's mouth, open-ear speakers
right next to the mics, bystanders at conversation distance)
Metrics follow Full-Duplex-Bench (v1 / v1.5) where one exists. Every per-condition
value is stored in its own CSV column named ``<metric>_<condition>``
(e.g. ``pause_tor_glasses``). Rates are fractions (0-1), latencies are seconds.
"""
from __future__ import annotations
from dataclasses import dataclass
# Analysis-tab task value. Not a submit task: there is no duplex evaluation worker yet.
TASK_DUPLEX = "duplex"
ANALYSIS_TASK_CHOICE: tuple[str, str] = ("Full-duplex voice agents", TASK_DUPLEX)
def is_duplex(task: str | None) -> bool:
return (task or "").strip().lower() == TASK_DUPLEX
# ---------------------------------------------------------------------------
# Conditions
# ---------------------------------------------------------------------------
@dataclass(frozen=True)
class DuplexCondition:
key: str
label: str
description: str
CONDITIONS: tuple[DuplexCondition, ...] = (
DuplexCondition(
"farfield",
"Far field",
"The agent runs on a device across the room. The user talks from a distance in a "
"reverberant, noisy room.",
),
DuplexCondition(
"glasses",
"Smart glasses",
"The agent runs on head-worn glasses. The mics are close to the wearer's mouth, the "
"open-ear speakers sit next to the mics, and bystanders talk at conversation distance.",
),
)
CONDITIONS_BY_KEY: dict[str, DuplexCondition] = {c.key: c for c in CONDITIONS}
CONDITION_KEYS: tuple[str, ...] = tuple(c.key for c in CONDITIONS)
VIEW_ALL = "all"
VIEWS: tuple[tuple[str, str], ...] = (
("Both conditions", VIEW_ALL),
*((c.label, c.key) for c in CONDITIONS),
)
def conditions_for_view(view: str | None) -> tuple[str, ...]:
"""Condition keys averaged by a view (``all`` averages both)."""
v = (view or VIEW_ALL).strip().lower()
return (v,) if v in CONDITIONS_BY_KEY else CONDITION_KEYS
def view_label(view: str | None) -> str:
return next((label for label, key in VIEWS if key == (view or VIEW_ALL)), VIEWS[0][0])
# ---------------------------------------------------------------------------
# Metrics
# ---------------------------------------------------------------------------
@dataclass(frozen=True)
class DuplexMetric:
key: str
label: str
description: str
unit: str # "rate" (fraction 0-1), "s" (seconds), "jsd" (0-1), "score" (0-5)
lower_is_better: bool
METRICS: tuple[DuplexMetric, ...] = (
DuplexMetric(
"pause_tor",
"Pause takeover rate",
"Share of mid-sentence user pauses where the agent takes the floor.",
"rate",
True,
),
DuplexMetric(
"turn_tor",
"Turn-taking rate",
"Share of finished user turns where the agent answers.",
"rate",
False,
),
DuplexMetric(
"bargein_tor",
"Barge-in success rate",
"Share of user interruptions where the agent stops and answers the new request.",
"rate",
False,
),
DuplexMetric(
"false_bargein",
"False barge-in rate",
"Share of non-user speech (bystanders, TV, the user talking to someone else) where the "
"agent stops or answers.",
"rate",
True,
),
DuplexMetric(
"echo_stop",
"Echo self-interruption rate",
"Share of agent turns that the agent cuts off because it hears its own voice, with no "
"user speech.",
"rate",
True,
),
DuplexMetric(
"bc_jsd",
"Backchannel timing JSD",
"Jensen-Shannon divergence between the agent's and human backchannel timing (0 = human-like).",
"jsd",
True,
),
DuplexMetric(
"resp_latency_s",
"Response latency",
"Seconds from the end of the user's turn to the agent's first speech.",
"s",
True,
),
DuplexMetric(
"stop_latency_s",
"Stop latency",
"Seconds from the start of a user barge-in until the agent is silent.",
"s",
True,
),
DuplexMetric(
"bargein_score",
"Barge-in reply quality",
"LLM-judge score (0-5) of the agent's answer after a barge-in.",
"score",
False,
),
)
METRICS_BY_KEY: dict[str, DuplexMetric] = {m.key: m for m in METRICS}
METRIC_KEYS: tuple[str, ...] = tuple(m.key for m in METRICS)
@dataclass(frozen=True)
class Behavior:
"""One turn-taking behaviour as a failure rate (lower is better)."""
key: str
label: str
metric: str
invert: bool # failure = 1 - metric when the stored metric is a success rate
# The interaction error is the mean of these five failure rates.
BEHAVIORS: tuple[Behavior, ...] = (
Behavior("pause", "Pause takeover", "pause_tor", False),
Behavior("turn", "Missed turns", "turn_tor", True),
Behavior("bargein", "Missed barge-ins", "bargein_tor", True),
Behavior("false_bargein", "False barge-ins", "false_bargein", False),
Behavior("echo", "Echo self-stops", "echo_stop", False),
)
BEHAVIORS_BY_KEY: dict[str, Behavior] = {b.key: b for b in BEHAVIORS}
def metric_column(metric: str, cond_key: str) -> str:
return f"{metric}_{cond_key}"
METRIC_COLUMNS: tuple[str, ...] = tuple(
metric_column(m, c) for c in CONDITION_KEYS for m in METRIC_KEYS
)
ARCHITECTURES: tuple[str, ...] = ("End-to-end", "Cascaded")
CSV_FIELDS: list[str] = [
"model_id",
"eval_family",
"architecture",
*METRIC_COLUMNS,
"num_samples",
"submission_notes",
"submitted_at",
]
|