LeRobot documentation

TOPReward

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.6.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

TOPReward

TOPReward는 zero-shot reward model로, 시판 중인 vision-language model(VLM)에서 토큰 log-probability를 추출하여 로봇 보상 신호로 활용합니다. 비디오 궤적과 작업 지시문이 주어지면, 해당 지시문이 참이라는 VLM의 log-likelihood를 반환하며, fine-tuning이 필요하지 않습니다.

논문: TOPReward: Token Probabilities as Hidden Zero-Shot Rewards for Robotics 프로젝트: topreward.github.io 원본 코드: github.com/TOPReward/TOPReward 기본 백본: Qwen/Qwen3-VL-8B-Instruct

개요

TOPReward은 로봇이 해당 작업을 수행하는 비디오를 조건으로, 일반적인 VLM에 작업 지시문이 얼마나 그럴듯한지 묻습니다. 구체적으로, 다음이 주어졌을 때:

  • 트래젝터리 비디오(프레임의 시퀀스).
  • 작업 지침(예: “open the drawer”).

다음 형태의 채팅 프롬프트를 구성합니다

<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는 zero-shot입니다. 호스팅할 fine-tuned 가중치가 없습니다. LeRobot의 “model”은 transformers의 Qwen3VLForConditionalGeneration를 감싸는 작은 wrapper와 label-masking 로직으로 구성됩니다. processor가 tokeniser를 소유하며 전체 chat prompt를 구성합니다(EO-1/Robometer 패턴).

LeRobot 통합이 다루는 범위

  • LeRobot를 통해 표준 reward_model.type=topreward 구성을 수행합니다.
  • transformers의 Qwen3VLForConditionalGeneration API를 통한 VLM 로딩.
  • 프로세서에서 프롬프트 조립 + 토큰화(업스트림 QwenClient.compute_instruction_reward와 일치).
  • compute_reward()는 샘플당 스칼라 로그 확률 1개를 반환합니다.
  • LeRobot 보상 모델 저장/로드 — save_pretrained는 config.json만 작성합니다(VLM은 vlm_name으로 식별됩니다).
  • RA-BC 및 오버레이를 위해 topreward_progress.parquet(SARM 호환 스키마)을 작성하는 오프라인 라벨링 스크립트입니다.

현재 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 데이터셋에서 preprocessor는 다음을 읽습니다:

Config 필드기본값의미
reward_model.image_keyobservation.images.topTOPReward에서 사용하는 카메라 관찰
reward_model.task_keytasktask 문자열에 보완 데이터를 입력합니다
reward_model.max_frames16샘플당 프레임 수 제한
reward_model.fps2.0Qwen 비디오 프로세서에 전달되는 메타데이터
reward_model.vlm_nameQwen/Qwen3-VL-8B-Instruct기저 VLM의 Hugging Face Hub id

모델은 다음을 반환합니다:

  • compute_reward(batch): 샘플당 하나의 로그 확률(log-probability)을 반환합니다. 값이 높을수록 태스크-비디오 정렬이 좋습니다. 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)

Preprocessor는 전체 프롬프트(비디오 + 접두사 + 지시어 접미사)를 토큰화하고, Qwen-VL 텐서와 prompt_length를 observation.topreward.* 아래에 기록합니다. 모델은 해당 텐서를 읽고 prompt_length를 기반으로 라벨 마스크를 적용한 뒤, log-prob 보상을 추출합니다.

오프라인 데이터셋 라벨링

RA-BC 학습 및 오버레이 비디오를 위해 topreward_progress.parquet를 작성합니다:

# Sparse-dense (15 anchors per episode, matches upstream)
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에 노출되어 있으며, ablation을 위해 사용할 수 있습니다. 접미사 템플릿은 반드시 {instruction}를 포함해야 합니다.

채팅 템플릿

add_chat_template=True는 토큰화 전에 전체 프롬프트(지시문 포함)를 토크나이저의 채팅 템플릿으로 감싸줍니다. 기본값은 False이며, 이는 업스트림 논문에서 수행한 주요 실험 설정과 일치합니다.

한계

  • 현재 LeRobot 포트는 추론 전용이며 제로샷입니다. forward()는 오버라이드되지 않았고 is_trainable은 False를 반환합니다.
  • Qwen3-VL family만 지원되며, 기타 upstream 클라이언트는 지원 범위에 포함되지 않습니다.
  • 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 라이선스의 적용을 받습니다.

Update on GitHub