Giuliocc's picture
Publish source-aware model SDK, forty-deliverable evidence and annotated-review tooling
1f5647a verified
Raw History Blame Contribute Delete
1.96 kB
"""Aggregate gold-token reconstruction diagnostics, without source publication."""
from collections import Counter
import json
from pathlib import Path
import probe
def main():
report = {"scope": "gold-token reconstruction diagnostic, not a fitted model score or a guaranteed upper bound",
"splits": {}, "test_accessed": False, "new_human_reviews": 0}
for split in ("train", "validation"):
rows, _, labels, mask, _, _ = probe.features(split)
result = {}
for hi, head in enumerate(probe.HEADS):
totals = {kind: Counter() for kind in ("strict", "relaxed")}
geometry = Counter()
for row in rows:
original = sorted({(x["start"], x["end"]) for x in row["gold"] if x["head"] == head})
y = labels[row["unit_start"]:row["unit_end"], hi].astype(bool)
y &= mask[row["unit_start"]:row["unit_end"]]
reconstructed = probe.predicted_spans(row, y)
geometry["original_distinct_spans"] += len(original)
geometry["gold_token_reconstructed_spans"] += len(reconstructed)
geometry["overlapping_or_touching_same_type_reference_pairs"] += sum(a[1] >= b[0] for i, a in enumerate(original) for b in original[i + 1:])
totals["strict"].update(probe.span_counts(original, reconstructed))
totals["relaxed"].update(probe.span_counts(original, reconstructed, True))
result[head] = {**dict(geometry), "strict_span": {**probe.scores(totals["strict"]), "counts": dict(totals["strict"])},
"relaxed_span": {**probe.scores(totals["relaxed"]), "counts": dict(totals["relaxed"])}}
report["splits"][split] = result
(Path(__file__).resolve().parent / "public/GOLD_TOKEN_RECONSTRUCTION.json").write_text(json.dumps(report, indent=2) + "\n")
print(json.dumps(report, indent=2))
if __name__ == "__main__":
main()