Datasets:
Download scripts/adjudicate_val.py from addyo07/vox-tier2-backup: direct link, hf CLI and curl.
- Browser
- Download file 4.65 kB
-
https://huggingface.co/datasets/addyo07/vox-tier2-backup/resolve/main/scripts/adjudicate_val.py
- Command line
-
hf download hf://datasets/addyo07/vox-tier2-backup/scripts/adjudicate_val.py
-
curl -L -o adjudicate_val.py https://huggingface.co/datasets/addyo07/vox-tier2-backup/resolve/main/scripts/adjudicate_val.py
4.65 kB
| #!/usr/bin/env python3 | |
| """Apply the Phase B adjudication to the val split. | |
| Discipline, because this edits a benchmark AFTER models have been scored on it: | |
| * Adjudication was BLIND — the judge saw only the raw sentences, never a | |
| model prediction, never which row was flagged. | |
| * Only rows where my judgement and the blind judge UNANIMOUSLY agreed on | |
| DISFLUENCY are relabelled. Disagreements stay CLEAN (precision-first). | |
| * Spans are generated by the existing compiler from a substring and asserted | |
| to round-trip, never hand-written as character offsets. | |
| * Every change is written to an audit file. The original file is preserved. | |
| Usage: adjudicate_val.py [--apply] | |
| """ | |
| import json | |
| import sys | |
| sys.path.insert(0, "/opt/vox/sandbox/scripts") | |
| from compiler import compile_candidate_to_example | |
| from schema import RawCandidate | |
| VAL = "/opt/vox/sandbox/corpus/pilot_v2_val.jsonl" | |
| OUT = "/opt/vox/sandbox/corpus/pilot_v2_val_adjudicated.jsonl" | |
| AUDIT = "/opt/vox/sandbox/benchmarks/phaseB_adjudication_APPLIED.json" | |
| # unanimous DISFLUENCY verdicts only (mine + blind judge agreed) | |
| AGREE = { | |
| "vxb_v2_00121": ("not something, Curious, ", "self_correction", 0.90), | |
| "vxb_v2_00150": ("We're just, ", "false_start", 0.75), | |
| "vxb_v2_00368": ("they're just get, ", "false_start", 0.80), | |
| "vxb_v2_00308": ("It does, ", "false_start", 0.80), | |
| "vxb_v2_00228": ("there does seem to be a, right now in verbalizing, ", "false_start", 0.85), | |
| "vxb_v2_00396": ("yeah yeah yeah ", "repetition", 0.85), | |
| "vxb_v2_00175": ("I happen to, ", "false_start", 0.80), | |
| "vxb_v2_00282": (", most awful dull", "repetition", 0.70), | |
| } | |
| # deliberate disagreements -> left CLEAN | |
| KEEP_CLEAN = { | |
| "vxb_v2_00135": "disagreement: I judged ambiguous/keep-CLEAN, blind judge said DISFLUENCY at " | |
| "confidence 0.60 (its own weakest call, and it noted UNCLEAR is defensible). " | |
| "Precision-first => stays CLEAN.", | |
| "vxb_v2_00668": "unanimous CLEAN: sentence-initial 'Well' is a legitimate discourse marker.", | |
| } | |
| # shape defects noted but NOT acted on, so the benchmark is not silently shrunk | |
| SHAPE_DEFECTS = { | |
| "vxb_v2_00396": "2 sentences + lowercase-initial (invariant 3 shape violation)", | |
| "vxb_v2_00175": "leading orphaned ')' ')' transcription artifact", | |
| "vxb_v2_00282": "truncated mid-sentence, ends 'Mrs.'", | |
| } | |
| def main(): | |
| rows = [json.loads(l) for l in open(VAL)] | |
| by_id = {r["id"]: r for r in rows} | |
| audit = {"applied": [], "kept_clean": KEEP_CLEAN, "shape_defects_not_acted_on": SHAPE_DEFECTS, | |
| "policy": "blind adjudication; unanimous DISFLUENCY only; compiler-generated spans", | |
| "base_val": VAL, "out_val": OUT} | |
| failed = [] | |
| for rid, (span_text, kind, conf) in AGREE.items(): | |
| r = by_id[rid] | |
| if span_text not in r["raw_text"]: | |
| failed.append((rid, "span not a verbatim substring")) | |
| continue | |
| # expected clean = deterministic slice cut of that span | |
| i = r["raw_text"].index(span_text) | |
| expected = (r["raw_text"][:i] + r["raw_text"][i + len(span_text):]) | |
| cand = RawCandidate(raw_text=r["raw_text"], clean_text=expected, | |
| disfluent_spans=[span_text]) | |
| ex, why = compile_candidate_to_example(cand, rid) | |
| if ex is None: | |
| failed.append((rid, f"compiler rejected: {why}")) | |
| continue | |
| # compiler's own punctuation/whitespace normalisation is authoritative | |
| gold_clean = ex.clean_text | |
| ex.id = rid | |
| ex.category = "DISFLUENCY" | |
| for s in ex.spans: | |
| s.origin = f"adjudicated:{kind}" | |
| by_id[rid] = json.loads(ex.model_dump_json()) | |
| audit["applied"].append({"id": rid, "kind": kind, "blind_confidence": conf, | |
| "span_text": span_text, | |
| "new_clean_text": gold_clean, | |
| "old_category": "CLEAN"}) | |
| print(f"RELABELLED {rid} {kind:16} span={span_text!r}") | |
| if failed: | |
| print("\nFAILED (left as CLEAN):") | |
| for f in failed: | |
| print(" ", f) | |
| audit["failed"] = failed | |
| out = [by_id[r["id"]] for r in rows] # preserve original ordering | |
| with open(OUT, "w") as f: | |
| for r in out: | |
| f.write(json.dumps(r) + "\n") | |
| json.dump(audit, open(AUDIT, "w"), indent=2) | |
| n_c = sum(1 for r in out if r["category"] == "CLEAN") | |
| n_d = len(out) - n_c | |
| print(f"\nwrote {OUT}") | |
| print(f" CLEAN {n_c} DISFLUENCY {n_d} (was CLEAN 427 / DISFLUENCY 373)") | |
| print(f"audit: {AUDIT}") | |
| if __name__ == "__main__": | |
| main() | |