| """Modality registry -- each task type maps to a verifier and a rubric hint. |
| |
| This is how Handicate improves across ALL the modalities, not just text: every task |
| is tagged with a type, and the reward routes to that type's objective verifier (where |
| one exists) blended with the judge's rubric score. |
| |
| - python / bash / 3d / svg -> objective execution/parse verifier (strong RL signal) |
| - image_prompt / audio_prompt / video_spec -> judge-only (the model learns to write good |
| generation specs; the actual pixels/audio/video come from the dedicated generators |
| -- ImageForge, Michiro, etc. -- which Handicate orchestrates) |
| """ |
| from core import verifiers |
|
|
| VERIFIERS = { |
| "python": verifiers.verify_python, |
| "bash": verifiers.verify_bash, |
| "3d": verifiers.verify_3d, |
| "svg": verifiers.verify_svg, |
| "image_prompt": None, |
| "audio_prompt": None, |
| "video_spec": None, |
| } |
|
|
| RUBRIC_HINTS = { |
| "python": "Return runnable Python in a ```python block; handle edge cases.", |
| "bash": "Return a correct POSIX bash command/script in a ```bash block.", |
| "3d": "Return Python using trimesh/numpy that builds a variable `mesh` (a valid trimesh).", |
| "svg": "Return a complete <svg>...</svg> with real shapes; must parse.", |
| "image_prompt": "Return a vivid, specific text-to-image prompt (subject, style, lighting, detail).", |
| "audio_prompt": "Return a precise music/audio generation prompt (genre, mood, instruments, bpm).", |
| "video_spec": "Return a concrete shot-by-shot video spec (scenes, motion, duration).", |
| } |
|
|
| |
| VERIFIER_WEIGHT = 0.6 |
|
|
|
|
| def verifier_for(task_type): |
| return VERIFIERS.get(task_type) |
|
|
|
|
| def blended_reward(task_type, judge_score, response_text): |
| """Objective verifier (if any) blended with the LLM judge's rubric score.""" |
| vfn = VERIFIERS.get(task_type) |
| if vfn is None: |
| return judge_score |
| try: |
| v = vfn(response_text) |
| except Exception: |
| v = 0.0 |
| return VERIFIER_WEIGHT * v + (1 - VERIFIER_WEIGHT) * judge_score |
|
|