fix(question_gen): 每次重试换视频避免同视频反复去重失败

Information Synopsis 163 道 benchmark 题,同一视频反复出题
必然相似。改为每次重试随机选不同视频。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 08:15:03 -04:00
parent d0148e78ad
commit 25c8d5ec42
+17 -19
View File
@@ -908,30 +908,28 @@ async def _run_generate(args: argparse.Namespace) -> None:
exemplars = _select_exemplars(benchmark, task_type, 3, rng)
for seq in range(start_seq, per_type):
# 随机选一个视频
video_id = rng.choice(video_ids)
tree_path = videos_dir / video_id / "tree.json"
try:
tree = TreeIndex.load_json(str(tree_path))
except Exception as exc:
logger.warning("加载树 {} 失败: {}", tree_path, exc)
total_failed += 1
continue
# frame_path 是相对于视频目录的,拼为绝对路径供 VLM 读取
video_dir = videos_dir / video_id
for l1 in tree.roots:
for l2 in l1.children:
for l3 in l2.children:
if l3.frame_path and not Path(l3.frame_path).is_absolute():
l3.frame_path = str(video_dir / l3.frame_path)
used_node_ids: set[str] = set()
session_id = f"gen-{task_type}-{seq}"
generated = False
for _attempt in range(max_retries):
# 每次重试换一个视频,避免同视频反复去重失败
video_id = rng.choice(video_ids)
tree_path = videos_dir / video_id / "tree.json"
try:
tree = TreeIndex.load_json(str(tree_path))
except Exception as exc:
logger.warning("加载树 {} 失败: {}", tree_path, exc)
continue
video_dir = videos_dir / video_id
for l1 in tree.roots:
for l2 in l1.children:
for l3 in l2.children:
if l3.frame_path and not Path(l3.frame_path).is_absolute():
l3.frame_path = str(video_dir / l3.frame_path)
candidate = await _generate_with_sem(
vlm,
tree,