Skip to content

score: the boundary F1 judges each boundary against its partner - #39

Merged
weiwchu merged 1 commit into
mainfrom
boundary-f1-partners
Nov 30, 2026
Merged

weiwchu merged 1 commit into
mainfrom
boundary-f1-partners

Conversation

@weiwchu

@weiwchu weiwchu commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR The label-checked boundary F1 now judges each reference boundary against its partner from the label alignment, as page 3 of the FA-Bench paper defines it. This fixes the two cases tabahi reported in issue #36 and a third found while reviewing it. The word timestamp F1, which ranks the word board, does not move.

FA-Bench reports two boundary F1 scores, wbnd_f1_all_20ms on the word tier and bnd_f1_all_20ms on the phone tier. Each one first checks the labels beside a boundary. Until now it then kept only the times of the boundaries that passed and paired them by distance, closest first. With this PR, each reference boundary meets one system boundary, the one between the same two units in the label alignment. The two count as a hit when they lie within 20 ms.

Score the case from issue #36

from fabench.schema import Interval, Utterance
from fabench.score.core import score_pair


def utt(words):
    return Utterance("u", "timit", "read", "s", "", 16000, 1.0,
                     words=[Interval(w, s, e) for w, s, e in words], phones=[])


# Words a b c. b lasts 25 ms, and the system is 15 ms late on both of its edges.
gold = utt([("a", 0.100, 0.200), ("b", 0.200, 0.225), ("c", 0.225, 0.300)])
hyp = utt([("a", 0.100, 0.215), ("b", 0.215, 0.240), ("c", 0.240, 0.300)])

for rule in ("partner", "time"):
    us = score_pair(gold, hyp, condition="clean", aligner="demo", mode="A",
                    boundary_pairing=rule)
    print(rule, us.wbnd_all)

It prints the boundary counts under each rule.

partner {'n_gold': 4, 'n_hyp': 4, 'hits': 4}
time {'n_gold': 4, 'n_hyp': 4, 'hits': 3}

Every boundary lies 15 ms from its partner, so all four are hits. The old rule paired the reference b|c at 25 ms with the system a|b at 15 ms, and that left the other two without a match.

An error of exactly 20 ms is a hit. In floating point, 0.13 minus 0.11 comes out a hair above 0.02. The new rule allows 20 ms plus the TA_TOL_S guard, as the word timestamp F1 already does.

from fabench.schema import Interval, Utterance
from fabench.score.core import score_pair


def utt(words):
    return Utterance("u", "timit", "read", "s", "", 16000, 1.0,
                     words=[Interval(w, s, e) for w, s, e in words], phones=[])


# The system puts the a|b boundary exactly 20 ms late.
gold = utt([("a", 0.00, 0.11), ("b", 0.11, 0.50)])
hyp = utt([("a", 0.00, 0.13), ("b", 0.13, 0.50)])

for rule in ("partner", "time"):
    us = score_pair(gold, hyp, condition="clean", aligner="demo", mode="A",
                    boundary_pairing=rule)
    print(rule, us.wbnd_all)
partner {'n_gold': 3, 'n_hyp': 3, 'hits': 3}
time {'n_gold': 3, 'n_hyp': 3, 'hits': 2}

What was wrong

The old rule lost hits in two ways and gave one away.

  1. Closest first is not a maximal matching, so a short unit with a steady lag lost a hit (issue Boundary F1 under-counts hits: greedy matcher, float edge at 20 ms, and F1/MAE matched sets disagree #36).
  2. The time pairing had no float guard, so an error of exactly 20 ms could miss (issue Boundary F1 under-counts hits: greedy matcher, float edge at 20 ms, and F1/MAE matched sets disagree #36).
  3. The pairing never used the label alignment, so a reference boundary could be credited against the boundary of another unit.

The third case appears when a 60 ms word meets a 40 ms lag. The new tests score it with the other cases, and you can run them yourself.

pytest fabench/score/test/test_labelled_boundary.py -q

Keep the old rule when you need it

One setting brings the old rule back. Add it to a cell's config and score the cell again.

scoring:
  boundary_pairing: time
fabench score --config <cell>/config.yaml

tests/repro sets time and rebuilds all 40 October 2026 cell units exactly, so the published snapshot stays reproducible. That test needs the frozen October system outputs, which stay on local disks because they carry the corpora's transcripts.

What moves

The boundary F1 of every row can move either way. Only the hit counts change, because the denominators stay the same. The phone board ranks on bnd_f1_all_20ms, so its numbers change when the leaderboard is next rescored. The word board ranks on the word timestamp F1 and stays as it is.

tools/ci.sh lint test selftest passes on this branch, and tests/repro passes on the October inputs.

Credit

tabahi found the problem and reported it in issue #36, so the commit names tabahi as a co-author. Thank you @tabahi. Review is welcome after the merge as well, and a follow-up PR is the way to propose a change.

Next steps

The label-checked boundary F1 gated each boundary on the labels beside it,
then paired the boundaries that passed by time alone, closest first. The label
alignment already names each boundary's partner, the system boundary between
the same two units, and the pairing dropped it. Issue #36 showed the cost. A
short unit with a steady lag lost a hit, and a boundary could be credited
against one of another name.

f1_all now judges a reference boundary against its partner alone, on the word
tier through the word alignment and on the phone tier through the phone
alignment's pairs. A hit lies within 20 ms plus the TA_TOL_S float guard, so
an error of exactly 20 ms counts, as in the word timestamp F1. The
denominators do not change.

scoring.boundary_pairing: time keeps the old rule, and tests/repro pins it to
rebuild the October 2026 snapshot. The two cases from issue #36 and the exact
20 ms case are tests.

Co-authored-by: tabahi <8020255+tabahi@users.noreply.github.com>
@weiwchu
weiwchu merged commit e46f6e3 into main Nov 30, 2026
5 checks passed
@weiwchu
weiwchu deleted the boundary-f1-partners branch November 30, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant