| |
| """Recompute the manuscript's argument counts from archived per-item records. |
| |
| This checks response scoring and archived finite-study outcomes. It does not |
| rerun inference, construct witnesses, or repeat the finite solvers. |
| """ |
| import argparse |
| from collections import Counter |
| import gzip |
| import json |
| from pathlib import Path |
|
|
| from analyze_visual_judges import number, valid_parsed |
|
|
|
|
| def records(path): |
| opener = gzip.open if path.suffix == ".gz" else open |
| with opener(path, "rt") as handle: |
| return [json.loads(line) for line in handle if line.strip()] |
|
|
|
|
| def check(inputs, finite_path, solver_path): |
| labels = json.loads((inputs / "plotqa/labels.json").read_text()) |
| by_id = {row["item_id"]: row for row in labels} |
| responses = records(inputs / "plotqa/qwen38-flash-next.jsonl.gz") |
| assert len(labels) == len(by_id) == len(responses) == 5000 |
| ids = [row["item_id"] for row in responses] |
| assert len(set(ids)) == 5000 and set(ids) == set(by_id) |
| counts = dict(correct=0, rejected=0, numeric_mismatch=0, unparsed=0, invalid=0) |
| for row in responses: |
| label = by_id[row["item_id"]] |
| if not label["answerable"]: |
| continue |
| parsed = valid_parsed(row) |
| if parsed is None: |
| category = "invalid" |
| elif not parsed["answerable"]: |
| category = "rejected" |
| elif number(parsed["answer"]) is None: |
| category = "unparsed" |
| elif number(parsed["answer"]) == number(label["target"]): |
| category = "correct" |
| else: |
| category = "numeric_mismatch" |
| counts[category] += 1 |
| assert counts == dict(correct=2473, rejected=49, numeric_mismatch=478, |
| unparsed=0, invalid=0), counts |
|
|
| finite = records(finite_path) |
| assert len({row["id"] for row in finite}) == len(finite) == 1024 |
| assert all(row["source_checks_passed"] and row["oracle_agreement"] for row in finite) |
| finite_counts = dict( |
| cases=len(finite), |
| ambiguous=sum(row["oracle_ambiguous"] for row in finite), |
| constant=sum(not row["oracle_ambiguous"] for row in finite), |
| dependency_false_missing=sum(row["dependency_cut_claims_missing"] |
| and not row["oracle_ambiguous"] for row in finite), |
| endpoint_missed_ambiguity=sum(not row["endpoint_separates"] |
| and row["oracle_ambiguous"] for row in finite), |
| archived_proofs_verified=sum(row["proof_verified"] is True for row in finite), |
| ) |
| assert finite_counts == dict(cases=1024, ambiguous=610, constant=414, |
| dependency_false_missing=132, |
| endpoint_missed_ambiguity=90, |
| archived_proofs_verified=610), finite_counts |
| solver = records(solver_path) |
| assert len({(row["cohort"], row["id"]) for row in solver}) == len(solver) == 1456 |
| assert all(row["source_checks_passed"] for row in solver) |
| assert all(row["truth"] == row["smt_status"] == row["enumeration_status"] |
| for row in solver) |
| solver_counts = Counter(row["truth"] for row in solver) |
| assert dict(solver_counts) == dict(ambiguous=822, constant=634), solver_counts |
| finite_truth = {row["id"]: "ambiguous" if row["oracle_ambiguous"] else "constant" |
| for row in finite} |
| original_solver = {row["id"]: row["truth"] for row in solver if row["cohort"] == "original"} |
| assert original_solver == finite_truth |
| assert sum(row["dependency_false_missing"] for row in solver) == 225 |
| return { |
| "status": "passed", |
| "source": "archived per-response and per-case records", |
| "qwen_positive_chart_views": counts, |
| "finite_program_cases": finite_counts, |
| "enumeration_smt_record_agreement": { |
| "cases": len(solver), **dict(solver_counts), "dependency_false_missing": 225 |
| }, |
| "inference_calls": 0, |
| "solvers_rerun": False, |
| "proof_archive_replayed_by_this_command": False, |
| "interpretation": ( |
| "Numeric mismatches remain task errors; no cause adjudication is inferred. " |
| "Finite shortcut counts describe the author-generated distribution, " |
| "not external annotation accuracy." |
| ), |
| } |
|
|
|
|
| if __name__ == "__main__": |
| parser = argparse.ArgumentParser(description=__doc__) |
| parser.add_argument("--inputs", type=Path, required=True) |
| parser.add_argument("--finite-results", type=Path, required=True) |
| parser.add_argument("--solver-results", type=Path, required=True) |
| parser.add_argument("--output", type=Path, required=True) |
| args = parser.parse_args() |
| result = check(args.inputs, args.finite_results, args.solver_results) |
| args.output.parent.mkdir(parents=True, exist_ok=True) |
| args.output.write_text(json.dumps(result, indent=2) + "\n") |
| print(json.dumps(result)) |
|
|