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odeGoat24/VideoDPO
|
| 12 |
+
base_model:
|
| 13 |
+
- lmms-lab/llava-onevision-qwen2-0.5b-ov
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## Model Summary
|
| 17 |
+
|
| 18 |
+
`Unified-Reward-0.5b` is the first unified reward model for multimodal understanding and generation assessment, enabling both pairwise ranking and pointwise scoring, which can be employed for vision model preference alignment.
|
| 19 |
+
|
| 20 |
+
For further details, please refer to the following resources:
|
| 21 |
+
- π° Paper: https://arxiv.org/pdf/2503.05236
|
| 22 |
+
- πͺ Project Page: https://codegoat24.github.io/UnifiedReward/
|
| 23 |
+
- π€ Model Collections: https://huggingface.co/collections/CodeGoat24/unifiedreward-models-67c3008148c3a380d15ac63a
|
| 24 |
+
- π€ Dataset Collections: https://huggingface.co/collections/CodeGoat24/unifiedreward-training-data-67c300d4fd5eff00fa7f1ede
|
| 25 |
+
- π Point of Contact: [Yibin Wang](https://codegoat24.github.io)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
## π Compared with Current Reward Models
|
| 29 |
+
|
| 30 |
+
| Reward Model | Method| Image Generation | Image Understanding | Video Generation | Video Understanding
|
| 31 |
+
| :-----: | :-----: |:-----: |:-----: | :-----: | :-----: |
|
| 32 |
+
| [PickScore](https://github.com/yuvalkirstain/PickScore) |Point | β | | ||
|
| 33 |
+
| [HPS](https://github.com/tgxs002/HPSv2) | Point | β | |||
|
| 34 |
+
| [ImageReward](https://github.com/THUDM/ImageReward) | Point| β| |||
|
| 35 |
+
| [LLaVA-Critic](https://huggingface.co/lmms-lab/llava-critic-7b) | Pair/Point | | β |||
|
| 36 |
+
| [IXC-2.5-Reward](https://github.com/InternLM/InternLM-XComposer) | Pair/Point | | β ||β|
|
| 37 |
+
| [VideoScore](https://github.com/TIGER-AI-Lab/VideoScore) | Point | | |β ||
|
| 38 |
+
| [LiFT](https://github.com/CodeGoat24/LiFT) | Point | | |β| |
|
| 39 |
+
| [VisionReward](https://github.com/THUDM/VisionReward) | Point |β | |β||
|
| 40 |
+
| [VideoReward](https://github.com/KwaiVGI/VideoAlign) | Point | | |β ||
|
| 41 |
+
| UnifiedReward (Ours) | Pair/Point | β | β |β|β|
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
### Quick Start
|
| 45 |
+
All pair rank and point score inference codes are provided in our [github](https://github.com/CodeGoat24/UnifiedReward).
|
| 46 |
+
|
| 47 |
+
We take image understanding assessment as example here:
|
| 48 |
+
~~~python
|
| 49 |
+
# pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
|
| 50 |
+
from llava.model.builder import load_pretrained_model
|
| 51 |
+
from llava.mm_utils import get_model_name_from_path, process_images, tokenizer_image_token
|
| 52 |
+
from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN, IGNORE_INDEX
|
| 53 |
+
from llava.conversation import conv_templates, SeparatorStyle
|
| 54 |
+
|
| 55 |
+
from PIL import Image
|
| 56 |
+
import requests
|
| 57 |
+
import copy
|
| 58 |
+
import torch
|
| 59 |
+
|
| 60 |
+
import sys
|
| 61 |
+
import warnings
|
| 62 |
+
import os
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
warnings.filterwarnings("ignore")
|
| 66 |
+
pretrained = "CodeGoat24/UnifiedReward-0.5b"
|
| 67 |
+
model_name = "llava_qwen"
|
| 68 |
+
device = "cuda"
|
| 69 |
+
device_map = "auto"
|
| 70 |
+
tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, device_map=device_map) # Add any other thing you want to pass in llava_model_args
|
| 71 |
+
|
| 72 |
+
model.eval()
|
| 73 |
+
|
| 74 |
+
url = "https://github.com/LLaVA-VL/blog/blob/main/2024-10-03-llava-critic/static/images/critic_img_seven.png?raw=True"
|
| 75 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
| 76 |
+
image_tensor = process_images([image], image_processor, model.config)
|
| 77 |
+
image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]
|
| 78 |
+
|
| 79 |
+
conv_template = "qwen_1_5" # Make sure you use correct chat template for different models
|
| 80 |
+
|
| 81 |
+
# pairwise ranking
|
| 82 |
+
critic_prompt = "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"
|
| 83 |
+
|
| 84 |
+
# pointwise scoring
|
| 85 |
+
# critic_prompt = "Given an image and a corresponding question, please serve as an unbiased and fair judge to evaluate the quality of answer answers provided by a Large Multimodal Model (LMM). Score the response out of 100 and explain your reasoning with specific details. Your task is provided as follows:\nQuestion: [What this image presents?]\nThe LMM response: [This is a handwritten number seven.]\nASSISTANT:\n "
|
| 86 |
+
|
| 87 |
+
question = DEFAULT_IMAGE_TOKEN + "\n" + critic_prompt
|
| 88 |
+
conv = copy.deepcopy(conv_templates[conv_template])
|
| 89 |
+
conv.append_message(conv.roles[0], question)
|
| 90 |
+
conv.append_message(conv.roles[1], None)
|
| 91 |
+
prompt_question = conv.get_prompt()
|
| 92 |
+
|
| 93 |
+
input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
|
| 94 |
+
image_sizes = [image.size]
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
cont = model.generate(
|
| 98 |
+
input_ids,
|
| 99 |
+
images=image_tensor,
|
| 100 |
+
image_sizes=image_sizes,
|
| 101 |
+
do_sample=False,
|
| 102 |
+
temperature=0,
|
| 103 |
+
max_new_tokens=4096,
|
| 104 |
+
)
|
| 105 |
+
text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)
|
| 106 |
+
print(text_outputs[0])
|
| 107 |
+
~~~
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
## Citation
|
| 111 |
+
|
| 112 |
+
```
|
| 113 |
+
@article{UnifiedReward,
|
| 114 |
+
title={Unified Reward Model for Multimodal Understanding and Generation.},
|
| 115 |
+
author={Wang, Yibin and Zang, Yuhang, and Li, Hao and Jin, Cheng and Wang Jiaqi},
|
| 116 |
+
journal={arXiv preprint arXiv:2503.05236},
|
| 117 |
+
year={2025}
|
| 118 |
+
}
|
| 119 |
+
```
|