feat: add uses_grounded_selector strategy switch (AR only)

This commit is contained in:
2026-07-14 13:53:17 -04:00
parent 2608a3841f
commit 3f984acc18
3 changed files with 32 additions and 0 deletions
+8
View File
@@ -91,6 +91,9 @@ class TaskTypeStrategy(Protocol):
@property
def leak_probe_template(self) -> str: ...
@property
def uses_grounded_selector(self) -> bool: ...
def select_sub_pattern(self, rng: random.Random) -> SubPattern | None: ...
def build_prompt_context(self, material: Any, sub_pattern: SubPattern | None) -> dict: ...
@@ -168,6 +171,11 @@ class BaseTaskTypeStrategy:
"""返回泄漏探测模板文件名(委托给绑定的 family.leak_profile)。"""
return self._family.leak_profile.probe_template
@property
def uses_grounded_selector(self) -> bool:
"""默认不启用 grounded selector11 类题型走原路径)。"""
return False
def select_sub_pattern(self, rng: random.Random) -> SubPattern | None:
"""BaseTaskTypeStrategy 无子模式。"""
return None
@@ -289,6 +289,11 @@ class ActionRecognitionStrategy:
"""返回泄漏探测模板文件名。"""
return "gate_leak_retrieval.md"
@property
def uses_grounded_selector(self) -> bool:
"""AR 启用候选池 + VLM 视觉打分 selector。"""
return True
def select_sub_pattern(self, rng: random.Random) -> SubPattern:
"""按权重随机选择一个 SubPattern。
+19
View File
@@ -0,0 +1,19 @@
"""uses_grounded_selector 分流:仅 AR=True,其余 11 类=False。"""
from app.question_gen.strategy import get_strategy
_NON_AR = [
"Action Reasoning", "Attribute Perception", "Counting Problem",
"Information Synopsis", "Object Recognition", "Object Reasoning",
"OCR Problems", "Spatial Perception", "Spatial Reasoning",
"Temporal Perception", "Temporal Reasoning",
]
def test_action_recognition_uses_grounded_selector():
assert get_strategy("Action Recognition").uses_grounded_selector is True
def test_non_ar_do_not_use_grounded_selector():
for tt in _NON_AR:
assert get_strategy(tt).uses_grounded_selector is False, tt