foley.eval.panel#
Human-panel infrastructure: blind tasks, a listening page, responses, and the calibration feed (#49).
A model judge is only trusted once it agrees with people (foley.eval.reliability). This
module is the manual-first path that produces those people’s judgements; the panel itself is
run by a person. Three task kinds, one flow:
Build blind tasks from what you want judged:
grade_tasks()(rate one clip 0-3 for a prompt: the scale the judge-vs-human α uses),pairwise_tasks()(2AFC: which of two fits better; feedsfoley.eval.bradley_terry),mushra_tasks()(rate several systems 0-100 against a reference, with a hidden copy of the reference and a low anchor, in the style of ITU-R BS.1534). Sides and order are shuffled with aseed; stimulus ids are opaque.save_tasks()copies every clip toaudio/<stimulus id><ext>(so neither a file name nor the hidden reference’s path gives it away) and writestasks.json(what raters get) andkey.json(which system each stimulus is; keep it from the raters).Run it:
render_panel_html()writes one self-contained page (audio, forms, a “download responses” button) to open in a browser or host anywhere static; or sendtasks.jsonto raters and collect the sameresponses.jsonlby any means. A response is one JSON line:{"rater": ..., "task": ..., "answer": ...}(the answer shape is per kind, seecheck_answer()).Analyse:
pairwise_comparisons()->bradley_terry.fit;screen_mushra()(the hidden-reference rule of ITU-R BS.1534 only; the standard’smid-range anchor rule is not implemented) and
mushra_scores();rating_units()->calibrate_against_judge(), which returns the human-human and judge-vs-humanKrippendorff α (
foley.eval.reliability.calibrate_judge_vs_human()) to put in the calibration report.
Pure stdlib apart from the numpy used in the analysis functions.
Module Attributes
The ordinal fit scale of the judge-vs-human calibration, and what each grade means. |
|
drop a rater who scores the hidden reference under |
|
MUSHRA 0-100 scores binned to the 0-3 grade scale (lower bound of each grade). |
|
A judge is only "promoted" on at least this many raters and rated units; below that α says little (and a panel with no variation in its grades gives α = 1 by construction). |
|
The z of a 95% normal interval on a mean score. |
|
|
Functions
|
Human-human and judge-vs-human agreement, ready for the calibration report. |
|
Raise |
|
Tasks that ask for a 0-3 grade; |
|
Read |
|
Read |
|
Read |
|
|
|
MUSHRA-style tasks; |
|
A 0-100 score as a 0-3 grade (the highest grade whose lower bound the score reaches). |
|
|
|
2AFC tasks; |
|
|
|
Write the panel folder: |
|
|
Classes
|
One clip a rater hears: an opaque |
|
One judgement: |
- foley.eval.panel.GRADE_LABELS = {0: 'wrong: not the sound asked for', 1: 'related: same family, clearly off', 2: 'acceptable: usable for the moment', 3: 'ideal: exactly right'}#
The ordinal fit scale of the judge-vs-human calibration, and what each grade means.
- foley.eval.panel.Key#
keymaps a stimulus id to{"role": ..., "system": ...}(never shown to raters).
- foley.eval.panel.MIN_RATERS = 3#
A judge is only “promoted” on at least this many raters and rated units; below that α says little (and a panel with no variation in its grades gives α = 1 by construction).
- foley.eval.panel.MUSHRA_GRADE_BOUNDS = (0, 25, 60, 85)#
MUSHRA 0-100 scores binned to the 0-3 grade scale (lower bound of each grade).
- foley.eval.panel.MUSHRA_REFERENCE_MIN = 90#
drop a rater who scores the hidden reference under
MUSHRA_REFERENCE_MINin more thanMUSHRA_MAX_VIOLATION_RATEof the trials.- Type:
Post-screening (ITU-R BS.1534)
- class foley.eval.panel.Stimulus(id, clip)[source]#
Bases:
objectOne clip a rater hears: an opaque
idand the audioclip(a path or URL).
- class foley.eval.panel.Task(id, kind, prompt, stimuli, unit='', reference=None)[source]#
Bases:
objectOne judgement:
kind, thepromptshown, thestimuli(shuffled), and aunit.unitnames what is judged (a golden-set unit id); judge-vs-human calibration joins on it. MUSHRA tasks also carry the visiblereferenceclip.
- foley.eval.panel.Z95 = 1.96#
The z of a 95% normal interval on a mean score.
- foley.eval.panel.calibrate_against_judge(units, judge_grades, *, level='ordinal', min_raters=3, min_units=50)[source]#
Human-human and judge-vs-human agreement, ready for the calibration report.
The judge is compared with the humans’ consensus (the per-unit median grade), never as one more rater next to all of them: with many humans who agree with each other, a judge added as a row would borrow their agreement and look reliable whatever it says.
per_rateris α of the judge against each person alone.- Parameters:
units (
Mapping[str,Mapping[str,int]]) –rating_units()’{unit: {rater: grade}}.judge_grades (
Mapping[str,int]) – The model judge’s{unit: grade}for the same units.min_raters (
int) – Fewer raters than this and nothing is promoted.min_units (
int) – Fewer units rated by at least two people than this and nothing is promoted.
- Returns:
AlphaResult | None, “judge_vs_human”: AlphaResult | None, “per_rater”: {rater: alpha}, “n_units”: …, “raters”: […], “insufficient”: […]}``.
human_alphais the humans’ own α (it needs two raters and a unit both rated);judge_vs_humanis the judge against the consensus. AnAlphaResultis neverpromotedwhileinsufficientis non-empty: too few raters, too few doubly-rated units, or human (or judge) grades that do not vary (α is 1 by construction then).- Return type:
- foley.eval.panel.check_answer(task, answer)[source]#
Raise
ValueErrorunlessanswerhas the shapetask.kindtakes.grade: an int in 0-3.2afc: a stimulus id of the task, orNonefor a tie.mushra:{stimulus_id: score 0-100}covering every stimulus.- Return type:
- foley.eval.panel.grade_tasks(units)[source]#
Tasks that ask for a 0-3 grade;
unitsare(unit_id, prompt, clip, system).
- foley.eval.panel.load_responses(path, tasks)[source]#
Read
responses.jsonl(one{"rater", "task", "answer"}per line), validated.A rater answering the same task twice keeps the last answer. Raters are told apart by name only: two people using the same name are merged, so give every rater a unique one.
- foley.eval.panel.mushra_scores(tasks, key, responses, *, raters=None)[source]#
{system: (mean, ci_low, ci_high)}over MUSHRA answers (95% normal interval).Only
raters(default: thosescreen_mushra()accepts). The hidden reference and anchor are reported under their own names.
- foley.eval.panel.mushra_tasks(trials, *, seed=0)[source]#
MUSHRA-style tasks;
trialsare(unit_id, prompt, reference_clip, [(clip, system), ...], anchor_clip).Each task shows the reference, and the systems plus a hidden copy of the reference and (if
anchor_clipis given) a low-quality anchor, in shuffled order.
- foley.eval.panel.mushra_to_grade(score, *, bounds=(0, 25, 60, 85))[source]#
A 0-100 score as a 0-3 grade (the highest grade whose lower bound the score reaches).
- Return type:
- foley.eval.panel.pairwise_comparisons(tasks, key, responses)[source]#
(winner_system, loser_system)for every non-tie 2AFC answer (feedbradley_terry.fit).
- foley.eval.panel.pairwise_tasks(comparisons, *, seed=0)[source]#
2AFC tasks;
comparisonsare(prompt, (clip_a, system_a), (clip_b, system_b)).Which clip is on the left is shuffled per task from
seed.
- foley.eval.panel.rating_units(tasks, key, responses)[source]#
{unit: {rater: grade}}from the grade and MUSHRA answers (the calibration feed).A unit is
"<task.unit>|<system>"for both kinds (one golden unit judged for two systems is two units); a MUSHRA score is binned bymushra_to_grade(). The hidden reference and anchor are not units.
- foley.eval.panel.save_tasks(tasks, key, directory, *, audio_dir='audio')[source]#
Write the panel folder:
tasks.json(for raters),key.json(keep private), the audio.Every clip (a local file) is copied to
<directory>/<audio_dir>/<stimulus id><ext>and the tasks written point at the copies, so a file name never names the system and the hidden reference does not share a path with the visible one. The returned tasks are those rewritten ones (hand them tofoley.eval.panel_page.render_panel_html()).- Raises:
FileNotFoundError – A clip is not a local file (fetch it first).
ValueError – Task ids repeat, or the clips are in more than one format (the extension would give a system away).
- Return type: