#!/usr/bin/env python3 """The paper's core quantity: are wrong-answer messages still useful? Among LOO events whose message carried a WRONG proposed answer and whose removal CHANGED final correctness, what share of those changes were helpful? PRIVATE REPO: run `hf auth login` first. """ import collections import pyarrow.compute as pc import pyarrow.dataset as ds from huggingface_hub import snapshot_download REPO = "AgentsSci/AAAI_Wrong-but-Useful" PAPER = ((pc.field("protocol_id") == "dhd") & (pc.field("paper_analysis_eligible") == True) # noqa: E712 & (pc.field("actor_model_id").isin(["gemma_4_31b", "gpt_oss_120b"]))) def main() -> None: root = snapshot_download(REPO, repo_type="dataset", allow_patterns=["data/labels/interventional_credit/**"]) credit = ds.dataset(f"{root}/data/labels/interventional_credit", format="parquet", partitioning="hive") tbl = credit.to_table( filter=(PAPER & (pc.field("credit_scope") == "committee_hypothesis") # tri-state: 'null' proposals belong to NEITHER group and are excluded & (pc.field("proposal_correctness_class") == "wrong")), columns=["actor_model_id", "benchmark_id", "signed_effect"]) per_model = collections.defaultdict(lambda: collections.Counter()) for model, _bench, eff in zip(tbl.column(0).to_pylist(), tbl.column(1).to_pylist(), tbl.column(2).to_pylist()): per_model[model][eff] += 1 print("Wrong-answer messages, leave-one-out removal events\n") print(f"{'model':<14}{'helpful':>10}{'harmful':>10}{'no change':>12}" f"{'flips':>9}{'helpful share':>15}") for model, c in sorted(per_model.items()): helpful, harmful, none = c[1], c[-1], c[0] flips = helpful + harmful share = helpful / flips if flips else float("nan") print(f"{model:<14}{helpful:>10,}{harmful:>10,}{none:>12,}" f"{flips:>9,}{share:>14.1%}") print("\nUNIT: these are LOO removal EVENTS, not messages.") print("Note: signed_effect is measured; 'no change' is a measured zero.") print("Missing replays produce NO row here -- missing is never coerced to 0.") print("\nThe paper's headline uses its own bootstrap and slice conventions;") print("this script shows the mechanism, not a restatement of a paper figure.") if __name__ == "__main__": main()