taryya commited on
Commit
6a3ab8d
·
verified ·
1 Parent(s): 190a0d9

Use dedicated single-video prompt template

Browse files
single_video_567/code/unified_eval.py CHANGED
@@ -23,13 +23,13 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
23
  from pathlib import Path
24
 
25
 
26
- VERSION = "runningbench-unified-v6"
27
  DATASETS = {
28
  "single_698": "segments_60s_gemini_verification/final/segments_700_verified.jsonl",
29
  "single_567_human": "human_answer_repair_567/single_567_human_eval.jsonl",
30
  "mixed_1487": "qa_fix_gold_recovery_and_adjudication/data/runningbench_v2_kept.jsonl",
31
  }
32
- PROMPT = """Answer this multiple-choice question about egocentric walking/running footage.
33
  The frames below are sampled in order from the clip(s) the question refers to; each clip is
34
  introduced by its label.
35
 
@@ -40,6 +40,18 @@ QUESTION: {question}
40
  OPTIONS:
41
  {options}
42
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  Select exactly {n} option{plural}.
44
  Return ONLY JSON: {{"answer": [{example}]}}"""
45
  MULTI_UNITS = {"cross_video", "cross_recording", "anonymous_multi_clip"}
@@ -316,11 +328,12 @@ class FloodgateClient:
316
  "attempts": [], "error": None}
317
 
318
 
319
- def prompt_for(question, qid):
320
  shown, back = shuffled_view(question["options"], qid)
321
  n = len(question["answer"])
322
  letters = sorted(shown)
323
- prompt = PROMPT.format(question=question["question"], options="\n".join(f"{letter}. {shown[letter]}" for letter in letters),
 
324
  n=n, plural="s" if n > 1 else "", example=", ".join(f'"{letter}"' for letter in letters[:n]))
325
  return prompt, letters, back
326
 
@@ -342,8 +355,9 @@ def run(args, dataset, root, work):
342
  elif args.skip:
343
  questions = questions[args.skip:]
344
  run_dir = work / "runs" / args.run_id
 
345
  config = {"version": VERSION, "dataset": dataset, "corpus_sha256": file_hash(corpus_path),
346
- "prompt_sha256": hashlib.sha256(PROMPT.encode()).hexdigest(), "model": args.model,
347
  "backend": args.backend,
348
  "thinking": args.thinking, "max_tokens": args.max_tokens,
349
  "max_tokens_cap": args.max_tokens_cap, "frames_per_question": args.frames,
@@ -395,7 +409,7 @@ def run(args, dataset, root, work):
395
  qid = question_id(question, dataset)
396
  if isinstance(frames, Exception):
397
  return {"question_id": qid, "dataset": dataset, "error": f"media:{type(frames).__name__}: {frames}"}
398
- prompt, letters, back = prompt_for(question, qid)
399
  started = time.time()
400
  try:
401
  response = client.ask(prompt, frames)
 
23
  from pathlib import Path
24
 
25
 
26
+ VERSION = "runningbench-unified-v7"
27
  DATASETS = {
28
  "single_698": "segments_60s_gemini_verification/final/segments_700_verified.jsonl",
29
  "single_567_human": "human_answer_repair_567/single_567_human_eval.jsonl",
30
  "mixed_1487": "qa_fix_gold_recovery_and_adjudication/data/runningbench_v2_kept.jsonl",
31
  }
32
+ MULTI_VIDEO_PROMPT = """Answer this multiple-choice question about egocentric walking/running footage.
33
  The frames below are sampled in order from the clip(s) the question refers to; each clip is
34
  introduced by its label.
35
 
 
40
  OPTIONS:
41
  {options}
42
 
43
+ Select exactly {n} option{plural}.
44
+ Return ONLY JSON: {{"answer": [{example}]}}"""
45
+ SINGLE_VIDEO_PROMPT = """Answer this multiple-choice question about egocentric walking/running footage.
46
+ The frames below are sampled in chronological order from the single 60-second video associated with this question.
47
+
48
+ Watch the video frames before deciding. Base your answer on visual evidence from this video. Do not answer from the wording of the options alone.
49
+
50
+ QUESTION: {question}
51
+
52
+ OPTIONS:
53
+ {options}
54
+
55
  Select exactly {n} option{plural}.
56
  Return ONLY JSON: {{"answer": [{example}]}}"""
57
  MULTI_UNITS = {"cross_video", "cross_recording", "anonymous_multi_clip"}
 
328
  "attempts": [], "error": None}
329
 
330
 
331
+ def prompt_for(question, qid, dataset):
332
  shown, back = shuffled_view(question["options"], qid)
333
  n = len(question["answer"])
334
  letters = sorted(shown)
335
+ template = SINGLE_VIDEO_PROMPT if dataset.startswith("single_") else MULTI_VIDEO_PROMPT
336
+ prompt = template.format(question=question["question"], options="\n".join(f"{letter}. {shown[letter]}" for letter in letters),
337
  n=n, plural="s" if n > 1 else "", example=", ".join(f'"{letter}"' for letter in letters[:n]))
338
  return prompt, letters, back
339
 
 
355
  elif args.skip:
356
  questions = questions[args.skip:]
357
  run_dir = work / "runs" / args.run_id
358
+ prompt_template = SINGLE_VIDEO_PROMPT if dataset.startswith("single_") else MULTI_VIDEO_PROMPT
359
  config = {"version": VERSION, "dataset": dataset, "corpus_sha256": file_hash(corpus_path),
360
+ "prompt_sha256": hashlib.sha256(prompt_template.encode()).hexdigest(), "model": args.model,
361
  "backend": args.backend,
362
  "thinking": args.thinking, "max_tokens": args.max_tokens,
363
  "max_tokens_cap": args.max_tokens_cap, "frames_per_question": args.frames,
 
409
  qid = question_id(question, dataset)
410
  if isinstance(frames, Exception):
411
  return {"question_id": qid, "dataset": dataset, "error": f"media:{type(frames).__name__}: {frames}"}
412
+ prompt, letters, back = prompt_for(question, qid, dataset)
413
  started = time.time()
414
  try:
415
  response = client.ask(prompt, frames)