We are actively gathering feedback from the community to improve our models. We welcome your input and encourage you to stay updated through our repository!!
Model Summary
UnifiedReward-qwen-7b is the first unified reward model based on Qwen/Qwen2.5-VL-7B-Instruct for multimodal understanding and generation assessment, enabling both pairwise ranking and pointwise scoring, which can be employed for vision model preference alignment.
For further details, please refer to the following resources:
All pair rank and point score inference codes are provided in our github.
We take image understanding assessment as example here:
python
1import json
2import random
3import torch
4import tqdm
5from PIL import Image
6import warnings
7import os
8from transformers import AutoProcessor, AutoTokenizer, Qwen2_5_VLForConditionalGeneration
9from qwen_vl_utils import process_vision_info
1011warnings.filterwarnings("ignore")1213model_path ="CodeGoat24/UnifiedReward-qwen-7b"14model = Qwen2_5_VLForConditionalGeneration.from_pretrained(15 model_path, torch_dtype="auto", device_map="auto"16)17processor = AutoProcessor.from_pretrained(model_path)181920url ="https://github.com/LLaVA-VL/blog/blob/main/2024-10-03-llava-critic/static/images/critic_img_seven.png?raw=True"21image = Image.open(requests.get(url, stream=True).raw)2223prompt_text =f'Given an image and a corresponding question, please serve as an unbiased and fair judge to evaluate the quality of the answers provided by a Large Multimodal Model (LMM). Determine which answer is better and explain your reasoning with specific details. Your task is provided as follows:\nQuestion: [What this image presents?]\nThe first response: [The image is a black and white sketch of a line that appears to be in the shape of a cross. The line is a simple and straightforward representation of the cross shape, with two straight lines intersecting at a point.]\nThe second response: [This is a handwritten number seven.]\nASSISTANT:\n'2425messages =[26{27"role":"user",28"content":[29{"type":"image","image": image},30{"type":"text","text": prompt_text},31],32}33]3435chat_input = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)36image_inputs, video_inputs = process_vision_info(messages)3738inputs = processor(39 text=[chat_input],40 images=image_inputs,41 videos=video_inputs,42 return_tensors="pt",43 padding=True44).to("cuda")4546with torch.no_grad():47 generated_ids = model.generate(**inputs, max_new_tokens=4096)48generated_trimmed =[49 out_ids[len(in_ids):]for in_ids, out_ids inzip(inputs.input_ids, generated_ids)50]51output = processor.batch_decode(generated_trimmed, skip_special_tokens=True)[0]525354print(output)
Citation
@article{unifiedreward,
title={Unified reward model for multimodal understanding and generation},
author={Wang, Yibin and Zang, Yuhang and Li, Hao and Jin, Cheng and Wang, Jiaqi},
journal={arXiv preprint arXiv:2503.05236},
year={2025}
}