Agent Skillsvllm-project/vime › add-reward-function

add-reward-function

GitHub

指导在vime中实现自定义奖励函数并配置,支持单样本或批量模式。涵盖创建模块、保持类型一致、可选后处理及参数连接,解决新逻辑开发、外部服务集成及任务特定奖励塑造需求。

.claude/skills/add-reward-function/SKILL.md vllm-project/vime

Trigger Scenarios

用户要求添加新的奖励计算逻辑 用户要求集成外部奖励服务 用户要求自定义奖励归一化或后处理

Install

npx skills add vllm-project/vime --skill add-reward-function -g -y
More Options

Non-standard path

npx skills add https://github.com/vllm-project/vime/tree/main/.claude/skills/add-reward-function -g -y

Use without installing

npx skills use vllm-project/vime@add-reward-function

指定 Agent (Claude Code)

npx skills add vllm-project/vime --skill add-reward-function -a claude-code -g -y

安装 repo 全部 skill

npx skills add vllm-project/vime --all -g -y

预览 repo 内 skill

npx skills add vllm-project/vime --list

SKILL.md

Frontmatter
{
    "name": "add-reward-function",
    "description": "Guide for adding a custom reward function in vime and wiring it through --custom-rm-path (and optional reward post-processing). Use when user wants new reward logic, remote\/service reward integration, or task-specific reward shaping."
}

Add Reward Function

Implement custom reward logic and connect it to vime rollout/training safely.

When to Use

Use this skill when:

  • User asks to add new reward computation logic
  • User asks to integrate an external reward service
  • User asks to customize reward normalization/post-processing

Step-by-Step Guide

Step 1: Choose Reward Mode

Pick one of these:

  • Single-sample mode (--group-rm disabled): custom function gets one Sample
  • Group/batch mode (--group-rm enabled): custom function gets list[Sample]

vime.rollout.rm_hub.__init__.py calls your function via --custom-rm-path.

Step 2: Create Reward Module

Create vime/rollout/rm_hub/<your_rm>.py.

Supported signatures:

async def custom_rm(args, sample):
    return float_reward_or_reward_dict
async def custom_rm(args, samples):
    return list_of_rewards

If using group mode, return one reward per sample in input order.

Step 3: Keep Reward Type Consistent

  • Return scalar numeric rewards unless your pipeline explicitly uses keyed rewards.
  • If using reward dicts, ensure downstream reward_key / eval_reward_key is configured.
  • Keep exceptions explicit for invalid metadata instead of silently returning zeros.

Step 4: Optional Reward Post-Processing

To customize normalization/shaping before advantage computation, add:

def post_process_rewards(args, samples):
    # return (raw_rewards, processed_rewards)
    ...

Wire with:

--custom-reward-post-process-path <module>.post_process_rewards

This hook is consumed in vime/ray/rollout.py.

Step 5: Wire and Validate

Use:

--custom-rm-path vime.rollout.rm_hub.<your_rm>.custom_rm

Common Mistakes

  • Returning wrong output shape in group mode
  • Mixing scalar rewards and reward dicts without reward_key config
  • Doing blocking network calls without async handling
  • Forgetting to validate reward behavior on truncated/failed samples

Reference Locations

  • Reward dispatch: vime/rollout/rm_hub/__init__.py
  • Reward post-process hook: vime/ray/rollout.py
  • Customization docs: docs/en/get_started/customization.md

Version History

  • 8d1f4cc Current 2026-07-05 14:58

Same Skill Collection

.claude/skills/add-dynamic-filter/SKILL.md
.claude/skills/add-eval-dataset-config/SKILL.md
.claude/skills/add-rollout-function/SKILL.md
.claude/skills/add-tests-and-ci/SKILL.md
.claude/skills/vime-code-review-preferences/SKILL.md

Metadata

Files
0
Version
8d1f4cc
Hash
0bc7621c
Indexed
2026-07-05 14:58

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-08 18:54
浙ICP备14020137号-1 $Carte des visiteurs$