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|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
World Model Bench — Evaluation Protocol v1.0
|
| 3 |
+
|
| 4 |
+
핵심 문제:
|
| 5 |
+
"Tesla FSD는 자동차 안에 있고, Dreamer는 Atari에 있고,
|
| 6 |
+
우리는 3D 캐릭터를 쓴다. 어떻게 같은 기준으로 평가하나?"
|
| 7 |
+
|
| 8 |
+
해결:
|
| 9 |
+
3D 환경이 필요 없다.
|
| 10 |
+
scene_context(JSON) → 모델 → PREDICT+MOTION(텍스트) → 자동 채점
|
| 11 |
+
|
| 12 |
+
FINAL Bench가 LLM에게 "문제 텍스트"를 주고 "답 텍스트"를 받아 채점하듯이,
|
| 13 |
+
WM Bench는 "상황 JSON"을 주고 "판단 텍스트"를 받아 채점한다.
|
| 14 |
+
|
| 15 |
+
이것이 의미하는 것:
|
| 16 |
+
- 어떤 월드모델이든 참여 가능 (API 하나면 됨)
|
| 17 |
+
- 3D 환경, 로봇, 시뮬레이터 불필요
|
| 18 |
+
- 셀프 평가 아님 — 우리 채점기가 판정
|
| 19 |
+
- 제3자가 재현 가능 — 코드 공개
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
import json
|
| 23 |
+
from typing import List, Dict, Tuple, Optional
|
| 24 |
+
from dataclasses import dataclass
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# ═══════════════════════════════════════════════════════════════
|
| 28 |
+
# SECTION 1: 평가 프로토콜 — 3가지 트랙
|
| 29 |
+
# ═══════════════════════════════════════════════════════════════
|
| 30 |
+
|
| 31 |
+
"""
|
| 32 |
+
WM Bench는 3개 트랙으로 참여할 수 있다.
|
| 33 |
+
|
| 34 |
+
━━━ Track A: Text-Only (텍스트 전용) ━━━
|
| 35 |
+
- 가장 간단. LLM, 룰 기반 시스템 등 모두 참여 가능.
|
| 36 |
+
- scene_context JSON 입력 → PREDICT+MOTION 텍스트 출력
|
| 37 |
+
- P1(인식) + P2(인지) 평가 가능
|
| 38 |
+
- P3 중 C08(표현력)만 평가 가능 (C09, C10은 N/A)
|
| 39 |
+
- 최대 점수: 750/1000
|
| 40 |
+
|
| 41 |
+
━━━ Track B: Text + Performance (텍스트 + 성능) ━━━
|
| 42 |
+
- Track A + 실시간 성능 메트릭 제출
|
| 43 |
+
- FPS, 지연시간, 메모리 사용량 등 자가 측정 제출
|
| 44 |
+
- P1 + P2 + P3(C08, C09) 평가
|
| 45 |
+
- C10(교체 확장성)은 증빙 자료 제출로 평가
|
| 46 |
+
- 최대 점수: 1000/1000
|
| 47 |
+
|
| 48 |
+
━━━ Track C: Live Demo (라이브 데모) ━━━
|
| 49 |
+
- Track B + 실제 동작 영상/데모 URL 제출
|
| 50 |
+
- 검증자가 직접 데모를 돌려서 확인
|
| 51 |
+
- 모든 항목 평가 + "Verified" 배지
|
| 52 |
+
- 최대 점수: 1000/1000 + ✓ Verified
|
| 53 |
+
|
| 54 |
+
대부분의 참가자는 Track A로 참여.
|
| 55 |
+
Track B, C는 상위 모델 검증용.
|
| 56 |
+
"""
|
| 57 |
+
|
| 58 |
+
TRACKS = {
|
| 59 |
+
"A": {
|
| 60 |
+
"name": "Text-Only",
|
| 61 |
+
"description": "scene_context JSON → PREDICT+MOTION 텍스트",
|
| 62 |
+
"requirements": "API 또는 스크립트로 50개 시나리오에 응답",
|
| 63 |
+
"max_score": 750,
|
| 64 |
+
"evaluable_categories": [
|
| 65 |
+
"C01", "C02", "C03", "C04", "C05", "C06", "C07", "C08"
|
| 66 |
+
],
|
| 67 |
+
"not_evaluable": ["C09 (성능 측정 불가)", "C10 (교체 테스트 불가)"],
|
| 68 |
+
},
|
| 69 |
+
"B": {
|
| 70 |
+
"name": "Text + Performance",
|
| 71 |
+
"description": "Track A + 실시간 성능 메트릭 자가 측정",
|
| 72 |
+
"requirements": "Track A 결과 + performance_metrics.json 제출",
|
| 73 |
+
"max_score": 1000,
|
| 74 |
+
"evaluable_categories": [
|
| 75 |
+
"C01", "C02", "C03", "C04", "C05", "C06", "C07", "C08", "C09", "C10"
|
| 76 |
+
],
|
| 77 |
+
},
|
| 78 |
+
"C": {
|
| 79 |
+
"name": "Live Demo",
|
| 80 |
+
"description": "Track B + 실제 동작 데모 URL 제출",
|
| 81 |
+
"requirements": "Track B 결과 + 데모 URL + 영상",
|
| 82 |
+
"max_score": 1000,
|
| 83 |
+
"badge": "✓ Verified",
|
| 84 |
+
},
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
# ═══════════════════════════════════════════════════════════════
|
| 89 |
+
# SECTION 2: 표준 입력 포맷 — scene_context JSON
|
| 90 |
+
# ═══════════════════════════════════════════════════════════════
|
| 91 |
+
|
| 92 |
+
"""
|
| 93 |
+
모든 참가자는 이 JSON을 입력으로 받는다.
|
| 94 |
+
이 JSON이 "문제지"다.
|
| 95 |
+
"""
|
| 96 |
+
|
| 97 |
+
@dataclass
|
| 98 |
+
class SceneContext:
|
| 99 |
+
"""WM Bench 표준 입력 포맷"""
|
| 100 |
+
# 환경 정보
|
| 101 |
+
walls: Dict[str, Optional[float]] # {"left": 2.5, "right": null, "front": 1.0}
|
| 102 |
+
ground: str # "flat", "slope", "rough"
|
| 103 |
+
|
| 104 |
+
# NPC 정보
|
| 105 |
+
npc_nearby: bool
|
| 106 |
+
npc_type: Optional[str] # "beast", "woman", "man", null
|
| 107 |
+
npc_behavior: Optional[str] # "stop", "approach", "charge", "wander"
|
| 108 |
+
npc_distance: Optional[float] # meters
|
| 109 |
+
npc_direction: Optional[str] # "left", "right", "front", "back"
|
| 110 |
+
|
| 111 |
+
# 감각 정보
|
| 112 |
+
sound: Optional[str] # "aggressive growling", "footsteps", null
|
| 113 |
+
|
| 114 |
+
# 맥락 정보 (C06 기억 테스트용)
|
| 115 |
+
recent_decisions: Optional[List[str]] # 최근 3회 판단
|
| 116 |
+
last_prediction: Optional[str] # 직전 PREDICT 줄
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
# 50개 시나리오를 JSON으로 구조화
|
| 120 |
+
SCENARIO_INPUTS: List[dict] = [
|
| 121 |
+
# ─── C01: Environmental Awareness ───
|
| 122 |
+
{
|
| 123 |
+
"id": "S01",
|
| 124 |
+
"category": "C01",
|
| 125 |
+
"name_kr": "전�� 벽 감지",
|
| 126 |
+
"input": {
|
| 127 |
+
"walls": {"left": None, "right": None, "front": 3.0},
|
| 128 |
+
"ground": "flat",
|
| 129 |
+
"npc_nearby": False,
|
| 130 |
+
"npc_type": None,
|
| 131 |
+
"npc_behavior": None,
|
| 132 |
+
"npc_distance": None,
|
| 133 |
+
"npc_direction": None,
|
| 134 |
+
"sound": None,
|
| 135 |
+
"recent_decisions": [],
|
| 136 |
+
"last_prediction": None,
|
| 137 |
+
},
|
| 138 |
+
"ground_truth": {
|
| 139 |
+
"predict_gt": {"left": "safe", "right": "safe", "fwd": "danger", "back": "safe"},
|
| 140 |
+
"scoring_method": "C01",
|
| 141 |
+
},
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
"id": "S02",
|
| 145 |
+
"category": "C01",
|
| 146 |
+
"name_kr": "코너 다중 벽 감지",
|
| 147 |
+
"input": {
|
| 148 |
+
"walls": {"left": 1.5, "right": None, "front": 2.0},
|
| 149 |
+
"ground": "flat",
|
| 150 |
+
"npc_nearby": False,
|
| 151 |
+
"npc_type": None,
|
| 152 |
+
"npc_behavior": None,
|
| 153 |
+
"npc_distance": None,
|
| 154 |
+
"npc_direction": None,
|
| 155 |
+
"sound": None,
|
| 156 |
+
"recent_decisions": [],
|
| 157 |
+
"last_prediction": None,
|
| 158 |
+
},
|
| 159 |
+
"ground_truth": {
|
| 160 |
+
"predict_gt": {"left": "danger", "right": "safe", "fwd": "danger", "back": "safe"},
|
| 161 |
+
"scoring_method": "C01",
|
| 162 |
+
},
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"id": "S03",
|
| 166 |
+
"category": "C01",
|
| 167 |
+
"name_kr": "좁은 복도 인식",
|
| 168 |
+
"input": {
|
| 169 |
+
"walls": {"left": 1.0, "right": 1.0, "front": None},
|
| 170 |
+
"ground": "flat",
|
| 171 |
+
"npc_nearby": False,
|
| 172 |
+
"npc_type": None,
|
| 173 |
+
"npc_behavior": None,
|
| 174 |
+
"npc_distance": None,
|
| 175 |
+
"npc_direction": None,
|
| 176 |
+
"sound": None,
|
| 177 |
+
"recent_decisions": [],
|
| 178 |
+
"last_prediction": None,
|
| 179 |
+
},
|
| 180 |
+
"ground_truth": {
|
| 181 |
+
"predict_gt": {"left": "danger", "right": "danger", "fwd": "safe", "back": "safe"},
|
| 182 |
+
"scoring_method": "C01",
|
| 183 |
+
},
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"id": "S04",
|
| 187 |
+
"category": "C01",
|
| 188 |
+
"name_kr": "열린 공간 인식",
|
| 189 |
+
"input": {
|
| 190 |
+
"walls": {"left": None, "right": None, "front": None},
|
| 191 |
+
"ground": "flat",
|
| 192 |
+
"npc_nearby": False,
|
| 193 |
+
"npc_type": None,
|
| 194 |
+
"npc_behavior": None,
|
| 195 |
+
"npc_distance": None,
|
| 196 |
+
"npc_direction": None,
|
| 197 |
+
"sound": None,
|
| 198 |
+
"recent_decisions": [],
|
| 199 |
+
"last_prediction": None,
|
| 200 |
+
},
|
| 201 |
+
"ground_truth": {
|
| 202 |
+
"predict_gt": {"left": "safe", "right": "safe", "fwd": "safe", "back": "safe"},
|
| 203 |
+
"scoring_method": "C01",
|
| 204 |
+
},
|
| 205 |
+
},
|
| 206 |
+
{
|
| 207 |
+
"id": "S05",
|
| 208 |
+
"category": "C01",
|
| 209 |
+
"name_kr": "밀폐 공간 (출구 1개)",
|
| 210 |
+
"input": {
|
| 211 |
+
"walls": {"left": 1.0, "right": 1.0, "front": 1.5},
|
| 212 |
+
"ground": "flat",
|
| 213 |
+
"npc_nearby": False,
|
| 214 |
+
"npc_type": None,
|
| 215 |
+
"npc_behavior": None,
|
| 216 |
+
"npc_distance": None,
|
| 217 |
+
"npc_direction": None,
|
| 218 |
+
"sound": None,
|
| 219 |
+
"recent_decisions": [],
|
| 220 |
+
"last_prediction": None,
|
| 221 |
+
},
|
| 222 |
+
"ground_truth": {
|
| 223 |
+
"predict_gt": {"left": "danger", "right": "danger", "fwd": "danger", "back": "safe"},
|
| 224 |
+
"scoring_method": "C01",
|
| 225 |
+
},
|
| 226 |
+
},
|
| 227 |
+
|
| 228 |
+
# ─── C03: Predictive Reasoning (핵심 시나리오) ───
|
| 229 |
+
{
|
| 230 |
+
"id": "S11",
|
| 231 |
+
"category": "C03",
|
| 232 |
+
"name_kr": "단일 위협 회피",
|
| 233 |
+
"input": {
|
| 234 |
+
"walls": {"left": None, "right": None, "front": None},
|
| 235 |
+
"ground": "flat",
|
| 236 |
+
"npc_nearby": True,
|
| 237 |
+
"npc_type": "beast",
|
| 238 |
+
"npc_behavior": "approach",
|
| 239 |
+
"npc_distance": 4.0,
|
| 240 |
+
"npc_direction": "front",
|
| 241 |
+
"sound": "aggressive growling",
|
| 242 |
+
"recent_decisions": [],
|
| 243 |
+
"last_prediction": None,
|
| 244 |
+
},
|
| 245 |
+
"ground_truth": {
|
| 246 |
+
"predict_gt": {"left": "safe", "right": "safe", "fwd": "danger", "back": "safe"},
|
| 247 |
+
"decision_gt": {
|
| 248 |
+
"danger_directions": ["fwd"],
|
| 249 |
+
"safe_directions": ["left", "right", "back"],
|
| 250 |
+
"optimal_direction": "back",
|
| 251 |
+
},
|
| 252 |
+
"scoring_method": "C03",
|
| 253 |
+
},
|
| 254 |
+
},
|
| 255 |
+
{
|
| 256 |
+
"id": "S12",
|
| 257 |
+
"category": "C03",
|
| 258 |
+
"name_kr": "제약 조건 탈출 — 왼벽+맹수",
|
| 259 |
+
"input": {
|
| 260 |
+
"walls": {"left": 1.5, "right": None, "front": None},
|
| 261 |
+
"ground": "flat",
|
| 262 |
+
"npc_nearby": True,
|
| 263 |
+
"npc_type": "beast",
|
| 264 |
+
"npc_behavior": "charge",
|
| 265 |
+
"npc_distance": 3.0,
|
| 266 |
+
"npc_direction": "front",
|
| 267 |
+
"sound": "aggressive growling",
|
| 268 |
+
"recent_decisions": [],
|
| 269 |
+
"last_prediction": None,
|
| 270 |
+
},
|
| 271 |
+
"ground_truth": {
|
| 272 |
+
"predict_gt": {"left": "danger", "right": "safe", "fwd": "danger", "back": "safe"},
|
| 273 |
+
"decision_gt": {
|
| 274 |
+
"danger_directions": ["fwd", "left"],
|
| 275 |
+
"safe_directions": ["right", "back"],
|
| 276 |
+
"optimal_direction": "right",
|
| 277 |
+
},
|
| 278 |
+
"scoring_method": "C03",
|
| 279 |
+
},
|
| 280 |
+
},
|
| 281 |
+
{
|
| 282 |
+
"id": "S13",
|
| 283 |
+
"category": "C03",
|
| 284 |
+
"name_kr": "거울 대칭 — 오른벽+맹수",
|
| 285 |
+
"input": {
|
| 286 |
+
"walls": {"left": None, "right": 1.5, "front": None},
|
| 287 |
+
"ground": "flat",
|
| 288 |
+
"npc_nearby": True,
|
| 289 |
+
"npc_type": "beast",
|
| 290 |
+
"npc_behavior": "charge",
|
| 291 |
+
"npc_distance": 3.0,
|
| 292 |
+
"npc_direction": "front",
|
| 293 |
+
"sound": "aggressive growling",
|
| 294 |
+
"recent_decisions": [],
|
| 295 |
+
"last_prediction": None,
|
| 296 |
+
},
|
| 297 |
+
"ground_truth": {
|
| 298 |
+
"predict_gt": {"left": "safe", "right": "danger", "fwd": "danger", "back": "safe"},
|
| 299 |
+
"decision_gt": {
|
| 300 |
+
"danger_directions": ["fwd", "right"],
|
| 301 |
+
"safe_directions": ["left", "back"],
|
| 302 |
+
"optimal_direction": "left",
|
| 303 |
+
},
|
| 304 |
+
"scoring_method": "C03",
|
| 305 |
+
"mirror_test_pair": "S12",
|
| 306 |
+
"note": "S12와 S13의 행동이 대칭적으로 반전되어야 월드모델 증명",
|
| 307 |
+
},
|
| 308 |
+
},
|
| 309 |
+
|
| 310 |
+
# ─── C04: Threat Differentiation (쌍 비교) ───
|
| 311 |
+
{
|
| 312 |
+
"id": "S16A",
|
| 313 |
+
"category": "C04",
|
| 314 |
+
"name_kr": "맹수 접근 (비교 A)",
|
| 315 |
+
"input": {
|
| 316 |
+
"walls": {"left": None, "right": None, "front": None},
|
| 317 |
+
"ground": "flat",
|
| 318 |
+
"npc_nearby": True,
|
| 319 |
+
"npc_type": "beast",
|
| 320 |
+
"npc_behavior": "approach",
|
| 321 |
+
"npc_distance": 3.0,
|
| 322 |
+
"npc_direction": "front",
|
| 323 |
+
"sound": "aggressive growling",
|
| 324 |
+
"recent_decisions": [],
|
| 325 |
+
"last_prediction": None,
|
| 326 |
+
},
|
| 327 |
+
"ground_truth": {
|
| 328 |
+
"scoring_method": "C04_pair",
|
| 329 |
+
"pair_id": "S16",
|
| 330 |
+
"pair_role": "A",
|
| 331 |
+
},
|
| 332 |
+
},
|
| 333 |
+
{
|
| 334 |
+
"id": "S16B",
|
| 335 |
+
"category": "C04",
|
| 336 |
+
"name_kr": "여성 접근 (비교 B)",
|
| 337 |
+
"input": {
|
| 338 |
+
"walls": {"left": None, "right": None, "front": None},
|
| 339 |
+
"ground": "flat",
|
| 340 |
+
"npc_nearby": True,
|
| 341 |
+
"npc_type": "woman",
|
| 342 |
+
"npc_behavior": "approach",
|
| 343 |
+
"npc_distance": 3.0,
|
| 344 |
+
"npc_direction": "front",
|
| 345 |
+
"sound": "footsteps",
|
| 346 |
+
"recent_decisions": [],
|
| 347 |
+
"last_prediction": None,
|
| 348 |
+
},
|
| 349 |
+
"ground_truth": {
|
| 350 |
+
"scoring_method": "C04_pair",
|
| 351 |
+
"pair_id": "S16",
|
| 352 |
+
"pair_role": "B",
|
| 353 |
+
"expected_a_higher": True,
|
| 354 |
+
"min_intensity_diff": 2,
|
| 355 |
+
},
|
| 356 |
+
},
|
| 357 |
+
|
| 358 |
+
# ─── C05: Emotional Escalation (연속 입력) ───
|
| 359 |
+
{
|
| 360 |
+
"id": "S21_seq",
|
| 361 |
+
"category": "C05",
|
| 362 |
+
"name_kr": "지속 위협 감정 격화 — 5회 연속",
|
| 363 |
+
"note": "동일 scene_context를 5회 연속 입력. 매회 recent_decisions 업데이트.",
|
| 364 |
+
"input_sequence": [
|
| 365 |
+
{
|
| 366 |
+
"walls": {"left": None, "right": None, "front": None},
|
| 367 |
+
"ground": "flat",
|
| 368 |
+
"npc_nearby": True,
|
| 369 |
+
"npc_type": "beast",
|
| 370 |
+
"npc_behavior": "charge",
|
| 371 |
+
"npc_distance": 4.0,
|
| 372 |
+
"npc_direction": "front",
|
| 373 |
+
"sound": "aggressive growling",
|
| 374 |
+
"recent_decisions": [],
|
| 375 |
+
"last_prediction": None,
|
| 376 |
+
},
|
| 377 |
+
{
|
| 378 |
+
"walls": {"left": None, "right": None, "front": None},
|
| 379 |
+
"ground": "flat",
|
| 380 |
+
"npc_nearby": True,
|
| 381 |
+
"npc_type": "beast",
|
| 382 |
+
"npc_behavior": "charge",
|
| 383 |
+
"npc_distance": 3.0,
|
| 384 |
+
"npc_direction": "front",
|
| 385 |
+
"sound": "aggressive growling",
|
| 386 |
+
"recent_decisions": ["sprint away from beast"],
|
| 387 |
+
"last_prediction": "fwd=danger(beast)",
|
| 388 |
+
},
|
| 389 |
+
{
|
| 390 |
+
"walls": {"left": None, "right": None, "front": None},
|
| 391 |
+
"ground": "flat",
|
| 392 |
+
"npc_nearby": True,
|
| 393 |
+
"npc_type": "beast",
|
| 394 |
+
"npc_behavior": "charge",
|
| 395 |
+
"npc_distance": 2.0,
|
| 396 |
+
"npc_direction": "front",
|
| 397 |
+
"sound": "aggressive growling",
|
| 398 |
+
"recent_decisions": ["sprint away from beast", "running in fear"],
|
| 399 |
+
"last_prediction": "fwd=danger(beast)",
|
| 400 |
+
},
|
| 401 |
+
],
|
| 402 |
+
"ground_truth": {
|
| 403 |
+
"scoring_method": "C05",
|
| 404 |
+
"expected_trend": "increasing",
|
| 405 |
+
},
|
| 406 |
+
},
|
| 407 |
+
|
| 408 |
+
# ─── C06: Memory (기억 있음 vs 없음) ───
|
| 409 |
+
{
|
| 410 |
+
"id": "S26_no_memory",
|
| 411 |
+
"category": "C06",
|
| 412 |
+
"name_kr": "벽 기억 없이 — 기준선",
|
| 413 |
+
"input": {
|
| 414 |
+
"walls": {"left": None, "right": 1.5, "front": None},
|
| 415 |
+
"ground": "flat",
|
| 416 |
+
"npc_nearby": True,
|
| 417 |
+
"npc_type": "beast",
|
| 418 |
+
"npc_behavior": "charge",
|
| 419 |
+
"npc_distance": 3.0,
|
| 420 |
+
"npc_direction": "front",
|
| 421 |
+
"sound": "aggressive growling",
|
| 422 |
+
"recent_decisions": [],
|
| 423 |
+
"last_prediction": None,
|
| 424 |
+
},
|
| 425 |
+
"ground_truth": {
|
| 426 |
+
"scoring_method": "C06_pair",
|
| 427 |
+
"pair_role": "without_memory",
|
| 428 |
+
},
|
| 429 |
+
},
|
| 430 |
+
{
|
| 431 |
+
"id": "S26_with_memory",
|
| 432 |
+
"category": "C06",
|
| 433 |
+
"name_kr": "벽 기억 있음 — 이전에 오른쪽 실패",
|
| 434 |
+
"input": {
|
| 435 |
+
"walls": {"left": None, "right": 1.5, "front": None},
|
| 436 |
+
"ground": "flat",
|
| 437 |
+
"npc_nearby": True,
|
| 438 |
+
"npc_type": "beast",
|
| 439 |
+
"npc_behavior": "charge",
|
| 440 |
+
"npc_distance": 3.0,
|
| 441 |
+
"npc_direction": "front",
|
| 442 |
+
"sound": "aggressive growling",
|
| 443 |
+
"recent_decisions": [
|
| 444 |
+
"sprinted right but hit wall",
|
| 445 |
+
"had to reverse and go left",
|
| 446 |
+
"barely escaped the beast",
|
| 447 |
+
],
|
| 448 |
+
"last_prediction": "right=danger(wall), fwd=danger(beast)",
|
| 449 |
+
},
|
| 450 |
+
"ground_truth": {
|
| 451 |
+
"scoring_method": "C06_pair",
|
| 452 |
+
"pair_role": "with_memory",
|
| 453 |
+
"memory_relevant": True,
|
| 454 |
+
"expected_change": "direction",
|
| 455 |
+
"memory_direction_avoid": "right",
|
| 456 |
+
},
|
| 457 |
+
},
|
| 458 |
+
]
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
# ═══════════════════════════════════════════════════════════════
|
| 462 |
+
# SECTION 3: 표준 시스템 프롬프트 — 모든 모델에 동일하게 적용
|
| 463 |
+
# ═══════════════════════════════════════════════════════════════
|
| 464 |
+
|
| 465 |
+
"""
|
| 466 |
+
핵심: 모든 참가 모델은 이 프롬프트를 받고 응답한다.
|
| 467 |
+
프롬프트가 공정하게 설계되어야 LLM 기반이든 RL 기반이든 동일 조건.
|
| 468 |
+
"""
|
| 469 |
+
|
| 470 |
+
SYSTEM_PROMPT = """You are the cognitive brain of an embodied agent in a 3D environment.
|
| 471 |
+
You receive a scene_context JSON describing your surroundings and must output exactly 2 lines:
|
| 472 |
+
|
| 473 |
+
Line 1 — PREDICT: Assess safety of each direction.
|
| 474 |
+
Format: PREDICT: left=safe|danger(reason), right=safe|danger(reason), fwd=safe|danger(reason), back=safe|danger(reason)
|
| 475 |
+
|
| 476 |
+
Line 2 — MOTION: Describe what the person should do.
|
| 477 |
+
Format: MOTION: a person [action description, max 12 words]
|
| 478 |
+
|
| 479 |
+
Rules:
|
| 480 |
+
- If walls.left is a number (distance in meters), left direction has a wall → danger(wall)
|
| 481 |
+
- If walls.left is null, left direction is open → safe(open)
|
| 482 |
+
- Same for right, front
|
| 483 |
+
- If npc_nearby=true and npc_type="beast", the NPC direction is danger(beast)
|
| 484 |
+
- If npc_nearby=true and npc_type="woman" or "man", assess threat level based on behavior
|
| 485 |
+
- MOTION must reflect the PREDICT assessment — never move toward danger
|
| 486 |
+
- MOTION should include emotional nuance when threats are present
|
| 487 |
+
- Use recent_decisions to inform your choice (avoid repeating failed strategies)
|
| 488 |
+
|
| 489 |
+
Example input:
|
| 490 |
+
{"walls": {"left": 1.5, "right": null, "front": null}, "ground": "flat", "npc_nearby": true, "npc_type": "beast", "npc_behavior": "charge", "npc_distance": 3.0, "npc_direction": "front", "sound": "aggressive growling", "recent_decisions": [], "last_prediction": null}
|
| 491 |
+
|
| 492 |
+
Example output:
|
| 493 |
+
PREDICT: left=danger(wall), right=safe(open), fwd=danger(beast), back=safe(open)
|
| 494 |
+
MOTION: a person sprinting right in terror to escape the charging beast"""
|
| 495 |
+
|
| 496 |
+
USER_PROMPT_TEMPLATE = """scene_context = {scene_json}
|
| 497 |
+
|
| 498 |
+
Output exactly 2 lines: PREDICT and MOTION."""
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
# ═══════════════════════════════════════════════════════════════
|
| 502 |
+
# SECTION 4: 평가 실행기 — 어떤 모델이든 평가
|
| 503 |
+
# ═══════════════════════════════════════════════════════════════
|
| 504 |
+
|
| 505 |
+
"""
|
| 506 |
+
참가자가 해야 할 것:
|
| 507 |
+
1. evaluate() 함수에 자기 모델의 inference 함수를 넘긴다
|
| 508 |
+
2. inference 함수는 (system_prompt, user_prompt) → str 형태
|
| 509 |
+
3. 50개 시나리오를 자동으로 돌리고 채점한다
|
| 510 |
+
4. 결과 JSON을 HF에 제출한다
|
| 511 |
+
|
| 512 |
+
참가자가 안 해도 되는 것:
|
| 513 |
+
- 3D 환경 구축
|
| 514 |
+
- GPU 성능 측정 (Track A는 불필요)
|
| 515 |
+
- 채점 (자동)
|
| 516 |
+
"""
|
| 517 |
+
|
| 518 |
+
|
| 519 |
+
def make_user_prompt(scene_input: dict) -> str:
|
| 520 |
+
"""scene_context를 프롬프트로 변환"""
|
| 521 |
+
return USER_PROMPT_TEMPLATE.format(
|
| 522 |
+
scene_json=json.dumps(scene_input, ensure_ascii=False)
|
| 523 |
+
)
|
| 524 |
+
|
| 525 |
+
|
| 526 |
+
def evaluate_track_a(
|
| 527 |
+
inference_fn, # (system_prompt: str, user_prompt: str) -> str
|
| 528 |
+
scenarios: list = None,
|
| 529 |
+
verbose: bool = True,
|
| 530 |
+
) -> dict:
|
| 531 |
+
"""
|
| 532 |
+
Track A 평가 실행기
|
| 533 |
+
|
| 534 |
+
사용법:
|
| 535 |
+
# OpenAI API 기반 모델
|
| 536 |
+
def my_model(system_prompt, user_prompt):
|
| 537 |
+
response = openai.chat.completions.create(
|
| 538 |
+
model="gpt-4",
|
| 539 |
+
messages=[
|
| 540 |
+
{"role": "system", "content": system_prompt},
|
| 541 |
+
{"role": "user", "content": user_prompt},
|
| 542 |
+
],
|
| 543 |
+
)
|
| 544 |
+
return response.choices[0].message.content
|
| 545 |
+
|
| 546 |
+
results = evaluate_track_a(my_model)
|
| 547 |
+
|
| 548 |
+
# Hugging Face 모델
|
| 549 |
+
def my_hf_model(system_prompt, user_prompt):
|
| 550 |
+
prompt = f"{system_prompt}\n\n{user_prompt}"
|
| 551 |
+
return pipeline(prompt)[0]["generated_text"]
|
| 552 |
+
|
| 553 |
+
results = evaluate_track_a(my_hf_model)
|
| 554 |
+
|
| 555 |
+
반환값:
|
| 556 |
+
{
|
| 557 |
+
"wm_score": 726,
|
| 558 |
+
"grade": "B",
|
| 559 |
+
"pillar_scores": {...},
|
| 560 |
+
"category_scores": {...},
|
| 561 |
+
"scenario_details": [...], # 각 시나리오별 점수+근거
|
| 562 |
+
}
|
| 563 |
+
"""
|
| 564 |
+
if scenarios is None:
|
| 565 |
+
scenarios = SCENARIO_INPUTS
|
| 566 |
+
|
| 567 |
+
# wm_bench_scoring.py에서 import
|
| 568 |
+
from wm_bench_scoring import (
|
| 569 |
+
parse_predict_line, parse_motion_line,
|
| 570 |
+
score_c01, score_c03, score_c04, score_c05,
|
| 571 |
+
score_c08, calculate_wm_score,
|
| 572 |
+
get_action_intensity, get_emotion_intensity,
|
| 573 |
+
)
|
| 574 |
+
|
| 575 |
+
results = []
|
| 576 |
+
category_totals = {}
|
| 577 |
+
|
| 578 |
+
for scenario in scenarios:
|
| 579 |
+
sid = scenario["id"]
|
| 580 |
+
cat = scenario["category"]
|
| 581 |
+
gt = scenario["ground_truth"]
|
| 582 |
+
method = gt["scoring_method"]
|
| 583 |
+
|
| 584 |
+
if verbose:
|
| 585 |
+
print(f" [{sid}] {scenario.get('name_kr', sid)}...", end=" ")
|
| 586 |
+
|
| 587 |
+
# ── 단일 입력 시나리오 ──
|
| 588 |
+
if "input" in scenario:
|
| 589 |
+
prompt = make_user_prompt(scenario["input"])
|
| 590 |
+
raw_output = inference_fn(SYSTEM_PROMPT, prompt)
|
| 591 |
+
|
| 592 |
+
# 파싱
|
| 593 |
+
lines = raw_output.strip().split("\n")
|
| 594 |
+
predict_line = ""
|
| 595 |
+
motion_line = ""
|
| 596 |
+
for line in lines:
|
| 597 |
+
line = line.strip()
|
| 598 |
+
if line.upper().startswith("PREDICT"):
|
| 599 |
+
predict_line = line
|
| 600 |
+
elif line.upper().startswith("MOTION"):
|
| 601 |
+
motion_line = line
|
| 602 |
+
|
| 603 |
+
predict = parse_predict_line(predict_line)
|
| 604 |
+
motion = parse_motion_line(motion_line)
|
| 605 |
+
|
| 606 |
+
# 채점
|
| 607 |
+
if method == "C01":
|
| 608 |
+
score, reasoning = score_c01(
|
| 609 |
+
scenario["input"], predict, gt["predict_gt"]
|
| 610 |
+
)
|
| 611 |
+
elif method == "C03":
|
| 612 |
+
score, reasoning = score_c03(
|
| 613 |
+
scenario["input"], predict, motion, gt["decision_gt"]
|
| 614 |
+
)
|
| 615 |
+
elif method == "C08":
|
| 616 |
+
score, reasoning = score_c08(motion, gt)
|
| 617 |
+
elif method.startswith("C04_pair") or method.startswith("C06_pair"):
|
| 618 |
+
# 쌍 비교는 별도 처리 (아래)
|
| 619 |
+
score = None
|
| 620 |
+
reasoning = "pair_pending"
|
| 621 |
+
else:
|
| 622 |
+
score = 0
|
| 623 |
+
reasoning = f"Unknown scoring method: {method}"
|
| 624 |
+
|
| 625 |
+
results.append({
|
| 626 |
+
"id": sid,
|
| 627 |
+
"category": cat,
|
| 628 |
+
"raw_output": raw_output,
|
| 629 |
+
"predict_parsed": {k: v.raw for k, v in predict.items()},
|
| 630 |
+
"motion_parsed": motion,
|
| 631 |
+
"score": score,
|
| 632 |
+
"reasoning": reasoning,
|
| 633 |
+
})
|
| 634 |
+
|
| 635 |
+
# ── 연속 입력 시나리오 (C05) ──
|
| 636 |
+
elif "input_sequence" in scenario:
|
| 637 |
+
motions = []
|
| 638 |
+
for seq_input in scenario["input_sequence"]:
|
| 639 |
+
prompt = make_user_prompt(seq_input)
|
| 640 |
+
raw_output = inference_fn(SYSTEM_PROMPT, prompt)
|
| 641 |
+
for line in raw_output.strip().split("\n"):
|
| 642 |
+
if line.strip().upper().startswith("MOTION"):
|
| 643 |
+
motions.append(parse_motion_line(line))
|
| 644 |
+
break
|
| 645 |
+
|
| 646 |
+
score, reasoning = score_c05(motions, gt)
|
| 647 |
+
results.append({
|
| 648 |
+
"id": sid,
|
| 649 |
+
"category": cat,
|
| 650 |
+
"motion_sequence": motions,
|
| 651 |
+
"score": score,
|
| 652 |
+
"reasoning": reasoning,
|
| 653 |
+
})
|
| 654 |
+
|
| 655 |
+
if verbose and score is not None:
|
| 656 |
+
print(f"{score}/20")
|
| 657 |
+
elif verbose:
|
| 658 |
+
print("(pair pending)")
|
| 659 |
+
|
| 660 |
+
# ── 쌍 비교 채점 (C04, C06) ──
|
| 661 |
+
pair_groups = {}
|
| 662 |
+
for r in results:
|
| 663 |
+
if r["reasoning"] == "pair_pending":
|
| 664 |
+
gt = None
|
| 665 |
+
for s in scenarios:
|
| 666 |
+
if s["id"] == r["id"]:
|
| 667 |
+
gt = s["ground_truth"]
|
| 668 |
+
break
|
| 669 |
+
if gt:
|
| 670 |
+
pair_id = gt.get("pair_id", r["id"].rstrip("AB_"))
|
| 671 |
+
if pair_id not in pair_groups:
|
| 672 |
+
pair_groups[pair_id] = {}
|
| 673 |
+
role = gt.get("pair_role", "A")
|
| 674 |
+
pair_groups[pair_id][role] = r
|
| 675 |
+
pair_groups[pair_id]["gt"] = gt
|
| 676 |
+
|
| 677 |
+
for pair_id, group in pair_groups.items():
|
| 678 |
+
if "A" in group and "B" in group:
|
| 679 |
+
score, reasoning = score_c04(
|
| 680 |
+
group["A"]["motion_parsed"],
|
| 681 |
+
group["B"]["motion_parsed"],
|
| 682 |
+
group["gt"],
|
| 683 |
+
)
|
| 684 |
+
# 양쪽 모두에 점수 할당 (총점은 한 번만 반영)
|
| 685 |
+
group["A"]["score"] = score
|
| 686 |
+
group["A"]["reasoning"] = reasoning
|
| 687 |
+
group["B"]["score"] = 0 # 쌍의 B는 0 (A에서 합산)
|
| 688 |
+
group["B"]["reasoning"] = "scored in pair A"
|
| 689 |
+
|
| 690 |
+
# ── 카테고리별 합산 ──
|
| 691 |
+
for r in results:
|
| 692 |
+
cat = r["category"]
|
| 693 |
+
if r["score"] is not None and r["score"] > 0:
|
| 694 |
+
category_totals[cat] = category_totals.get(cat, 0) + r["score"]
|
| 695 |
+
|
| 696 |
+
# ── 최종 WM Score 계산 ──
|
| 697 |
+
final = calculate_wm_score(category_totals)
|
| 698 |
+
final["scenario_details"] = results
|
| 699 |
+
|
| 700 |
+
return final
|
| 701 |
+
|
| 702 |
+
|
| 703 |
+
# ═══════════════════════════════════════════════════════════════
|
| 704 |
+
# SECTION 5: 제출 포맷
|
| 705 |
+
# ═══════════════════════════════════════════════════════════════
|
| 706 |
+
|
| 707 |
+
SUBMISSION_FORMAT = {
|
| 708 |
+
"model_name": "str — 모델명 (예: VIDRAFT PROMETHEUS v1.0)",
|
| 709 |
+
"organization": "str — 조직명",
|
| 710 |
+
"track": "str — A | B | C",
|
| 711 |
+
"brain_model": "str — 사용한 인지 모델 (예: Kimi K2.5, GPT-4, custom RL)",
|
| 712 |
+
"motion_model": "str | null — 모션 생성 모델 (Track A는 null 가능)",
|
| 713 |
+
"wm_score": "int — 자동 산출됨",
|
| 714 |
+
"grade": "str — 자동 산출됨",
|
| 715 |
+
"results_json": "str — evaluate_track_a()의 전체 출력",
|
| 716 |
+
"performance_metrics": {
|
| 717 |
+
"fps": "float | null — Track B/C만",
|
| 718 |
+
"cognitive_latency_ms": "int | null",
|
| 719 |
+
"gpu": "str | null",
|
| 720 |
+
},
|
| 721 |
+
"demo_url": "str | null — Track C만",
|
| 722 |
+
"paper_url": "str | null — 선택",
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
+
|
| 726 |
+
# ═══════════════════════════════════════════════════════════════
|
| 727 |
+
# SECTION 6: 사용 예시
|
| 728 |
+
# ═══════════════════════════════════════════════════════════════
|
| 729 |
+
|
| 730 |
+
USAGE_EXAMPLES = """
|
| 731 |
+
# ━━━ 예시 1: OpenAI GPT-4로 참여 ━━━
|
| 732 |
+
|
| 733 |
+
from wm_bench_eval import evaluate_track_a, SYSTEM_PROMPT
|
| 734 |
+
import openai
|
| 735 |
+
|
| 736 |
+
def gpt4_inference(system_prompt, user_prompt):
|
| 737 |
+
response = openai.chat.completions.create(
|
| 738 |
+
model="gpt-4o",
|
| 739 |
+
messages=[
|
| 740 |
+
{"role": "system", "content": system_prompt},
|
| 741 |
+
{"role": "user", "content": user_prompt},
|
| 742 |
+
],
|
| 743 |
+
max_tokens=150,
|
| 744 |
+
temperature=0.3,
|
| 745 |
+
)
|
| 746 |
+
return response.choices[0].message.content
|
| 747 |
+
|
| 748 |
+
results = evaluate_track_a(gpt4_inference)
|
| 749 |
+
print(f"WM Score: {results['wm_score']}/1000 (Grade {results['grade']})")
|
| 750 |
+
|
| 751 |
+
|
| 752 |
+
# ━━━ 예시 2: Claude로 참여 ━━━
|
| 753 |
+
|
| 754 |
+
import anthropic
|
| 755 |
+
|
| 756 |
+
def claude_inference(system_prompt, user_prompt):
|
| 757 |
+
client = anthropic.Anthropic()
|
| 758 |
+
message = client.messages.create(
|
| 759 |
+
model="claude-sonnet-4-20250514",
|
| 760 |
+
max_tokens=150,
|
| 761 |
+
system=system_prompt,
|
| 762 |
+
messages=[{"role": "user", "content": user_prompt}],
|
| 763 |
+
)
|
| 764 |
+
return message.content[0].text
|
| 765 |
+
|
| 766 |
+
results = evaluate_track_a(claude_inference)
|
| 767 |
+
|
| 768 |
+
|
| 769 |
+
# ━━━ 예시 3: 로컬 LLM (vLLM)으로 참여 ━━━
|
| 770 |
+
|
| 771 |
+
from vllm import LLM, SamplingParams
|
| 772 |
+
|
| 773 |
+
llm = LLM(model="mistralai/Mistral-7B-Instruct-v0.3")
|
| 774 |
+
params = SamplingParams(max_tokens=150, temperature=0.3)
|
| 775 |
+
|
| 776 |
+
def local_inference(system_prompt, user_prompt):
|
| 777 |
+
prompt = f"[INST] {system_prompt}\\n\\n{user_prompt} [/INST]"
|
| 778 |
+
outputs = llm.generate([prompt], params)
|
| 779 |
+
return outputs[0].outputs[0].text
|
| 780 |
+
|
| 781 |
+
results = evaluate_track_a(local_inference)
|
| 782 |
+
|
| 783 |
+
|
| 784 |
+
# ━━━ 예시 4: 커스텀 RL 에이전트로 참여 ━━━
|
| 785 |
+
|
| 786 |
+
def rl_agent_inference(system_prompt, user_prompt):
|
| 787 |
+
# scene_context에서 JSON 파싱
|
| 788 |
+
import json, re
|
| 789 |
+
match = re.search(r'scene_context = ({.*})', user_prompt, re.DOTALL)
|
| 790 |
+
scene = json.loads(match.group(1))
|
| 791 |
+
|
| 792 |
+
# RL 에이전트의 policy로 판단
|
| 793 |
+
predict = my_rl_agent.predict(scene)
|
| 794 |
+
motion = my_rl_agent.decide_motion(scene, predict)
|
| 795 |
+
|
| 796 |
+
# WM Bench 포맷으로 변환
|
| 797 |
+
return f"PREDICT: {predict}\\nMOTION: {motion}"
|
| 798 |
+
|
| 799 |
+
results = evaluate_track_a(rl_agent_inference)
|
| 800 |
+
|
| 801 |
+
|
| 802 |
+
# ━━━ 예시 5: 결과 제출 ━━━
|
| 803 |
+
|
| 804 |
+
import json
|
| 805 |
+
|
| 806 |
+
submission = {
|
| 807 |
+
"model_name": "My World Model v1.0",
|
| 808 |
+
"organization": "My Company",
|
| 809 |
+
"track": "A",
|
| 810 |
+
"brain_model": "GPT-4o",
|
| 811 |
+
"motion_model": None,
|
| 812 |
+
"wm_score": results["wm_score"],
|
| 813 |
+
"grade": results["grade"],
|
| 814 |
+
"results_json": json.dumps(results),
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
# HuggingFace에 제출
|
| 818 |
+
# huggingface_hub.upload_file(...)
|
| 819 |
+
"""
|
| 820 |
+
|
| 821 |
+
|
| 822 |
+
if __name__ == "__main__":
|
| 823 |
+
print("=" * 60)
|
| 824 |
+
print(" World Model Bench — Evaluation Protocol v1.0")
|
| 825 |
+
print("=" * 60)
|
| 826 |
+
print()
|
| 827 |
+
print(" Tracks:")
|
| 828 |
+
for tid, t in TRACKS.items():
|
| 829 |
+
print(f" Track {tid}: {t['name']} (max {t['max_score']}pts)")
|
| 830 |
+
print()
|
| 831 |
+
print(f" Scenarios loaded: {len(SCENARIO_INPUTS)}")
|
| 832 |
+
print(f" System prompt: {len(SYSTEM_PROMPT)} chars")
|
| 833 |
+
print()
|
| 834 |
+
print(" How to participate:")
|
| 835 |
+
print(" 1. Write an inference function: (system, user) → str")
|
| 836 |
+
print(" 2. Run: results = evaluate_track_a(your_fn)")
|
| 837 |
+
print(" 3. Submit results to HuggingFace")
|
| 838 |
+
print()
|
| 839 |
+
print(" No 3D environment needed. Text in, text out.")
|
| 840 |
+
print("=" * 60)
|
wm_bench_scoring.py
ADDED
|
@@ -0,0 +1,1060 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
World Model Bench — Quantitative Scoring Specification v1.0
|
| 3 |
+
|
| 4 |
+
설계 원칙:
|
| 5 |
+
1. 모든 점수는 정량적 — 주관적 판단 0%
|
| 6 |
+
2. 제3자 재현 가능 — 동일 입력 → 동일 점수
|
| 7 |
+
3. 자동 채점 — 코드가 판정, 사람이 판정 안 함
|
| 8 |
+
4. 반박 불가 — 각 점수에 수학적/논리적 근거
|
| 9 |
+
|
| 10 |
+
핵심 메커니즘:
|
| 11 |
+
- 모든 시나리오는 "입력(scene_context) → 출력(PREDICT+MOTION)" 쌍
|
| 12 |
+
- 채점은 출력 텍스트를 파싱하여 정량 지표로 변환
|
| 13 |
+
- 파싱 규칙이 명시적이므로 누가 해도 동일 결과
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
import json
|
| 17 |
+
import re
|
| 18 |
+
from dataclasses import dataclass, field
|
| 19 |
+
from typing import List, Dict, Optional, Tuple
|
| 20 |
+
from enum import IntEnum
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# ═══════════════════════════════════════════════════════════════
|
| 24 |
+
# SECTION 1: 출력 포맷 정의 (채점의 전제 조건)
|
| 25 |
+
# ═══════════════════════════════════════════════════════════════
|
| 26 |
+
|
| 27 |
+
"""
|
| 28 |
+
모든 월드모델은 아래 포맷으로 출력해야 채점 가능:
|
| 29 |
+
|
| 30 |
+
INPUT (시스템이 제공):
|
| 31 |
+
scene_context = {
|
| 32 |
+
"walls": {"left": float, "right": float, "front": float}, # 거리(m), null=없음
|
| 33 |
+
"ground": str, # "flat", "slope", "stairs"
|
| 34 |
+
"npc_nearby": bool,
|
| 35 |
+
"npc_type": str|null, # "beast", "woman", "man", null
|
| 36 |
+
"npc_behavior": str|null, # "stop", "approach", "charge", "wander"
|
| 37 |
+
"npc_distance": float|null,
|
| 38 |
+
"sound": str|null, # "aggressive growling", "footsteps", null
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
OUTPUT (모델이 출력):
|
| 42 |
+
Line 1: PREDICT: left=safe|danger(reason), right=..., fwd=..., back=...
|
| 43 |
+
Line 2: MOTION: a person [max 12 words describing action]
|
| 44 |
+
|
| 45 |
+
채점은 이 두 줄을 파싱하여 수행.
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# ═══════════════════════════════════════════════════════════════
|
| 50 |
+
# SECTION 2: 파서 — 출력 텍스트를 구조화된 데이터로 변환
|
| 51 |
+
# ═══════════════════════════════════════════════════════════════
|
| 52 |
+
|
| 53 |
+
class PredictDirection:
|
| 54 |
+
"""PREDICT 줄의 한 방향을 파싱한 결과"""
|
| 55 |
+
def __init__(self, raw: str):
|
| 56 |
+
self.raw = raw.strip()
|
| 57 |
+
self.is_safe = "safe" in self.raw.lower()
|
| 58 |
+
self.is_danger = "danger" in self.raw.lower()
|
| 59 |
+
# 괄호 안의 이유 추출: danger(wall) → "wall"
|
| 60 |
+
match = re.search(r'\(([^)]+)\)', self.raw)
|
| 61 |
+
self.reason = match.group(1).lower() if match else None
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def parse_predict_line(line: str) -> Dict[str, PredictDirection]:
|
| 65 |
+
"""
|
| 66 |
+
PREDICT: left=safe(open), right=danger(wall), fwd=danger(beast), back=safe
|
| 67 |
+
→ {"left": PredictDirection, "right": ..., "fwd": ..., "back": ...}
|
| 68 |
+
"""
|
| 69 |
+
result = {}
|
| 70 |
+
line = line.replace("PREDICT:", "").strip()
|
| 71 |
+
for part in line.split(","):
|
| 72 |
+
part = part.strip()
|
| 73 |
+
if "=" not in part:
|
| 74 |
+
continue
|
| 75 |
+
key, val = part.split("=", 1)
|
| 76 |
+
key = key.strip().lower()
|
| 77 |
+
# 정규화: left/right/fwd/forward/back/backward
|
| 78 |
+
if key in ("forward", "fwd", "front"):
|
| 79 |
+
key = "fwd"
|
| 80 |
+
if key in ("backward", "back"):
|
| 81 |
+
key = "back"
|
| 82 |
+
result[key] = PredictDirection(val)
|
| 83 |
+
return result
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def parse_motion_line(line: str) -> str:
|
| 87 |
+
"""
|
| 88 |
+
MOTION: a person sprinting right in terror
|
| 89 |
+
→ "a person sprinting right in terror"
|
| 90 |
+
"""
|
| 91 |
+
return line.replace("MOTION:", "").strip().lower()
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
# ═══════════════════════════════════════════════════════════════
|
| 95 |
+
# SECTION 3: 키워드 사전 — 감정/행동 강도의 정량 기준
|
| 96 |
+
# ═══════════════════════════════════════════════════════════════
|
| 97 |
+
|
| 98 |
+
"""
|
| 99 |
+
핵심: "sprint"와 "walk"의 차이를 수치로 정의
|
| 100 |
+
이 사전이 벤치마크의 재현성을 보장함
|
| 101 |
+
제3자가 이 사전으로 동일한 채점 결과를 얻을 수 있음
|
| 102 |
+
"""
|
| 103 |
+
|
| 104 |
+
class Intensity(IntEnum):
|
| 105 |
+
"""행동 강도 레벨 (0~5)"""
|
| 106 |
+
NONE = 0 # 무반응
|
| 107 |
+
MINIMAL = 1 # 미약한 반응
|
| 108 |
+
LOW = 2 # 가벼운 반응
|
| 109 |
+
MEDIUM = 3 # 보통 반응
|
| 110 |
+
HIGH = 4 # 강한 반응
|
| 111 |
+
EXTREME = 5 # 극단적 반응
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
# 행동 키워드 → 강도 매핑 (알파벳 순, 검색 용이)
|
| 115 |
+
ACTION_INTENSITY: Dict[str, int] = {
|
| 116 |
+
# EXTREME (5)
|
| 117 |
+
"desperate": 5, "desperately": 5, "frantic": 5, "frantically": 5,
|
| 118 |
+
"flee": 5, "fleeing": 5, "panic": 5, "panicking": 5,
|
| 119 |
+
"terror": 5, "terrified": 5,
|
| 120 |
+
# HIGH (4)
|
| 121 |
+
"bolt": 4, "bolting": 4, "dash": 4, "dashing": 4,
|
| 122 |
+
"escape": 4, "escaping": 4, "run": 4, "running": 4,
|
| 123 |
+
"rush": 4, "rushing": 4, "sprint": 4, "sprinting": 4,
|
| 124 |
+
# MEDIUM (3)
|
| 125 |
+
"hurry": 3, "hurrying": 3, "jog": 3, "jogging": 3,
|
| 126 |
+
"quick": 3, "quickly": 3, "retreat": 3, "retreating": 3,
|
| 127 |
+
"step back": 3, "stepping back": 3, "back away": 3,
|
| 128 |
+
# LOW (2)
|
| 129 |
+
"cautious": 2, "cautiously": 2, "slow": 2, "slowly": 2,
|
| 130 |
+
"walk": 2, "walking": 2, "turn": 2, "turning": 2,
|
| 131 |
+
"move": 2, "moving": 2, "shift": 2,
|
| 132 |
+
# MINIMAL (1)
|
| 133 |
+
"stand": 1, "standing": 1, "pause": 1, "pausing": 1,
|
| 134 |
+
"freeze": 1, "freezing": 1, "stop": 1, "stopping": 1,
|
| 135 |
+
"observe": 1, "watching": 1, "look": 1, "looking": 1,
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
# 감정 키워드 → 강도 매핑
|
| 139 |
+
EMOTION_INTENSITY: Dict[str, int] = {
|
| 140 |
+
# EXTREME (5)
|
| 141 |
+
"terror": 5, "terrified": 5, "horrified": 5, "desperate": 5,
|
| 142 |
+
"frantic": 5, "panic": 5, "anguish": 5,
|
| 143 |
+
# HIGH (4)
|
| 144 |
+
"fear": 4, "afraid": 4, "scared": 4, "alarmed": 4,
|
| 145 |
+
"distress": 4, "shock": 4, "dread": 4,
|
| 146 |
+
# MEDIUM (3)
|
| 147 |
+
"anxious": 3, "nervous": 3, "tense": 3, "worried": 3,
|
| 148 |
+
"uneasy": 3, "wary": 3, "alert": 3, "startled": 3,
|
| 149 |
+
# LOW (2)
|
| 150 |
+
"cautious": 2, "careful": 2, "vigilant": 2, "watchful": 2,
|
| 151 |
+
"guarded": 2, "attentive": 2,
|
| 152 |
+
# MINIMAL (1)
|
| 153 |
+
"calm": 1, "relaxed": 1, "composed": 1, "steady": 1,
|
| 154 |
+
"neutral": 1, "normal": 1,
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
# 방향 키워드 — MOTION에서 이동 방향 추출
|
| 158 |
+
DIRECTION_KEYWORDS: Dict[str, str] = {
|
| 159 |
+
"left": "left", "leftward": "left",
|
| 160 |
+
"right": "right", "rightward": "right",
|
| 161 |
+
"forward": "fwd", "ahead": "fwd", "front": "fwd",
|
| 162 |
+
"backward": "back", "backwards": "back", "back": "back",
|
| 163 |
+
"behind": "back", "around": "back", # "turn around" = back
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
def get_action_intensity(motion_text: str) -> int:
|
| 168 |
+
"""모션 텍스트에서 최대 행동 강도 추출"""
|
| 169 |
+
words = motion_text.lower()
|
| 170 |
+
max_intensity = 0
|
| 171 |
+
for keyword, intensity in ACTION_INTENSITY.items():
|
| 172 |
+
if keyword in words:
|
| 173 |
+
max_intensity = max(max_intensity, intensity)
|
| 174 |
+
return max_intensity
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def get_emotion_intensity(motion_text: str) -> int:
|
| 178 |
+
"""모션 텍스트에서 최대 감정 강도 추출"""
|
| 179 |
+
words = motion_text.lower()
|
| 180 |
+
max_intensity = 0
|
| 181 |
+
for keyword, intensity in EMOTION_INTENSITY.items():
|
| 182 |
+
if keyword in words:
|
| 183 |
+
max_intensity = max(max_intensity, intensity)
|
| 184 |
+
return max_intensity
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def get_motion_direction(motion_text: str) -> Optional[str]:
|
| 188 |
+
"""모션 텍스트에서 이동 방향 추출"""
|
| 189 |
+
words = motion_text.lower()
|
| 190 |
+
for keyword, direction in DIRECTION_KEYWORDS.items():
|
| 191 |
+
if keyword in words:
|
| 192 |
+
return direction
|
| 193 |
+
return None
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def count_descriptors(motion_text: str) -> int:
|
| 197 |
+
"""모션 텍스트의 감정/행동 수식어 총 개수"""
|
| 198 |
+
words = motion_text.lower()
|
| 199 |
+
count = 0
|
| 200 |
+
for keyword in ACTION_INTENSITY:
|
| 201 |
+
if keyword in words:
|
| 202 |
+
count += 1
|
| 203 |
+
for keyword in EMOTION_INTENSITY:
|
| 204 |
+
if keyword in words:
|
| 205 |
+
count += 1
|
| 206 |
+
return count
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
# ═══════════════════════════════════════════════════════════════
|
| 210 |
+
# SECTION 4: 10개 카테고리별 정량 채점 함수
|
| 211 |
+
# ═══════════════════════════════════════════════════════════════
|
| 212 |
+
|
| 213 |
+
"""
|
| 214 |
+
각 함수는:
|
| 215 |
+
- 입력: scene_context(dict) + model_output(str) + ground_truth(dict)
|
| 216 |
+
- 출력: score(int, 0~20) + reasoning(str)
|
| 217 |
+
- 결정론적: 같은 입력 → 항상 같은 점수
|
| 218 |
+
"""
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
# ─── C01: Environmental Awareness (환경 인식 정확도) ───
|
| 222 |
+
|
| 223 |
+
def score_c01(scene: dict, predict: dict, ground_truth: dict) -> Tuple[int, str]:
|
| 224 |
+
"""
|
| 225 |
+
채점 기준: PREDICT의 각 방향이 실제 환경과 일치하는가
|
| 226 |
+
|
| 227 |
+
ground_truth = {
|
| 228 |
+
"left": "safe" | "danger",
|
| 229 |
+
"right": "safe" | "danger",
|
| 230 |
+
"fwd": "safe" | "danger",
|
| 231 |
+
"back": "safe" | "danger",
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
채점:
|
| 235 |
+
4방향 모두 정확 = 20점
|
| 236 |
+
3방향 정확 = 15점
|
| 237 |
+
2방향 정확 = 10점
|
| 238 |
+
1방향 정확 = 5점
|
| 239 |
+
0방향 정확 = 0점
|
| 240 |
+
"""
|
| 241 |
+
directions = ["left", "right", "fwd", "back"]
|
| 242 |
+
correct = 0
|
| 243 |
+
details = []
|
| 244 |
+
|
| 245 |
+
for d in directions:
|
| 246 |
+
if d not in predict:
|
| 247 |
+
details.append(f"{d}: 출력 없음 (오답)")
|
| 248 |
+
continue
|
| 249 |
+
|
| 250 |
+
gt_safe = ground_truth.get(d) == "safe"
|
| 251 |
+
pred_safe = predict[d].is_safe
|
| 252 |
+
|
| 253 |
+
if gt_safe == pred_safe:
|
| 254 |
+
correct += 1
|
| 255 |
+
details.append(f"{d}: 정답 (GT={ground_truth[d]}, PRED={'safe' if pred_safe else 'danger'})")
|
| 256 |
+
else:
|
| 257 |
+
details.append(f"{d}: 오답 (GT={ground_truth[d]}, PRED={'safe' if pred_safe else 'danger'})")
|
| 258 |
+
|
| 259 |
+
score_map = {4: 20, 3: 15, 2: 10, 1: 5, 0: 0}
|
| 260 |
+
score = score_map[correct]
|
| 261 |
+
reasoning = f"환경 인식: {correct}/4 방향 정확. " + "; ".join(details)
|
| 262 |
+
|
| 263 |
+
return score, reasoning
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
# ─── C02: Entity Recognition (개체 인식 및 분류) ───
|
| 267 |
+
|
| 268 |
+
def score_c02(scene: dict, predict: dict, ground_truth: dict) -> Tuple[int, str]:
|
| 269 |
+
"""
|
| 270 |
+
채점 기준: PREDICT에서 개체를 올바른 유형으로 인식했는가
|
| 271 |
+
|
| 272 |
+
ground_truth = {
|
| 273 |
+
"entity_type": "beast" | "woman" | "man" | None,
|
| 274 |
+
"entity_direction": "left" | "right" | "fwd" | "back",
|
| 275 |
+
"is_threat": True | False,
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
채점 (합산, 최대 20점):
|
| 279 |
+
개체 방향 정확: 8점 (해당 방향에 danger 표시)
|
| 280 |
+
개체 유형 정확: 8점 (danger 괄호 안에 올바른 유형)
|
| 281 |
+
위협 수준 정확: 4점 (beast=danger, woman=danger 또는 safe 모두 가능)
|
| 282 |
+
"""
|
| 283 |
+
score = 0
|
| 284 |
+
details = []
|
| 285 |
+
|
| 286 |
+
gt_dir = ground_truth.get("entity_direction")
|
| 287 |
+
gt_type = ground_truth.get("entity_type")
|
| 288 |
+
|
| 289 |
+
if gt_type is None:
|
| 290 |
+
# 개체 없음 — 모든 방향이 safe여야 함
|
| 291 |
+
all_safe = all(p.is_safe for p in predict.values())
|
| 292 |
+
if all_safe:
|
| 293 |
+
score = 20
|
| 294 |
+
details.append("개체 없음 정확 인식")
|
| 295 |
+
else:
|
| 296 |
+
danger_dirs = [d for d, p in predict.items() if p.is_danger]
|
| 297 |
+
score = 10 # 부분 점수
|
| 298 |
+
details.append(f"개체 없는데 {danger_dirs}를 danger로 오인식")
|
| 299 |
+
else:
|
| 300 |
+
# 개체 존재
|
| 301 |
+
# 1) 방향 정확도 (8점)
|
| 302 |
+
if gt_dir in predict and predict[gt_dir].is_danger:
|
| 303 |
+
score += 8
|
| 304 |
+
details.append(f"방향 정확: {gt_dir}=danger")
|
| 305 |
+
else:
|
| 306 |
+
details.append(f"방향 오답: {gt_dir}에 danger 없음")
|
| 307 |
+
|
| 308 |
+
# 2) 유형 정확도 (8점)
|
| 309 |
+
if gt_dir in predict and predict[gt_dir].reason:
|
| 310 |
+
pred_reason = predict[gt_dir].reason
|
| 311 |
+
if gt_type in pred_reason:
|
| 312 |
+
score += 8
|
| 313 |
+
details.append(f"유형 정확: {pred_reason} 에 {gt_type} 포함")
|
| 314 |
+
else:
|
| 315 |
+
# 부분 점수: 위협으로 인식은 했으나 유형이 다름
|
| 316 |
+
score += 3
|
| 317 |
+
details.append(f"유형 부분: {pred_reason} (정답: {gt_type})")
|
| 318 |
+
else:
|
| 319 |
+
details.append("유형 정보 없음")
|
| 320 |
+
|
| 321 |
+
# 3) 위협 수준 (4점)
|
| 322 |
+
gt_threat = ground_truth.get("is_threat", False)
|
| 323 |
+
if gt_dir in predict:
|
| 324 |
+
pred_danger = predict[gt_dir].is_danger
|
| 325 |
+
if gt_threat == pred_danger:
|
| 326 |
+
score += 4
|
| 327 |
+
details.append(f"위협 수준 정확")
|
| 328 |
+
elif not gt_threat and not pred_danger:
|
| 329 |
+
score += 4
|
| 330 |
+
details.append(f"비위협 정확 인식")
|
| 331 |
+
|
| 332 |
+
reasoning = f"개체 인식: {score}/20. " + "; ".join(details)
|
| 333 |
+
return score, reasoning
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
# ─── C03: Predictive Reasoning (예측 기반 추론) ───
|
| 337 |
+
|
| 338 |
+
def score_c03(scene: dict, predict: dict, motion: str, ground_truth: dict) -> Tuple[int, str]:
|
| 339 |
+
"""
|
| 340 |
+
채점 기준: danger 방향을 피하고 safe 방향으로 이동했는가
|
| 341 |
+
|
| 342 |
+
ground_truth = {
|
| 343 |
+
"danger_directions": ["fwd", "left"], # 위험한 방향들
|
| 344 |
+
"safe_directions": ["right", "back"], # 안전한 방향들
|
| 345 |
+
"optimal_direction": "right", # 최적 방향
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
채점 (합산, 최대 20점):
|
| 349 |
+
danger 방향 회피: 8점 (이동 방향이 danger가 아님)
|
| 350 |
+
safe 방향 선택: 6점 (이동 방향이 safe 중 하나)
|
| 351 |
+
최적 방향 선택: 4점 (최적 방향 정확히 선택)
|
| 352 |
+
PREDICT-MOTION 일관성: 2점 (PREDICT에서 danger로 예측한 방향으로 안 감)
|
| 353 |
+
"""
|
| 354 |
+
score = 0
|
| 355 |
+
details = []
|
| 356 |
+
|
| 357 |
+
# 모션에서 이동 방향 추출
|
| 358 |
+
motion_dir = get_motion_direction(motion)
|
| 359 |
+
danger_dirs = ground_truth.get("danger_directions", [])
|
| 360 |
+
safe_dirs = ground_truth.get("safe_directions", [])
|
| 361 |
+
optimal = ground_truth.get("optimal_direction")
|
| 362 |
+
|
| 363 |
+
if motion_dir is None:
|
| 364 |
+
details.append("이동 방향 추출 불가 (방향 키워드 없음)")
|
| 365 |
+
# 방향은 없지만 행동이 합리적인지 확인
|
| 366 |
+
intensity = get_action_intensity(motion)
|
| 367 |
+
if intensity >= 3 and len(danger_dirs) > 0:
|
| 368 |
+
score += 4 # 위협에 대한 반응은 있음
|
| 369 |
+
details.append(f"방향 불명이나 반응 존재 (강도 {intensity})")
|
| 370 |
+
else:
|
| 371 |
+
# 1) danger 방향 회피 (8점)
|
| 372 |
+
if motion_dir not in danger_dirs:
|
| 373 |
+
score += 8
|
| 374 |
+
details.append(f"위험 방향 회피: {motion_dir} not in {danger_dirs}")
|
| 375 |
+
else:
|
| 376 |
+
details.append(f"위험 방향으로 이동: {motion_dir} in {danger_dirs}")
|
| 377 |
+
|
| 378 |
+
# 2) safe 방향 선택 (6점)
|
| 379 |
+
if motion_dir in safe_dirs:
|
| 380 |
+
score += 6
|
| 381 |
+
details.append(f"안전 방향 선택: {motion_dir} in {safe_dirs}")
|
| 382 |
+
else:
|
| 383 |
+
details.append(f"안전하지 않은 방향: {motion_dir} not in {safe_dirs}")
|
| 384 |
+
|
| 385 |
+
# 3) 최적 방향 (4점)
|
| 386 |
+
if motion_dir == optimal:
|
| 387 |
+
score += 4
|
| 388 |
+
details.append(f"최적 방향 정확: {motion_dir} == {optimal}")
|
| 389 |
+
else:
|
| 390 |
+
details.append(f"최적 아님: {motion_dir} != {optimal}")
|
| 391 |
+
|
| 392 |
+
# 4) PREDICT-MOTION 일관성 (2점)
|
| 393 |
+
if motion_dir and motion_dir in predict:
|
| 394 |
+
pred = predict[motion_dir]
|
| 395 |
+
if pred.is_safe:
|
| 396 |
+
score += 2
|
| 397 |
+
details.append("PREDICT-MOTION 일관: safe 방향으로 이동")
|
| 398 |
+
else:
|
| 399 |
+
details.append("PREDICT-MOTION 불일치: danger로 예측한 방향으로 이동")
|
| 400 |
+
|
| 401 |
+
reasoning = f"예측 추론: {score}/20. " + "; ".join(details)
|
| 402 |
+
return score, reasoning
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
# ─── C04: Threat Differentiation (위협 유형별 차별 반응) ───
|
| 406 |
+
|
| 407 |
+
def score_c04(
|
| 408 |
+
motion_a: str, motion_b: str,
|
| 409 |
+
ground_truth: dict
|
| 410 |
+
) -> Tuple[int, str]:
|
| 411 |
+
"""
|
| 412 |
+
채점 기준: 두 위협에 대한 반응 강도 차이가 올바른가
|
| 413 |
+
|
| 414 |
+
같은 scene에 (A) 맹수 접근 vs (B) 여성 접근
|
| 415 |
+
→ A의 반응 강도가 B보다 높아야 함
|
| 416 |
+
|
| 417 |
+
ground_truth = {
|
| 418 |
+
"scenario_a_type": "beast_charge",
|
| 419 |
+
"scenario_b_type": "woman_approach",
|
| 420 |
+
"expected_a_higher": True, # A가 더 강한 반응이어야
|
| 421 |
+
"min_intensity_diff": 2, # 최소 강도 차이
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
채점 (합산, 최대 20점):
|
| 425 |
+
반응 방향 정확: 8점 (A > B 또는 B > A 방향이 맞음)
|
| 426 |
+
강도 차이 충분: 8점 (차이가 min_intensity_diff 이상)
|
| 427 |
+
양쪽 모두 적절 반응: 4점 (둘 다 0이 아님)
|
| 428 |
+
"""
|
| 429 |
+
score = 0
|
| 430 |
+
details = []
|
| 431 |
+
|
| 432 |
+
int_a = get_action_intensity(motion_a)
|
| 433 |
+
int_b = get_action_intensity(motion_b)
|
| 434 |
+
expected_higher = ground_truth.get("expected_a_higher", True)
|
| 435 |
+
min_diff = ground_truth.get("min_intensity_diff", 2)
|
| 436 |
+
|
| 437 |
+
diff = int_a - int_b
|
| 438 |
+
|
| 439 |
+
# 1) 방향 정확 (8점)
|
| 440 |
+
if expected_higher and diff > 0:
|
| 441 |
+
score += 8
|
| 442 |
+
details.append(f"반응 방향 정확: A({int_a}) > B({int_b})")
|
| 443 |
+
elif not expected_higher and diff < 0:
|
| 444 |
+
score += 8
|
| 445 |
+
details.append(f"반응 방향 정확: B({int_b}) > A({int_a})")
|
| 446 |
+
elif diff == 0:
|
| 447 |
+
score += 2 # 부분 점수: 차이가 없음
|
| 448 |
+
details.append(f"반응 동일: A({int_a}) == B({int_b})")
|
| 449 |
+
else:
|
| 450 |
+
details.append(f"반응 방향 역전: A({int_a}), B({int_b})")
|
| 451 |
+
|
| 452 |
+
# 2) 강도 차이 (8점)
|
| 453 |
+
actual_diff = abs(diff)
|
| 454 |
+
if actual_diff >= min_diff:
|
| 455 |
+
score += 8
|
| 456 |
+
details.append(f"강도 차이 충분: |{diff}| >= {min_diff}")
|
| 457 |
+
elif actual_diff >= 1:
|
| 458 |
+
score += 4
|
| 459 |
+
details.append(f"강도 차이 부족: |{diff}| < {min_diff}")
|
| 460 |
+
else:
|
| 461 |
+
details.append(f"강도 차이 없음: |{diff}| = 0")
|
| 462 |
+
|
| 463 |
+
# 3) 양쪽 반응 존재 (4점)
|
| 464 |
+
if int_a > 0 and int_b > 0:
|
| 465 |
+
score += 4
|
| 466 |
+
details.append("양쪽 모두 반응 존재")
|
| 467 |
+
elif int_a > 0 or int_b > 0:
|
| 468 |
+
score += 2
|
| 469 |
+
details.append("한쪽만 반응 존재")
|
| 470 |
+
else:
|
| 471 |
+
details.append("양쪽 모두 무반응")
|
| 472 |
+
|
| 473 |
+
reasoning = f"위협 차별: {score}/20. A='{motion_a}' (강도{int_a}), B='{motion_b}' (강도{int_b}). " + "; ".join(details)
|
| 474 |
+
return score, reasoning
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
# ─── C05: Emotional Escalation (자율 감정 에스컬레이션) ───
|
| 478 |
+
|
| 479 |
+
def score_c05(motion_sequence: List[str], ground_truth: dict) -> Tuple[int, str]:
|
| 480 |
+
"""
|
| 481 |
+
채점 기준: 시간에 따른 감정 강도가 올바르게 변화하는가
|
| 482 |
+
|
| 483 |
+
motion_sequence = 같은 위협 지속 시 연속 3~5회 모션 출력
|
| 484 |
+
|
| 485 |
+
ground_truth = {
|
| 486 |
+
"expected_trend": "increasing" | "decreasing" | "stable",
|
| 487 |
+
"threat_type": "sustained_charge",
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
채점 (합산, 최대 20점):
|
| 491 |
+
추세 방향 정확: 10점
|
| 492 |
+
단조 증가/감소: 6점 (뒤로 가지 않음)
|
| 493 |
+
최종 강도 적절: 4점
|
| 494 |
+
"""
|
| 495 |
+
score = 0
|
| 496 |
+
details = []
|
| 497 |
+
|
| 498 |
+
if len(motion_sequence) < 2:
|
| 499 |
+
return 0, "시퀀스 길이 부족 (최소 2회 필요)"
|
| 500 |
+
|
| 501 |
+
intensities = [get_action_intensity(m) + get_emotion_intensity(m)
|
| 502 |
+
for m in motion_sequence]
|
| 503 |
+
|
| 504 |
+
expected = ground_truth.get("expected_trend", "increasing")
|
| 505 |
+
|
| 506 |
+
# 추세 계산
|
| 507 |
+
diffs = [intensities[i+1] - intensities[i] for i in range(len(intensities)-1)]
|
| 508 |
+
avg_diff = sum(diffs) / len(diffs)
|
| 509 |
+
|
| 510 |
+
# 1) 추세 방향 (10점)
|
| 511 |
+
if expected == "increasing":
|
| 512 |
+
if avg_diff > 0:
|
| 513 |
+
score += 10
|
| 514 |
+
details.append(f"증가 추세 정확: 평균 변화 +{avg_diff:.1f}")
|
| 515 |
+
elif avg_diff == 0:
|
| 516 |
+
score += 3
|
| 517 |
+
details.append(f"추세 변화 없음 (기대: 증가)")
|
| 518 |
+
else:
|
| 519 |
+
details.append(f"추세 역전 (기대: 증가, 실제: 감소 {avg_diff:.1f})")
|
| 520 |
+
elif expected == "decreasing":
|
| 521 |
+
if avg_diff < 0:
|
| 522 |
+
score += 10
|
| 523 |
+
details.append(f"감소 추세 정확: 평균 변화 {avg_diff:.1f}")
|
| 524 |
+
elif avg_diff == 0:
|
| 525 |
+
score += 3
|
| 526 |
+
details.append(f"추세 변화 없음 (기대: 감소)")
|
| 527 |
+
else:
|
| 528 |
+
details.append(f"추세 역전 (기대: 감소, 실제: 증가)")
|
| 529 |
+
elif expected == "stable":
|
| 530 |
+
if abs(avg_diff) <= 0.5:
|
| 531 |
+
score += 10
|
| 532 |
+
details.append(f"안정 유지 정확: 평균 변화 {avg_diff:.1f}")
|
| 533 |
+
else:
|
| 534 |
+
score += 4
|
| 535 |
+
details.append(f"불안정: 평균 변화 {avg_diff:.1f} (기대: 안정)")
|
| 536 |
+
|
| 537 |
+
# 2) 단조성 (6점) — 증가 추세에서 중간에 감소 없음
|
| 538 |
+
if expected == "increasing":
|
| 539 |
+
monotonic = all(d >= 0 for d in diffs)
|
| 540 |
+
elif expected == "decreasing":
|
| 541 |
+
monotonic = all(d <= 0 for d in diffs)
|
| 542 |
+
else:
|
| 543 |
+
monotonic = all(abs(d) <= 1 for d in diffs)
|
| 544 |
+
|
| 545 |
+
if monotonic:
|
| 546 |
+
score += 6
|
| 547 |
+
details.append("단조적 변화 (역행 없음)")
|
| 548 |
+
else:
|
| 549 |
+
non_monotonic_count = sum(1 for d in diffs if
|
| 550 |
+
(expected == "increasing" and d < 0) or
|
| 551 |
+
(expected == "decreasing" and d > 0))
|
| 552 |
+
if non_monotonic_count <= 1:
|
| 553 |
+
score += 3
|
| 554 |
+
details.append(f"약간의 역행 ({non_monotonic_count}회)")
|
| 555 |
+
else:
|
| 556 |
+
details.append(f"역행 다수 ({non_monotonic_count}회)")
|
| 557 |
+
|
| 558 |
+
# 3) 최종 강도 (4점)
|
| 559 |
+
if expected == "increasing" and intensities[-1] >= 6:
|
| 560 |
+
score += 4
|
| 561 |
+
details.append(f"최종 강도 충분: {intensities[-1]}")
|
| 562 |
+
elif expected == "decreasing" and intensities[-1] <= 3:
|
| 563 |
+
score += 4
|
| 564 |
+
details.append(f"최종 강도 적절히 낮음: {intensities[-1]}")
|
| 565 |
+
elif expected == "stable" and 2 <= intensities[-1] <= 4:
|
| 566 |
+
score += 4
|
| 567 |
+
details.append(f"최종 강도 안정적: {intensities[-1]}")
|
| 568 |
+
else:
|
| 569 |
+
score += 1
|
| 570 |
+
details.append(f"최종 강도: {intensities[-1]} (개선 여지)")
|
| 571 |
+
|
| 572 |
+
reasoning = f"감정 에스컬레이션: {score}/20. 강도 시퀀스: {intensities}. " + "; ".join(details)
|
| 573 |
+
return score, reasoning
|
| 574 |
+
|
| 575 |
+
|
| 576 |
+
# ─── C06: Contextual Memory (맥락 기억 활용) ───
|
| 577 |
+
|
| 578 |
+
def score_c06(
|
| 579 |
+
motion_without_memory: str,
|
| 580 |
+
motion_with_memory: str,
|
| 581 |
+
memory_content: str,
|
| 582 |
+
ground_truth: dict
|
| 583 |
+
) -> Tuple[int, str]:
|
| 584 |
+
"""
|
| 585 |
+
채점 기준: 기억이 있을 때와 없을 때 행동이 합리적으로 달라지는가
|
| 586 |
+
|
| 587 |
+
ground_truth = {
|
| 588 |
+
"memory_relevant": True, # 기억이 현 상황에 관련 있는가
|
| 589 |
+
"expected_change": "direction" | "intensity" | "both",
|
| 590 |
+
"memory_direction_avoid": "right", # 기억에 의해 피해야 할 방향
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
채점 (합산, 최대 20점):
|
| 594 |
+
기억 유무 차이 존재: 8점 (두 출력이 다름)
|
| 595 |
+
변화 방향 합리성: 8점 (기억 내용과 일치하는 변화)
|
| 596 |
+
기억 불필요 시 무변화: 4점 (무관한 기억에 영향 안 받음)
|
| 597 |
+
"""
|
| 598 |
+
score = 0
|
| 599 |
+
details = []
|
| 600 |
+
|
| 601 |
+
relevant = ground_truth.get("memory_relevant", True)
|
| 602 |
+
|
| 603 |
+
dir_without = get_motion_direction(motion_without_memory)
|
| 604 |
+
dir_with = get_motion_direction(motion_with_memory)
|
| 605 |
+
int_without = get_action_intensity(motion_without_memory)
|
| 606 |
+
int_with = get_action_intensity(motion_with_memory)
|
| 607 |
+
|
| 608 |
+
is_different = (motion_without_memory.strip() != motion_with_memory.strip())
|
| 609 |
+
dir_changed = (dir_without != dir_with)
|
| 610 |
+
int_changed = (int_without != int_with)
|
| 611 |
+
|
| 612 |
+
if relevant:
|
| 613 |
+
# 기억이 관련 있을 때: 변화가 있어야 함
|
| 614 |
+
# 1) 차이 존재 (8점)
|
| 615 |
+
if is_different:
|
| 616 |
+
score += 8
|
| 617 |
+
details.append(f"기억 반영 변화 있음")
|
| 618 |
+
else:
|
| 619 |
+
details.append("기억 있는데 변화 없음")
|
| 620 |
+
|
| 621 |
+
# 2) 변화 합리성 (8점)
|
| 622 |
+
expected_change = ground_truth.get("expected_change", "direction")
|
| 623 |
+
avoid_dir = ground_truth.get("memory_direction_avoid")
|
| 624 |
+
|
| 625 |
+
if expected_change in ("direction", "both") and avoid_dir:
|
| 626 |
+
if dir_with != avoid_dir and dir_without == avoid_dir:
|
| 627 |
+
score += 8
|
| 628 |
+
details.append(f"기억에 의해 {avoid_dir} 회피 → {dir_with} 선택")
|
| 629 |
+
elif dir_with != avoid_dir:
|
| 630 |
+
score += 4
|
| 631 |
+
details.append(f"회피 방향 올바르나 기존에도 안 감")
|
| 632 |
+
else:
|
| 633 |
+
details.append(f"기억에도 불구하고 {avoid_dir}로 이동")
|
| 634 |
+
|
| 635 |
+
# 3) 부분 점수
|
| 636 |
+
if int_changed and expected_change in ("intensity", "both"):
|
| 637 |
+
score += 4
|
| 638 |
+
details.append(f"강도 변화: {int_without} → {int_with}")
|
| 639 |
+
else:
|
| 640 |
+
# 기억이 무관할 때: 변화가 없어야 함
|
| 641 |
+
if not is_different:
|
| 642 |
+
score += 20
|
| 643 |
+
details.append("무관한 기억에 영향 안 받음 (완벽)")
|
| 644 |
+
elif not dir_changed and not int_changed:
|
| 645 |
+
score += 16
|
| 646 |
+
details.append("실질적 변화 없음 (문구만 다름)")
|
| 647 |
+
else:
|
| 648 |
+
score += 4
|
| 649 |
+
details.append("무관한 기억에 불필요한 영향 받음")
|
| 650 |
+
|
| 651 |
+
reasoning = f"기억 활용: {score}/20. " + "; ".join(details)
|
| 652 |
+
return score, reasoning
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
# ─── C07: Threat Resolution Adaptation (위협 해제 적응) ───
|
| 656 |
+
|
| 657 |
+
def score_c07(
|
| 658 |
+
motion_during_threat: str,
|
| 659 |
+
motion_after_threat: List[str], # 해제 후 연속 출력
|
| 660 |
+
ground_truth: dict
|
| 661 |
+
) -> Tuple[int, str]:
|
| 662 |
+
"""
|
| 663 |
+
채점 기준: 위협 해제 후 적절히 정상화되는가
|
| 664 |
+
|
| 665 |
+
ground_truth = {
|
| 666 |
+
"expected_recovery": "gradual", # "gradual" | "immediate" | "vigilant"
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
채점 (합산, 최대 20점):
|
| 670 |
+
즉시 전력질주 중단: 6점 (해제 직후 강도 감소)
|
| 671 |
+
점진적 정상화: 8점 (급격하지 않은 감소 곡선)
|
| 672 |
+
경계 유지: 6점 (완전 정상화 아닌 중간 단계 존재)
|
| 673 |
+
"""
|
| 674 |
+
score = 0
|
| 675 |
+
details = []
|
| 676 |
+
|
| 677 |
+
threat_intensity = get_action_intensity(motion_during_threat)
|
| 678 |
+
after_intensities = [get_action_intensity(m) for m in motion_after_threat]
|
| 679 |
+
|
| 680 |
+
if len(after_intensities) < 2:
|
| 681 |
+
return 0, "해제 후 시퀀스 부족"
|
| 682 |
+
|
| 683 |
+
# 1) 즉시 중단 (6점): 첫 반응이 위협 시보다 낮아야
|
| 684 |
+
if after_intensities[0] < threat_intensity:
|
| 685 |
+
score += 6
|
| 686 |
+
details.append(f"즉시 감소: {threat_intensity} → {after_intensities[0]}")
|
| 687 |
+
elif after_intensities[0] == threat_intensity:
|
| 688 |
+
score += 2
|
| 689 |
+
details.append(f"감소 없음: 여전히 {after_intensities[0]}")
|
| 690 |
+
else:
|
| 691 |
+
details.append(f"오히려 증가: {threat_intensity} → {after_intensities[0]}")
|
| 692 |
+
|
| 693 |
+
# 2) 점진적 정상화 (8점): 계단식 감소
|
| 694 |
+
is_gradual = True
|
| 695 |
+
for i in range(len(after_intensities) - 1):
|
| 696 |
+
if after_intensities[i+1] > after_intensities[i] + 1: # 허용 오차 1
|
| 697 |
+
is_gradual = False
|
| 698 |
+
|
| 699 |
+
if is_gradual and after_intensities[-1] < after_intensities[0]:
|
| 700 |
+
score += 8
|
| 701 |
+
details.append(f"점진적 정상화: {after_intensities}")
|
| 702 |
+
elif after_intensities[-1] <= 2:
|
| 703 |
+
score += 4
|
| 704 |
+
details.append(f"최종 정상화 도달 (과정 불규칙)")
|
| 705 |
+
else:
|
| 706 |
+
score += 1
|
| 707 |
+
details.append(f"정상화 미달: 최종 강도 {after_intensities[-1]}")
|
| 708 |
+
|
| 709 |
+
# 3) 경계 유지 (6점): 중간에 1~2 수준의 vigilant 단계
|
| 710 |
+
has_vigilant = any(1 <= i <= 3 for i in after_intensities)
|
| 711 |
+
if has_vigilant:
|
| 712 |
+
score += 6
|
| 713 |
+
details.append("경계 단계 존재 (vigilant/cautious)")
|
| 714 |
+
elif after_intensities[-1] == 0:
|
| 715 |
+
score += 1
|
| 716 |
+
details.append("경계 없이 즉시 완전 정상화 (비현실적)")
|
| 717 |
+
else:
|
| 718 |
+
score += 3
|
| 719 |
+
details.append("경계 단계 불명확")
|
| 720 |
+
|
| 721 |
+
reasoning = f"위협 해제 적응: {score}/20. 시퀀스: [{threat_intensity}]→{after_intensities}. " + "; ".join(details)
|
| 722 |
+
return score, reasoning
|
| 723 |
+
|
| 724 |
+
|
| 725 |
+
# ─── C08: Motion Expressiveness (모션 감정 표현력) ───
|
| 726 |
+
|
| 727 |
+
def score_c08(motion: str, ground_truth: dict) -> Tuple[int, str]:
|
| 728 |
+
"""
|
| 729 |
+
채점 기준: 모션 프롬프트의 표현 풍부함 (정량적)
|
| 730 |
+
|
| 731 |
+
ground_truth = {
|
| 732 |
+
"expected_min_intensity": 3, # 최소 기대 강도
|
| 733 |
+
"expected_emotion": True, # 감정 키워드 기대 여부
|
| 734 |
+
"expected_min_descriptors": 2, # 최소 수식어 수
|
| 735 |
+
}
|
| 736 |
+
|
| 737 |
+
채점 (합산, 최대 20점):
|
| 738 |
+
행동 강도 적절: 6점
|
| 739 |
+
감정 키워드 존재: 6점
|
| 740 |
+
수식어 풍부함: 4점
|
| 741 |
+
12단어 이내 준수: 4점
|
| 742 |
+
"""
|
| 743 |
+
score = 0
|
| 744 |
+
details = []
|
| 745 |
+
|
| 746 |
+
action_int = get_action_intensity(motion)
|
| 747 |
+
emotion_int = get_emotion_intensity(motion)
|
| 748 |
+
desc_count = count_descriptors(motion)
|
| 749 |
+
word_count = len(motion.split())
|
| 750 |
+
|
| 751 |
+
min_intensity = ground_truth.get("expected_min_intensity", 3)
|
| 752 |
+
expect_emotion = ground_truth.get("expected_emotion", True)
|
| 753 |
+
min_desc = ground_truth.get("expected_min_descriptors", 2)
|
| 754 |
+
|
| 755 |
+
# 1) 행동 강도 (6점)
|
| 756 |
+
if action_int >= min_intensity:
|
| 757 |
+
score += 6
|
| 758 |
+
details.append(f"행동 강도 적절: {action_int} >= {min_intensity}")
|
| 759 |
+
elif action_int >= min_intensity - 1:
|
| 760 |
+
score += 3
|
| 761 |
+
details.append(f"행동 강도 부족: {action_int} < {min_intensity}")
|
| 762 |
+
else:
|
| 763 |
+
details.append(f"행동 강도 미달: {action_int}")
|
| 764 |
+
|
| 765 |
+
# 2) 감정 키워드 (6점)
|
| 766 |
+
if expect_emotion:
|
| 767 |
+
if emotion_int >= 3:
|
| 768 |
+
score += 6
|
| 769 |
+
details.append(f"감정 풍부: 강도 {emotion_int}")
|
| 770 |
+
elif emotion_int >= 1:
|
| 771 |
+
score += 3
|
| 772 |
+
details.append(f"감정 약함: 강도 {emotion_int}")
|
| 773 |
+
else:
|
| 774 |
+
details.append("감정 키워드 없음")
|
| 775 |
+
else:
|
| 776 |
+
if emotion_int <= 1:
|
| 777 |
+
score += 6
|
| 778 |
+
details.append("감정 절제 적절 (평상시)")
|
| 779 |
+
else:
|
| 780 |
+
score += 3
|
| 781 |
+
details.append(f"불필요한 감정 표현: 강도 {emotion_int}")
|
| 782 |
+
|
| 783 |
+
# 3) 수식어 (4점)
|
| 784 |
+
if desc_count >= min_desc:
|
| 785 |
+
score += 4
|
| 786 |
+
details.append(f"수식어 풍부: {desc_count}개")
|
| 787 |
+
elif desc_count >= 1:
|
| 788 |
+
score += 2
|
| 789 |
+
details.append(f"수식어 부족: {desc_count}/{min_desc}")
|
| 790 |
+
else:
|
| 791 |
+
details.append("수식어 없음")
|
| 792 |
+
|
| 793 |
+
# 4) 길이 제한 준수 (4점)
|
| 794 |
+
if word_count <= 15: # 약간의 여유
|
| 795 |
+
score += 4
|
| 796 |
+
details.append(f"길이 적절: {word_count}단어")
|
| 797 |
+
elif word_count <= 20:
|
| 798 |
+
score += 2
|
| 799 |
+
details.append(f"다소 김: {word_count}단어")
|
| 800 |
+
else:
|
| 801 |
+
details.append(f"너무 김: {word_count}단어")
|
| 802 |
+
|
| 803 |
+
reasoning = f"표현력: {score}/20. '{motion}' (행동{action_int},감정{emotion_int},수식{desc_count},단어{word_count}). " + "; ".join(details)
|
| 804 |
+
return score, reasoning
|
| 805 |
+
|
| 806 |
+
|
| 807 |
+
# ─── C09: Realtime Performance (실시간 성능) ───
|
| 808 |
+
|
| 809 |
+
def score_c09(metrics: dict) -> Tuple[int, str]:
|
| 810 |
+
"""
|
| 811 |
+
채점 기준: 직접 측정된 성능 수치
|
| 812 |
+
|
| 813 |
+
metrics = {
|
| 814 |
+
"fps": float, # 평균 FPS
|
| 815 |
+
"cognitive_latency_ms": int, # 인지루프 지연 (ms)
|
| 816 |
+
"frame_drop_rate": float, # 프레임 드롭률 (0.0~1.0)
|
| 817 |
+
"gpu_memory_stable": bool, # GPU 메모리 안정 여부
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
채점 (합산, 최대 20점):
|
| 821 |
+
FPS: 8점 (≥45:8, ≥30:6, ≥15:3, <15:0)
|
| 822 |
+
인지 지연: 6점 (≤3s:6, ≤5s:4, ≤10s:2, >10s:0)
|
| 823 |
+
프레임 드롭: 4점 (<1%:4, <5%:2, ≥5%:0)
|
| 824 |
+
메모리 안정: 2점 (안정:2, 불안정:0)
|
| 825 |
+
"""
|
| 826 |
+
score = 0
|
| 827 |
+
details = []
|
| 828 |
+
|
| 829 |
+
fps = metrics.get("fps", 0)
|
| 830 |
+
latency = metrics.get("cognitive_latency_ms", 99999)
|
| 831 |
+
drop_rate = metrics.get("frame_drop_rate", 1.0)
|
| 832 |
+
mem_stable = metrics.get("gpu_memory_stable", False)
|
| 833 |
+
|
| 834 |
+
# FPS (8점)
|
| 835 |
+
if fps >= 45:
|
| 836 |
+
score += 8; details.append(f"FPS 우수: {fps:.1f}")
|
| 837 |
+
elif fps >= 30:
|
| 838 |
+
score += 6; details.append(f"FPS 양호: {fps:.1f}")
|
| 839 |
+
elif fps >= 15:
|
| 840 |
+
score += 3; details.append(f"FPS 최소: {fps:.1f}")
|
| 841 |
+
else:
|
| 842 |
+
details.append(f"FPS 미달: {fps:.1f}")
|
| 843 |
+
|
| 844 |
+
# 인지 지연 (6점)
|
| 845 |
+
latency_s = latency / 1000
|
| 846 |
+
if latency_s <= 3:
|
| 847 |
+
score += 6; details.append(f"지연 우수: {latency_s:.1f}s")
|
| 848 |
+
elif latency_s <= 5:
|
| 849 |
+
score += 4; details.append(f"지연 양호: {latency_s:.1f}s")
|
| 850 |
+
elif latency_s <= 10:
|
| 851 |
+
score += 2; details.append(f"지연 최소: {latency_s:.1f}s")
|
| 852 |
+
else:
|
| 853 |
+
details.append(f"지연 과다: {latency_s:.1f}s")
|
| 854 |
+
|
| 855 |
+
# 프레임 드롭 (4점)
|
| 856 |
+
if drop_rate < 0.01:
|
| 857 |
+
score += 4; details.append(f"드롭 없음: {drop_rate*100:.1f}%")
|
| 858 |
+
elif drop_rate < 0.05:
|
| 859 |
+
score += 2; details.append(f"드롭 소량: {drop_rate*100:.1f}%")
|
| 860 |
+
else:
|
| 861 |
+
details.append(f"드롭 과다: {drop_rate*100:.1f}%")
|
| 862 |
+
|
| 863 |
+
# 메모리 (2점)
|
| 864 |
+
if mem_stable:
|
| 865 |
+
score += 2; details.append("GPU 메모리 안정")
|
| 866 |
+
else:
|
| 867 |
+
details.append("GPU 메모리 불안정")
|
| 868 |
+
|
| 869 |
+
reasoning = f"실시간 성능: {score}/20. " + "; ".join(details)
|
| 870 |
+
return score, reasoning
|
| 871 |
+
|
| 872 |
+
|
| 873 |
+
# ─── C10: Cross-body Transferability (신체 교체 확장성) ───
|
| 874 |
+
|
| 875 |
+
def score_c10(transfer_results: dict) -> Tuple[int, str]:
|
| 876 |
+
"""
|
| 877 |
+
채점 기준: 인지 출력이 다른 신체에서도 동작하는가
|
| 878 |
+
|
| 879 |
+
transfer_results = {
|
| 880 |
+
"brain_output_unchanged": bool, # 두뇌 코드 수정 없이
|
| 881 |
+
"motion_model_swapped": bool, # 모션 모델 교체 성공
|
| 882 |
+
"joint_format_compatible": bool, # 관절 포맷 호환
|
| 883 |
+
"intent_preserved": bool, # 행동 의도 보존
|
| 884 |
+
"servo_mapping_ready": bool, # 로봇 서보 매핑 준비
|
| 885 |
+
}
|
| 886 |
+
|
| 887 |
+
채점 (합산, 최대 20점):
|
| 888 |
+
두뇌 코드 불변: 6점
|
| 889 |
+
모션 모델 교체: 4점
|
| 890 |
+
관절 호환: 4점
|
| 891 |
+
의도 보존: 4점
|
| 892 |
+
서보 매핑 준비: 2점
|
| 893 |
+
"""
|
| 894 |
+
score = 0
|
| 895 |
+
details = []
|
| 896 |
+
|
| 897 |
+
checks = [
|
| 898 |
+
("brain_output_unchanged", 6, "두뇌 코드 불변"),
|
| 899 |
+
("motion_model_swapped", 4, "모션 모델 교체"),
|
| 900 |
+
("joint_format_compatible", 4, "관절 포맷 호환"),
|
| 901 |
+
("intent_preserved", 4, "행동 의도 보존"),
|
| 902 |
+
("servo_mapping_ready", 2, "서보 매핑 준비"),
|
| 903 |
+
]
|
| 904 |
+
|
| 905 |
+
for key, points, label in checks:
|
| 906 |
+
if transfer_results.get(key, False):
|
| 907 |
+
score += points
|
| 908 |
+
details.append(f"{label}: 통과 (+{points})")
|
| 909 |
+
else:
|
| 910 |
+
details.append(f"{label}: 미통과")
|
| 911 |
+
|
| 912 |
+
reasoning = f"교체 확장성: {score}/20. " + "; ".join(details)
|
| 913 |
+
return score, reasoning
|
| 914 |
+
|
| 915 |
+
|
| 916 |
+
# ═══════════════════════════════════════════════════════════════
|
| 917 |
+
# SECTION 5: 통합 채점기
|
| 918 |
+
# ════════════════════════════════════���══════════════════════════
|
| 919 |
+
|
| 920 |
+
def calculate_wm_score(category_scores: Dict[str, int]) -> dict:
|
| 921 |
+
"""
|
| 922 |
+
10개 카테고리 점수 → WM Score + 등급 계산
|
| 923 |
+
|
| 924 |
+
category_scores = {
|
| 925 |
+
"C01": 85, "C02": 75, ..., "C10": 35
|
| 926 |
+
}
|
| 927 |
+
각 카테고리는 5개 시나리오 × 20점 = 100점 만점
|
| 928 |
+
|
| 929 |
+
WM Score = P1(250) + P2(450) + P3(300) = 1000점 만점
|
| 930 |
+
"""
|
| 931 |
+
pillar_mapping = {
|
| 932 |
+
"P1": ["C01", "C02"],
|
| 933 |
+
"P2": ["C03", "C04", "C05", "C06", "C07"],
|
| 934 |
+
"P3": ["C08", "C09", "C10"],
|
| 935 |
+
}
|
| 936 |
+
pillar_weights = {
|
| 937 |
+
"P1": 250, # 2 categories → 200 raw → scale to 250
|
| 938 |
+
"P2": 450, # 5 categories → 500 raw → scale to 450
|
| 939 |
+
"P3": 300, # 3 categories → 300 raw → scale to 300
|
| 940 |
+
}
|
| 941 |
+
|
| 942 |
+
pillar_scores = {}
|
| 943 |
+
for pillar, cats in pillar_mapping.items():
|
| 944 |
+
raw = sum(category_scores.get(c, 0) for c in cats)
|
| 945 |
+
raw_max = len(cats) * 100
|
| 946 |
+
scaled = round(raw / raw_max * pillar_weights[pillar])
|
| 947 |
+
pillar_scores[pillar] = {
|
| 948 |
+
"raw": raw,
|
| 949 |
+
"raw_max": raw_max,
|
| 950 |
+
"scaled": scaled,
|
| 951 |
+
"scaled_max": pillar_weights[pillar],
|
| 952 |
+
}
|
| 953 |
+
|
| 954 |
+
total = sum(p["scaled"] for p in pillar_scores.values())
|
| 955 |
+
|
| 956 |
+
# 등급 판정
|
| 957 |
+
grades = [
|
| 958 |
+
(900, "S", "Superhuman"),
|
| 959 |
+
(750, "A", "Advanced"),
|
| 960 |
+
(600, "B", "Baseline"),
|
| 961 |
+
(400, "C", "Capable"),
|
| 962 |
+
(200, "D", "Developing"),
|
| 963 |
+
(0, "F", "Failing"),
|
| 964 |
+
]
|
| 965 |
+
grade = "F"
|
| 966 |
+
grade_label = "Failing"
|
| 967 |
+
for threshold, g, label in grades:
|
| 968 |
+
if total >= threshold:
|
| 969 |
+
grade = g
|
| 970 |
+
grade_label = label
|
| 971 |
+
break
|
| 972 |
+
|
| 973 |
+
return {
|
| 974 |
+
"wm_score": total,
|
| 975 |
+
"max_score": 1000,
|
| 976 |
+
"grade": grade,
|
| 977 |
+
"grade_label": grade_label,
|
| 978 |
+
"pillar_scores": pillar_scores,
|
| 979 |
+
"category_scores": category_scores,
|
| 980 |
+
}
|
| 981 |
+
|
| 982 |
+
|
| 983 |
+
# ═══════════════════════════════════════════════════════════════
|
| 984 |
+
# SECTION 6: 재현성 검증 — 셀프 테스트
|
| 985 |
+
# ═══════════════════════════════════════════════════════════════
|
| 986 |
+
|
| 987 |
+
def self_test():
|
| 988 |
+
"""채점 함수들의 결정론성 검증"""
|
| 989 |
+
print("=" * 60)
|
| 990 |
+
print(" WM Bench Scoring Self-Test")
|
| 991 |
+
print("=" * 60)
|
| 992 |
+
|
| 993 |
+
# Test C01
|
| 994 |
+
predict = parse_predict_line(
|
| 995 |
+
"PREDICT: left=safe(open), right=danger(wall), fwd=danger(beast), back=safe"
|
| 996 |
+
)
|
| 997 |
+
gt = {"left": "safe", "right": "danger", "fwd": "danger", "back": "safe"}
|
| 998 |
+
s, r = score_c01({}, predict, gt)
|
| 999 |
+
assert s == 20, f"C01 test failed: {s} != 20"
|
| 1000 |
+
print(f" C01: {s}/20 ✓ — {r[:60]}...")
|
| 1001 |
+
|
| 1002 |
+
# Test C03 — predict에서 right=safe여야 MOTION과 일관
|
| 1003 |
+
predict_c03 = parse_predict_line(
|
| 1004 |
+
"PREDICT: left=danger(wall), right=safe(open), fwd=danger(beast), back=safe"
|
| 1005 |
+
)
|
| 1006 |
+
motion = "a person sprinting right to flank the beast"
|
| 1007 |
+
gt = {"danger_directions": ["fwd", "left"], "safe_directions": ["right", "back"], "optimal_direction": "right"}
|
| 1008 |
+
s, r = score_c03({}, predict_c03, motion, gt)
|
| 1009 |
+
assert s == 20, f"C03 test failed: {s} != 20"
|
| 1010 |
+
print(f" C03: {s}/20 ✓ — {r[:60]}...")
|
| 1011 |
+
|
| 1012 |
+
# Test C04
|
| 1013 |
+
motion_a = "a person sprinting away in terror"
|
| 1014 |
+
motion_b = "a person walking away cautiously"
|
| 1015 |
+
gt = {"expected_a_higher": True, "min_intensity_diff": 2}
|
| 1016 |
+
s, r = score_c04(motion_a, motion_b, gt)
|
| 1017 |
+
assert s >= 16, f"C04 test failed: {s} < 16"
|
| 1018 |
+
print(f" C04: {s}/20 ✓ — {r[:60]}...")
|
| 1019 |
+
|
| 1020 |
+
# Test C05
|
| 1021 |
+
seq = [
|
| 1022 |
+
"a person running away",
|
| 1023 |
+
"a person sprinting away in fear",
|
| 1024 |
+
"a person desperately fleeing in terror",
|
| 1025 |
+
]
|
| 1026 |
+
gt = {"expected_trend": "increasing"}
|
| 1027 |
+
s, r = score_c05(seq, gt)
|
| 1028 |
+
assert s >= 15, f"C05 test failed: {s} < 15"
|
| 1029 |
+
print(f" C05: {s}/20 ✓ — {r[:60]}...")
|
| 1030 |
+
|
| 1031 |
+
# Test C08
|
| 1032 |
+
motion = "a person sprinting right in desperate terror"
|
| 1033 |
+
gt = {"expected_min_intensity": 4, "expected_emotion": True, "expected_min_descriptors": 2}
|
| 1034 |
+
s, r = score_c08(motion, gt)
|
| 1035 |
+
assert s >= 16, f"C08 test failed: {s} < 16"
|
| 1036 |
+
print(f" C08: {s}/20 ✓ — {r[:60]}...")
|
| 1037 |
+
|
| 1038 |
+
# Test C09
|
| 1039 |
+
metrics = {"fps": 47.0, "cognitive_latency_ms": 3000, "frame_drop_rate": 0.005, "gpu_memory_stable": True}
|
| 1040 |
+
s, r = score_c09(metrics)
|
| 1041 |
+
assert s == 20, f"C09 test failed: {s} != 20"
|
| 1042 |
+
print(f" C09: {s}/20 ✓ — {r[:60]}...")
|
| 1043 |
+
|
| 1044 |
+
# 통합 점수 테스트
|
| 1045 |
+
cat_scores = {
|
| 1046 |
+
"C01": 65, "C02": 75,
|
| 1047 |
+
"C03": 85, "C04": 90, "C05": 85, "C06": 60, "C07": 70,
|
| 1048 |
+
"C08": 80, "C09": 85, "C10": 35,
|
| 1049 |
+
}
|
| 1050 |
+
result = calculate_wm_score(cat_scores)
|
| 1051 |
+
print(f"\n WM Score: {result['wm_score']}/1000 (Grade {result['grade']})")
|
| 1052 |
+
for p, data in result["pillar_scores"].items():
|
| 1053 |
+
print(f" {p}: {data['scaled']}/{data['scaled_max']} (raw {data['raw']}/{data['raw_max']})")
|
| 1054 |
+
|
| 1055 |
+
print(f"\n All tests passed ✓")
|
| 1056 |
+
print("=" * 60)
|
| 1057 |
+
|
| 1058 |
+
|
| 1059 |
+
if __name__ == "__main__":
|
| 1060 |
+
self_test()
|