pkulium's picture
Add manifests, eval harness (Claude Opus 5 / Bedrock), generation results
92ff1f9 verified
Raw
History Blame Contribute Delete
3.5 kB
# SPDX-License-Identifier: Apache-2.0
"""Aggregate score_claude.py output into a per-video score file and a summary.
Replaces the old combine.py, which merged two judges (Qwen3.5 + VideoScore2).
Claude Opus 5 is now the only judge, so there is nothing to combine -- the
score is just the mean of the four rubric axes:
score = mean(time_alignment, camera_motion, quality, smoothness) / 10
pass = time_alignment >= 8 and camera_motion >= 6 and quality >= 7
Thresholds are carried over unchanged from combine.py (camera_motion stays at
6, not 8, since camera-motion-following is a harder, less-established
capability than the transition/quality axes); the VideoScore2 `min(v,t,p) >= 4`
gate is gone with the model that produced it.
Usage:
python summarize.py
python summarize.py --out-dir outputs
Output: outputs/scores.jsonl (per-video) + outputs/summary.json.
"""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import numpy as np
HERE = Path(__file__).resolve().parent
AXES = ("time_alignment", "camera_motion", "quality", "smoothness")
GROUP_KEYS = ("camera_motion_name", "time_variant", "domain")
PASS_TIME_ALIGNMENT = 8.0
PASS_CAMERA_MOTION = 6.0
PASS_QUALITY = 7.0
def passed(r: dict) -> bool:
return (r["time_alignment"] >= PASS_TIME_ALIGNMENT
and r["camera_motion"] >= PASS_CAMERA_MOTION
and r["quality"] >= PASS_QUALITY)
# --- generic below this line -------------------------------------------------
def parse_args() -> argparse.Namespace:
p = argparse.ArgumentParser(description="Summarize Claude judge scores.")
p.add_argument("--out-dir", default=str(HERE / "outputs"))
return p.parse_args()
def load_jsonl(path: Path) -> list[dict]:
if not path.exists():
raise SystemExit(f"missing {path} -- run score_claude.py first")
return [json.loads(l) for l in path.read_text().splitlines() if l.strip()]
def main() -> None:
args = parse_args()
out_dir = Path(args.out_dir)
records = load_jsonl(out_dir / "claude_scores.jsonl")
merged = []
for r in sorted(records, key=lambda x: x["id"]):
if "error" in r:
merged.append({**{k: v for k, v in r.items() if k != "reason"}, "pass": False})
continue
score = sum(r[axis] for axis in AXES) / (10.0 * len(AXES))
merged.append({**r, "score": round(score, 4), "pass": passed(r)})
scores_path = out_dir / "scores.jsonl"
scores_path.write_text("\n".join(json.dumps(r) for r in merged) + "\n")
ok = [r for r in merged if "error" not in r]
summary = {
"judge": "claude-opus-5 (bedrock)",
"num_scored": len(merged),
"num_ok": len(ok),
"num_errors": len(merged) - len(ok),
"pass_rate": round(sum(r["pass"] for r in ok) / len(ok), 3) if ok else None,
"mean_score": round(float(np.mean([r["score"] for r in ok])), 3) if ok else None,
}
for axis in AXES:
summary[f"mean_{axis}"] = round(float(np.mean([r[axis] for r in ok])), 3) if ok else None
for key in GROUP_KEYS:
groups: dict = {}
for r in ok:
groups.setdefault(r[key], []).append(r["score"])
summary[f"mean_score_by_{key}"] = {k: round(float(np.mean(v)), 3)
for k, v in sorted(groups.items())}
(out_dir / "summary.json").write_text(json.dumps(summary, indent=2))
print(json.dumps(summary, indent=2))
if __name__ == "__main__":
main()