CodeGoat24 commited on
Commit
af20ddd
Β·
verified Β·
1 Parent(s): 6ce121f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +122 -3
README.md CHANGED
@@ -1,3 +1,122 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - CodeGoat24/HPD
5
+ - CodeGoat24/LiFT-HRA
6
+ - CodeGoat24/OIP
7
+ - CodeGoat24/EvalMuse
8
+ - CodeGoat24/ShareGPTVideo-DPO
9
+ - CodeGoat24/VideoFeedback
10
+ - CodeGoat24/LLaVA-Critic-113k
11
+ - CodeGoat24/VideoDPO
12
+ base_model:
13
+ - lmms-lab/llava-onevision-qwen2-7b-ov
14
+ ---
15
+
16
+
17
+ # Unified-Reward-7B-v1.5
18
+
19
+ ## Model Summary
20
+
21
+ `Unified-Reward-7b-v1.5` is the enhanced version of [Unified-Reward-7b](https://huggingface.co/CodeGoat24/UnifiedReward-7b/blob/main/README.md) which 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.
22
+
23
+ For further details, please refer to the following resources:
24
+ - πŸ“° Paper: https://arxiv.org/pdf/2503.05236
25
+ - πŸͺ Project Page: https://codegoat24.github.io/UnifiedReward/
26
+ - πŸ€— Model Collections: https://huggingface.co/collections/CodeGoat24/unifiedreward-models-67c3008148c3a380d15ac63a
27
+ - πŸ€— Dataset Collections: https://huggingface.co/collections/CodeGoat24/unifiedreward-training-data-67c300d4fd5eff00fa7f1ede
28
+ - πŸ‘‹ Point of Contact: [Yibin Wang](https://codegoat24.github.io)
29
+
30
+
31
+ ## 🏁 Compared with Current Reward Models
32
+
33
+ | Reward Model | Method| Image Generation | Image Understanding | Video Generation | Video Understanding
34
+ | :-----: | :-----: |:-----: |:-----: | :-----: | :-----: |
35
+ | [PickScore](https://github.com/yuvalkirstain/PickScore) |Point | √ | | ||
36
+ | [HPS](https://github.com/tgxs002/HPSv2) | Point | √ | |||
37
+ | [ImageReward](https://github.com/THUDM/ImageReward) | Point| √| |||
38
+ | [LLaVA-Critic](https://huggingface.co/lmms-lab/llava-critic-7b) | Pair/Point | | √ |||
39
+ | [IXC-2.5-Reward](https://github.com/InternLM/InternLM-XComposer) | Pair/Point | | √ ||√|
40
+ | [VideoScore](https://github.com/TIGER-AI-Lab/VideoScore) | Point | | |√ ||
41
+ | [LiFT](https://github.com/CodeGoat24/LiFT) | Point | | |√| |
42
+ | [VisionReward](https://github.com/THUDM/VisionReward) | Point |√ | |√||
43
+ | [VideoReward](https://github.com/KwaiVGI/VideoAlign) | Point | | |√ ||
44
+ | UnifiedReward (Ours) | Pair/Point | √ | √ |√|√|
45
+
46
+
47
+ ### Quick Start
48
+ All pair rank and point score inference codes are provided in our [github](https://github.com/CodeGoat24/UnifiedReward).
49
+
50
+ We take image understanding assessment as example here:
51
+ ~~~python
52
+ # pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
53
+ from llava.model.builder import load_pretrained_model
54
+ from llava.mm_utils import get_model_name_from_path, process_images, tokenizer_image_token
55
+ from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN, IGNORE_INDEX
56
+ from llava.conversation import conv_templates, SeparatorStyle
57
+
58
+ from PIL import Image
59
+ import requests
60
+ import copy
61
+ import torch
62
+
63
+ import sys
64
+ import warnings
65
+ import os
66
+
67
+
68
+ warnings.filterwarnings("ignore")
69
+ pretrained = "CodeGoat24/UnifiedReward-7b-v1.5"
70
+ model_name = "llava_qwen"
71
+ device = "cuda"
72
+ device_map = "auto"
73
+ 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
74
+
75
+ model.eval()
76
+
77
+ url = "https://github.com/LLaVA-VL/blog/blob/main/2024-10-03-llava-critic/static/images/critic_img_seven.png?raw=True"
78
+ image = Image.open(requests.get(url, stream=True).raw)
79
+ image_tensor = process_images([image], image_processor, model.config)
80
+ image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]
81
+
82
+ conv_template = "qwen_1_5" # Make sure you use correct chat template for different models
83
+
84
+ # pairwise ranking
85
+ 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"
86
+
87
+ # pointwise scoring
88
+ # 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 "
89
+
90
+ question = DEFAULT_IMAGE_TOKEN + "\n" + critic_prompt
91
+ conv = copy.deepcopy(conv_templates[conv_template])
92
+ conv.append_message(conv.roles[0], question)
93
+ conv.append_message(conv.roles[1], None)
94
+ prompt_question = conv.get_prompt()
95
+
96
+ input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
97
+ image_sizes = [image.size]
98
+
99
+
100
+ cont = model.generate(
101
+ input_ids,
102
+ images=image_tensor,
103
+ image_sizes=image_sizes,
104
+ do_sample=False,
105
+ temperature=0,
106
+ max_new_tokens=4096,
107
+ )
108
+ text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)
109
+ print(text_outputs[0])
110
+ ~~~
111
+
112
+
113
+ ## Citation
114
+
115
+ ```
116
+ @article{UnifiedReward,
117
+ title={Unified Reward Model for Multimodal Understanding and Generation.},
118
+ author={Wang, Yibin and Zang, Yuhang, and Li, Hao and Jin, Cheng and Wang Jiaqi},
119
+ journal={arXiv preprint arXiv:2503.05236},
120
+ year={2025}
121
+ }
122
+ ```