feat: add supports_flip/flip_axis to SubPattern for Phase B flip gate
This commit is contained in:
@@ -49,6 +49,8 @@ class SubPattern:
|
|||||||
positive_examples: VME 原题 few-shot 示范。
|
positive_examples: VME 原题 few-shot 示范。
|
||||||
negative_examples: 反面示例。
|
negative_examples: 反面示例。
|
||||||
distractor_rules: 干扰项构造规则。
|
distractor_rules: 干扰项构造规则。
|
||||||
|
supports_flip: 是否支持配对翻转门(Phase B 用,默认 False)。
|
||||||
|
flip_axis: 翻转轴("before/after" | "first/last"),None 表示不翻转。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
@@ -59,6 +61,8 @@ class SubPattern:
|
|||||||
positive_examples: list[dict] = field(default_factory=list)
|
positive_examples: list[dict] = field(default_factory=list)
|
||||||
negative_examples: list[dict] = field(default_factory=list)
|
negative_examples: list[dict] = field(default_factory=list)
|
||||||
distractor_rules: str = ""
|
distractor_rules: str = ""
|
||||||
|
supports_flip: bool = False
|
||||||
|
flip_axis: str | None = None
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ _TEMPORAL_REASONING_FAILURE = SubPattern(
|
|||||||
"即同一组真实事件的错误排列或错误的第 N 次定位。"
|
"即同一组真实事件的错误排列或错误的第 N 次定位。"
|
||||||
"严禁使用视频中未出现的缺席事件作为干扰项。"
|
"严禁使用视频中未出现的缺席事件作为干扰项。"
|
||||||
),
|
),
|
||||||
|
supports_flip=True,
|
||||||
|
flip_axis="before/after",
|
||||||
)
|
)
|
||||||
|
|
||||||
_SEMANTIC_RIGIDITY = SubPattern(
|
_SEMANTIC_RIGIDITY = SubPattern(
|
||||||
@@ -183,6 +185,8 @@ _CROSS_SEGMENT_ENTITY_TRACKING = SubPattern(
|
|||||||
"仅在【动作主体】这一单一维度上与正解不同。"
|
"仅在【动作主体】这一单一维度上与正解不同。"
|
||||||
"严禁编造任何实体未做过的缺席动作。"
|
"严禁编造任何实体未做过的缺席动作。"
|
||||||
),
|
),
|
||||||
|
supports_flip=True,
|
||||||
|
flip_axis="first/last",
|
||||||
)
|
)
|
||||||
|
|
||||||
_EVIDENCE_GAP_CONFABULATION = SubPattern(
|
_EVIDENCE_GAP_CONFABULATION = SubPattern(
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
"""SubPattern.supports_flip/flip_axis 默认值 + AR 两个子模式的翻转声明。"""
|
||||||
|
|
||||||
|
from app.question_gen.strategy import SubPattern
|
||||||
|
from app.question_gen.strategy_action_recognition import AR_SUB_PATTERNS
|
||||||
|
|
||||||
|
_FLIP_EXPECTED = {
|
||||||
|
"temporal_reasoning_failure": "before/after",
|
||||||
|
"cross_segment_entity_tracking": "first/last",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_sub_pattern_defaults_no_flip():
|
||||||
|
sp = SubPattern(
|
||||||
|
name="x", weight=1.0, sampling_level_override=None,
|
||||||
|
constraint_override=None, instruction="i",
|
||||||
|
)
|
||||||
|
assert sp.supports_flip is False
|
||||||
|
assert sp.flip_axis is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_ar_flip_declarations():
|
||||||
|
by_name = {sp.name: sp for sp in AR_SUB_PATTERNS}
|
||||||
|
for name, axis in _FLIP_EXPECTED.items():
|
||||||
|
assert by_name[name].supports_flip is True, name
|
||||||
|
assert by_name[name].flip_axis == axis, name
|
||||||
|
|
||||||
|
|
||||||
|
def test_other_ar_sub_patterns_keep_defaults():
|
||||||
|
for sp in AR_SUB_PATTERNS:
|
||||||
|
if sp.name in _FLIP_EXPECTED:
|
||||||
|
continue
|
||||||
|
assert sp.supports_flip is False, sp.name
|
||||||
|
assert sp.flip_axis is None, sp.name
|
||||||
Reference in New Issue
Block a user