Giuliocc's picture
Publish source-aware model SDK, forty-deliverable evidence and annotated-review tooling
1f5647a verified
Raw History Blame Contribute Delete
2.29 kB
"""Aggregate boundary failure shapes; never publish source rows or annotations."""
import argparse
from collections import Counter, defaultdict
import json
from pathlib import Path
import probe
def overlaps(a, b):
return min(a[1], b[1]) > max(a[0], b[0])
def main(split):
if split == "test":
probe.unlock_receipt()
root = Path(__file__).resolve().parent
records = json.loads((root / f"work/private/{split}_predictions.json").read_text())
counts = defaultdict(Counter)
for record in records:
key = record["method"] + "/" + record["head"]
gold = sorted(set(tuple(x) for x in record["gold"]))
predicted = sorted(set(tuple(x) for x in record["predicted"]))
counts[key]["reference_spans"] += len(gold)
counts[key]["predicted_spans"] += len(predicted)
for span in predicted:
matches = [x for x in gold if overlaps(span, x)]
if span in gold:
counts[key]["exact_reference_matches"] += 1
elif not matches:
counts[key]["predicted_spans_without_reference_overlap"] += 1
elif len(matches) == 1:
counts[key]["partial_boundary_spans"] += 1
else:
counts[key]["predicted_spans_touching_multiple_references"] += 1
for span in gold:
matches = [x for x in predicted if overlaps(span, x)]
if not matches:
counts[key]["reference_spans_without_prediction_overlap"] += 1
elif len(matches) > 1:
counts[key]["reference_spans_fragmented_across_predictions"] += 1
result = {"split": split, "scope": "exploratory aggregate geometry after fixed scoring; no threshold/model changes",
"source_rows_published": False, "reference_unmatched_is_not_proof_of_harmless_or_biased_language": True,
"methods_heads": {key: dict(value) for key, value in counts.items()}}
(root / f"public/{split.upper()}_FAILURE_GEOMETRY.json").write_text(json.dumps(result, indent=2) + "\n")
print(json.dumps(result, indent=2))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--split", choices=("validation", "test"), default="validation")
main(parser.parse_args().split)