feat: add evolution_target derivation and cell

This commit is contained in:
2026-07-15 12:06:56 -04:00
parent 3a8dd5c167
commit 0a7ba724a9
2 changed files with 59 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
"""视频级切分选择:signal 分层、视频聚合、贪心联合约束选择(纯函数)。
结果驱动切分管线的核心:把诊断信号投影为多样性格子,供贪心选择器最大化覆盖。
本模块起步定义 evolution_target 派生与多样性格子;后续追加 score_signal /
build_video_records / select_split。
"""
from __future__ import annotations
_EVOLUTION_TARGET = {
"extraction_failure": "tool",
"search_failure": "skill",
"reasoning_failure": "skill",
"mixed": "system",
}
def evolution_target_of(error_type: str) -> str:
"""由 error_type 确定性派生进化目标(tool/skill/system)。
这是报告用的派生标注,非独立多样性轴(多样性主格子=task_type×error_type)。
参数:
error_type: 诊断瀑布归因的错误类别(extraction/search/reasoning/mixed_failure)。
返回:
进化目标字符串 tool / skill / system。
异常:
ValueError: error_type 不在已知集合内(不静默兜底)。
"""
if error_type not in _EVOLUTION_TARGET:
raise ValueError(f"未知 error_type: {error_type}")
return _EVOLUTION_TARGET[error_type]
def cell_of(task_type: str, error_type: str) -> tuple[str, str]:
"""构造多样性主格子 = (task_type, error_type)。
参数:
task_type: 题型(12 类之一)。
error_type: 错误类别(4 类之一)。
返回:
(task_type, error_type) 二元组,作为覆盖计数的格子键。
"""
return (task_type, error_type)
+12
View File
@@ -0,0 +1,12 @@
from app.harness.split_selection import cell_of, evolution_target_of
def test_evolution_target_mapping():
assert evolution_target_of("extraction_failure") == "tool"
assert evolution_target_of("search_failure") == "skill"
assert evolution_target_of("reasoning_failure") == "skill"
assert evolution_target_of("mixed") == "system"
def test_cell_is_task_type_x_error_type():
assert cell_of("Counting Problem", "search_failure") == ("Counting Problem", "search_failure")