跳转至

TOPReward

TOPReward 是一个零样本奖励模型,它从现成的视觉-语言模型(VLM)中提取令牌的对数概率,作为机器人奖励信号。给定一段视频轨迹和任务指令后,它返回 VLM 对该指令为真的对数似然值——无需任何微调。

论文: TOPReward: Token Probabilities as Hidden Zero-Shot Rewards for Robotics 项目主页: topreward.github.io 原始代码: github.com/TOPReward/TOPReward 默认骨干网络: Qwen/Qwen3-VL-8B-Instruct

概述

TOPReward 询问通用 VLM 一条任务指令的可能性,以机器人尝试完成该任务的视频为条件。具体而言,给定:

  • 轨迹视频(帧序列)。
  • 任务指令(例如 "打开抽屉")。

系统构建如下形式的聊天提示:

<video>
"The above video shows a robot manipulation trajectory that completes the
 following task: <instruction> Decide whether the above statement is True
 or not. The answer is: True"

将其送入 VLM,对除最后一个令牌以外的所有位置进行标签遮蔽,然后读取该令牌的对数概率——默认为后缀模板末尾的字面量 "True"。所得的 log P("True" | video + prompt + instruction) 即为奖励值。

由于该方法仅依赖冻结的 VLM,TOPReward 是零样本的:无需托管任何微调权重。LeRobot 中的"模型"是对 transformers 库中 Qwen3VLForConditionalGeneration 以及标签遮蔽逻辑的轻量封装,预处理器负责分词并构建完整的聊天提示(与 EO-1/Robometer 模式一致)。

LeRobot 集成功能范围

  • 通过 LeRobot 标准配置项 reward_model.type=topreward 使用 TOPReward。
  • 通过 transformersQwen3VLForConditionalGeneration API 加载 VLM。
  • 在预处理器中完成提示拼接与分词(与上游的 QwenClient.compute_instruction_reward 逻辑保持一致)。
  • compute_reward() 为每个样本返回一个标量对数概率。
  • LeRobot 奖励模型的保存/加载——save_pretrained 仅写入 config.json(VLM 通过 vlm_name 标识)。
  • 提供离线标注脚本,写出符合 SARM 兼容格式的 topreward_progress.parquet 文件,供 RA-BC 训练和叠加可视化使用。

当前 LeRobot 移植版本仅支持 Qwen3-VL 客户端。其他上游客户端(Gemini、OpenAI、Gemma、Molmo)可作为后续扩展项添加。

安装要求

  1. 按照安装指南安装 LeRobot。
  2. 安装 TOPReward 可选扩展:
pip install -e ".[topreward]"

或从源码目录使用 uv

uv sync --extra topreward

此操作会安装 transformers。首次运行 TOPReward 时,Hugging Face 还会从 Hub 下载 VLM 权重(Qwen3-VL-8B-Instruct 约 16 GB)。强烈建议使用 GPU。

模型输入与输出

TOPReward 的输入要求:

  • 轨迹视频或帧序列。
  • 自然语言任务描述。

在 LeRobot 数据集中,预处理器读取以下配置字段:

配置字段 默认值 含义
reward_model.image_key observation.images.top TOPReward 使用的相机观测
reward_model.task_key task 互补数据中存储任务字符串的键名
reward_model.max_frames 16 每个样本的最大帧数上限
reward_model.fps 2.0 传入 Qwen 视频处理器的元数据
reward_model.vlm_name Qwen/Qwen3-VL-8B-Instruct 底层 VLM 在 Hugging Face Hub 上的 ID

模型返回:

  • compute_reward(batch):每个样本一个对数概率。值越高,表示任务-视频对齐程度越好。当 success_threshold 为有限值时,返回二值化的阈值结果。

使用方法

直接加载奖励模型

from lerobot.rewards.topreward import TOPRewardConfig, TOPRewardModel

cfg = TOPRewardConfig(
    vlm_name="Qwen/Qwen3-VL-8B-Instruct",
    device="cuda",
)
reward_model = TOPRewardModel(cfg)

使用奖励工厂

from lerobot.rewards import make_reward_model, make_reward_model_config, make_reward_pre_post_processors

cfg = make_reward_model_config(
    "topreward",
    vlm_name="Qwen/Qwen3-VL-8B-Instruct",
    device="cuda",
    image_key="observation.images.top",
)
reward_model = make_reward_model(cfg)
preprocessor, postprocessor = make_reward_pre_post_processors(cfg)

预处理器对完整提示(视频 + 前缀 + 指令后缀)进行分词,将 Qwen-VL 张量和 prompt_length 写入 observation.topreward.* 命名空间。模型读取这些张量,根据 prompt_length 进行标签遮蔽,并提取对数概率奖励值。

离线数据集标注

为 RA-BC 训练和叠加视频写出 topreward_progress.parquet

# 稀疏-密集模式(每个片段 15 个锚点,与上游保持一致)
uv run python -m lerobot.rewards.topreward.compute_rabc_weights \
    --dataset-repo-id lerobot/libero_10_image \
    --num-samples 15 \
    --device cuda

然后为任意片段渲染进度叠加视频:

uv run examples/dataset/create_progress_videos.py \
    --repo-id lerobot/libero_10_image \
    --episode 0 \
    --progress-file topreward_progress.parquet \
    --gif

配置说明

提示词参数

默认提示词与论文上游保持一致:

prompt_prefix = "The above video shows a robot manipulation trajectory that completes the following task: "
prompt_suffix_template = "{instruction} Decide whether the above statement is True or not. The answer is: True"

这两个参数均在 TOPRewardConfig 中暴露,可用于消融实验。后缀模板必须包含 {instruction}

聊天模板

add_chat_template=True 会在分词前用分词器的聊天模板包裹完整提示(含指令)。默认值为 False,与上游论文主要实验设置保持一致。

局限性

  • 当前 LeRobot 移植版本仅支持推理,且为零样本forward() 未被覆盖,is_trainable 返回 False
  • 仅支持 Qwen3-VL 系列;其他上游客户端不在支持范围内。
  • TOPReward 会继承底层 VLM 的偏差。

参考资料

引用

@article{chen2026topreward,
  title={TOPReward: Token Probabilities as Hidden Zero-Shot Rewards for Robotics},
  author={Chen, Shirui and Harrison, Cole and Lee, Ying-Chun and Yang, Angela Jin and
          Ren, Zhongzheng and Ratliff, Lillian J and Duan, Jiafei and Fox, Dieter and
          Krishna, Ranjay},
  journal={arXiv preprint arXiv:2602.19313},
  year={2026}
}

许可证

TOPReward 原始代码库采用 MIT 许可证。LeRobot 移植版本遵循 LeRobot 的 Apache 2.0 许可证;封装的 Qwen3-VL 权重受原始 Qwen 许可证约束。