Views
No views yet
<think>...</think> block, then a scalar reward
in [0.000, 1.000] estimating task progress at the current (last) frame.densereward-1frame: single-frame reward model — given one RGB frame + task text, outputs a scalar reward in [0.000, 1.000].densereward-3frame-thinking: 3-frame reward model with reasoning — given 3 chronological frames + task text, emits a <think> reasoning word then a scalar reward. Warm-started from the 1-frame checkpoint.<think>WORD</think> block followed by one float with three
decimals, e.g. <think>\ncorrect\n</think>\n\n0.374.system_prompt.txt in this
directory). It instructs:<think>...</think>, from this
vocabulary:
correct — progress on track (reward increasing/holding)miss — gripper missed the grasp and reward just droppedcollision — an unintended collision just dropped the rewardfall — the held object fell and reward just droppedsmooth — motion stalled / non-smooth behaviour dropped the rewardfailure — an unclassified failure event just dropped the reward[0.000, 1.000] (three decimals).</think>):1<think>
2correct
3</think>
4
50.374The user turn must contain the 3 images followed by the task text, in the same format used during training (<image><image><image>{task}).
transformers>=4.57, qwen_vl_utils>=0.0.14, torch, accelerate.Tested environment: Python 3.12, CUDA 12.8,torch==2.8.0+cu128,torchvision==0.23.0+cu128,transformers==5.2.0,accelerate==1.13.0,qwen-vl-utils==0.0.14.bash1conda create -n densereward python=3.12 -y 2conda activate densereward 3pip install torch==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu128 4pip install "transformers==5.2.0" "accelerate==1.13.0" "qwen-vl-utils==0.0.14" pillow numpy
1import re
2import torch
3from transformers import AutoModelForImageTextToText, AutoProcessor
4from qwen_vl_utils import process_vision_info
5
6MODEL_DIR = "densereward/densereward-3frame-thinking" # or a local path to this checkpoint
7
8# The exact thinking system prompt used in training ships with the model:
9SYSTEM_PROMPT = open(f"{MODEL_DIR}/system_prompt.txt").read().strip()
10
11model = AutoModelForImageTextToText.from_pretrained(
12 MODEL_DIR, torch_dtype=torch.bfloat16, device_map="auto"
13)
14processor = AutoProcessor.from_pretrained(MODEL_DIR)
15
16# 3 chronological frames: oldest -> current
17frames = [
18 "file:///path/to/frame_t-2.png",
19 "file:///path/to/frame_t-1.png",
20 "file:///path/to/frame_t.png",
21]
22messages = [
23 {"role": "system", "content": SYSTEM_PROMPT},
24 {
25 "role": "user",
26 "content": [
27 {"type": "image", "image": frames[0]},
28 {"type": "image", "image": frames[1]},
29 {"type": "image", "image": frames[2]},
30 {"type": "text", "text": "put the black bowl on the plate"},
31 ],
32 },
33]
34
35text = processor.apply_chat_template(
36 messages, tokenize=False, add_generation_prompt=True
37)
38image_inputs, video_inputs = process_vision_info(messages)
39inputs = processor(
40 text=[text],
41 images=image_inputs,
42 videos=video_inputs,
43 padding=True,
44 return_tensors="pt",
45).to(model.device)
46
47with torch.no_grad():
48 out = model.generate(**inputs, max_new_tokens=32, do_sample=False) # greedy
49
50gen = out[:, inputs.input_ids.shape[1]:]
51raw = processor.batch_decode(gen, skip_special_tokens=True)[0].strip()
52print(raw)
53
54word = re.search(r"<think>\s*(\w+)\s*</think>", raw)
55reward = re.search(r"</think>\s*([01](?:\.\d+)?)", raw)
56print("reason:", word.group(1) if word else None,
57 "| reward:", float(reward.group(1)) if reward else None)max_new_tokens>=32: the output includes the <think> block and the
reward.[0, 1] and handle malformed output.<think>WORD</think> block is part of the trained assistant output,
driven by the system prompt and thinking-labelled training data — it is not
ms-swift's native --enable_thinking mode (enable_thinking was false for this
run). At inference you only need the bundled system prompt; the model produces the
<think>...</think> block itself.args.json ({model_type: qwen3_vl, swift_version})
so ms-swift's PtEngine / TransformersEngine can auto-detect the model type for
this local directory. Load it as the base model with no adapter; pass the
bundled system prompt and a 3-image user turn.Compatibility note: ms-swift 4.2.x targetstransformers>=4.57,<5. Under a much newer transformers (e.g. 5.x) the swift template/prompt composition can misbehave even though weights load fine — prefer thetransformerspath above, or a swift-matched transformers version, for swift-based inference.
LICENSE). The base model
Qwen/Qwen3-VL-4B-Instruct
is also Apache-2.0. This fine-tune was produced at the University of North
Carolina at Chapel Hill.1@article{fang2026densereward,
2 title={DenseReward: Dense Reward Learning via Failure Synthesis for Robotic Manipulation},
3 author={Fang, Yu and Dong, Wanxi and Liu, Jiaqi and Yang, Yue and Huo, Mingxiao and Mu, Yao and Yao, Huaxiu and Li, Li Erran and Szafir, Daniel and Ding, Mingyu},
4 journal={arXiv preprint arXiv:2607.13033},
5 year={2026}
6}