chore: snapshot in-progress question-gen work before preflight fixes

This commit is contained in:
2026-07-16 04:12:21 -04:00
parent 11a5545f57
commit a4c429b247
39 changed files with 738 additions and 283 deletions
+5 -19
View File
@@ -27,7 +27,7 @@ from typing import TYPE_CHECKING
from loguru import logger
from app.harness.question_units import build_units
from app.harness.question_units import build_units, unit_correctness
if TYPE_CHECKING:
from pathlib import Path
@@ -65,20 +65,6 @@ class LadderEntry:
p_hat: float
def _unit_correct(unit: QuestionUnit, correctness: dict[str, bool]) -> bool:
"""单元级正确性:AR pair 双向 AND,single 即单题;单元错 = 任一成员错。
参数:
unit: 目标单元。
correctness: question_id -> 是否答对(缺项按未答对处理,与迁移前
correctness.get(qid, False) 的默认语义一致,不改判定)。
返回:
单元内所有成员均答对时 True,否则 False。
"""
return all(correctness.get(q.question_id, False) for q in unit.questions)
def build_cold_entries(
units: list[QuestionUnit],
correctness: dict[str, bool],
@@ -90,7 +76,7 @@ def build_cold_entries(
参数:
units: 该题型的全部候选单元(已排除 test 池;AR pair 已折叠成单元)。
correctness: question_id -> 种子基线是否答对(900 题全量逐题对错)。
单元级对错由 _unit_correct 折叠(任一成员错 → 单元错)。
单元级对错由 unit_correctness(strict=False) 折叠(任一成员错 → 单元错)。
probe_quota: 从错 unit 中随机抽出插到梯尾的探针比例(防"解锁新能力"盲区)。
seed: 洗牌种子,保证确定性重建。
@@ -104,8 +90,8 @@ def build_cold_entries(
错错对 2:1 交错(一方耗尽后顺排另一方)-> 探针追加尾部。
"""
rng = random.Random(seed)
wrong = [u for u in units if not _unit_correct(u, correctness)]
right = [u for u in units if _unit_correct(u, correctness)]
wrong = [u for u in units if not unit_correctness(u, correctness, strict=False)]
right = [u for u in units if unit_correctness(u, correctness, strict=False)]
rng.shuffle(wrong)
rng.shuffle(right)
@@ -125,7 +111,7 @@ def build_cold_entries(
interleaved.extend(probes)
def _p0(u: QuestionUnit) -> float:
return 2 / 3 if _unit_correct(u, correctness) else 1 / 3
return 2 / 3 if unit_correctness(u, correctness, strict=False) else 1 / 3
return [LadderEntry(u.unit_id, _p0(u)) for u in interleaved]