Weitaikang_bench_github / scripts /04_evaluate.py
weitaikang's picture
HeroFrame-Bench evaluation code
425512c verified
Raw
History Blame Contribute Delete
2.66 kB
#!/usr/bin/env python
"""Step 4 of 4: score a submission.
python scripts/04_evaluate.py --selections my_method.jsonl \\
--track ./track --name my_method
Needs a reader model serving an OpenAI-compatible endpoint. Every published
number used Qwen3.6-27B on local hardware:
vllm serve Qwen/Qwen3-VL-27B-Instruct \\
--max-model-len 16384 --gpu-memory-utilization 0.90 \\
--reasoning-parser qwen3 --no-enable-prefix-caching
Two calls per (frame, chain) pair. Five frames across 204 films with ten chains
each is about 20,000 calls, so try `--movies` with a few films first.
The reader is part of the specification. Frame-level scores from a different
reader are not comparable with the leaderboard, even though the method ranking
survives a reader change.
"""
import argparse
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from heroframe import evaluate, report
from heroframe.data import Benchmark
from heroframe.reader import OpenAICompatReader
def main():
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
ap.add_argument("--selections", type=Path, required=True)
ap.add_argument("--track", type=Path, required=True)
ap.add_argument("--name", default="my_method")
ap.add_argument("--root", type=Path, default=None)
ap.add_argument("--out", type=Path, default=None)
ap.add_argument("--movies", nargs="*", default=None)
ap.add_argument("--chains-per-movie", type=int, default=None,
help="cap chains per film; the official protocol uses all")
ap.add_argument("--base-url", default="http://localhost:8000/v1")
ap.add_argument("--model", default=None)
ap.add_argument("--workers", type=int, default=8)
ap.add_argument("--allow-modified-prompt", action="store_true",
help="score with an edited prompt; result is not comparable")
a = ap.parse_args()
bench = Benchmark(a.root) if a.root else Benchmark()
reader = OpenAICompatReader(base_url=a.base_url)
if a.model:
reader.model = a.model
out = a.out or Path(f"{a.name}_result.json")
result = evaluate.evaluate(
a.selections, a.track, reader,
bench=bench, method_name=a.name, movies=a.movies,
chains_per_movie=a.chains_per_movie, workers=a.workers,
out_path=out, strict_prompts=not a.allow_modified_prompt,
)
print()
print(report.render(result, bench))
md = out.with_suffix(".md")
md.write_text(report.render(result, bench))
print(f"\nwrote {out} and {md}")
return 0
if __name__ == "__main__":
sys.exit(main())