jongwooko commited on
Commit
d32075e
·
verified ·
1 Parent(s): e99c3a9

Update README.md

Browse files

Add an extended description

Files changed (1) hide show
  1. README.md +184 -166
README.md CHANGED
@@ -1,198 +1,216 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
4
  ---
5
 
6
  # Model Card for Model ID
7
 
8
  <!-- Provide a quick summary of what the model is/does. -->
9
 
10
- [Flex-Judge](https://arxiv.org/abs/2505.18601)
 
11
 
12
-
13
- ## Model Details
14
 
15
  ### Model Description
16
 
17
- <!-- Provide a longer summary of what this model is. -->
18
-
19
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
20
-
21
- - **Developed by:** [More Information Needed]
22
- - **Funded by [optional]:** [More Information Needed]
23
- - **Shared by [optional]:** [More Information Needed]
24
- - **Model type:** [More Information Needed]
25
- - **Language(s) (NLP):** [More Information Needed]
26
- - **License:** [More Information Needed]
27
- - **Finetuned from model [optional]:** [More Information Needed]
28
 
29
- ### Model Sources [optional]
30
 
31
  <!-- Provide the basic links for the model. -->
32
-
33
- - **Repository:** [More Information Needed]
34
- - **Paper [optional]:** [More Information Needed]
35
- - **Demo [optional]:** [More Information Needed]
36
 
37
  ## Uses
38
 
39
  <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
40
 
41
- ### Direct Use
42
 
43
  <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
44
 
45
- [More Information Needed]
 
 
 
 
 
46
 
47
- ### Downstream Use [optional]
48
 
49
  <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
50
 
51
- [More Information Needed]
52
-
53
- ### Out-of-Scope Use
54
-
55
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
56
-
57
- [More Information Needed]
58
-
59
- ## Bias, Risks, and Limitations
60
-
61
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
62
-
63
- [More Information Needed]
64
-
65
- ### Recommendations
66
-
67
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
68
-
69
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
70
-
71
- ## How to Get Started with the Model
72
-
73
- Use the code below to get started with the model.
74
-
75
- [More Information Needed]
76
-
77
- ## Training Details
78
-
79
- ### Training Data
80
-
81
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
82
-
83
- [More Information Needed]
84
-
85
- ### Training Procedure
86
-
87
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
88
-
89
- #### Preprocessing [optional]
90
-
91
- [More Information Needed]
92
-
93
-
94
- #### Training Hyperparameters
95
-
96
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
97
-
98
- #### Speeds, Sizes, Times [optional]
99
-
100
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
101
-
102
- [More Information Needed]
103
-
104
- ## Evaluation
105
-
106
- <!-- This section describes the evaluation protocols and provides the results. -->
107
-
108
- ### Testing Data, Factors & Metrics
109
-
110
- #### Testing Data
111
-
112
- <!-- This should link to a Dataset Card if possible. -->
113
-
114
- [More Information Needed]
115
-
116
- #### Factors
117
-
118
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
119
-
120
- [More Information Needed]
121
-
122
- #### Metrics
123
-
124
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
125
-
126
- [More Information Needed]
127
-
128
- ### Results
129
-
130
- [More Information Needed]
131
-
132
- #### Summary
133
-
134
-
135
-
136
- ## Model Examination [optional]
137
-
138
- <!-- Relevant interpretability work for the model goes here -->
139
-
140
- [More Information Needed]
141
-
142
- ## Environmental Impact
143
-
144
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
145
-
146
- - **Hardware Type:** [More Information Needed]
147
- - **Hours used:** [More Information Needed]
148
- - **Cloud Provider:** [More Information Needed]
149
- - **Compute Region:** [More Information Needed]
150
- - **Carbon Emitted:** [More Information Needed]
151
-
152
- ## Technical Specifications [optional]
153
-
154
- ### Model Architecture and Objective
155
-
156
- [More Information Needed]
157
-
158
- ### Compute Infrastructure
159
-
160
- [More Information Needed]
161
-
162
- #### Hardware
163
-
164
- [More Information Needed]
165
-
166
- #### Software
167
-
168
- [More Information Needed]
169
-
170
- ## Citation [optional]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
173
 
174
  **BibTeX:**
175
 
176
- [More Information Needed]
177
-
178
- **APA:**
179
-
180
- [More Information Needed]
181
-
182
- ## Glossary [optional]
183
-
184
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
185
-
186
- [More Information Needed]
187
-
188
- ## More Information [optional]
189
-
190
- [More Information Needed]
191
-
192
- ## Model Card Authors [optional]
193
-
194
- [More Information Needed]
195
-
196
- ## Model Card Contact
197
-
198
- [More Information Needed]
 
1
  ---
2
  library_name: transformers
3
+ base_model:
4
+ - Qwen/Qwen2.5-VL-7B-Instruct
5
  ---
6
 
7
  # Model Card for Model ID
8
 
9
  <!-- Provide a quick summary of what the model is/does. -->
10
 
11
+ [Flex-Judge: Text-Only Reasoning Unleashes Zero-Shot Multimodal Evaluators
12
+ ](https://arxiv.org/abs/2505.18601)
13
 
14
+ **Flex-VL-7B** is a vision-language model developed as part of the Flex-Judge framework, designed to perform robust evaluation of multimodal content using primarily text-only reasoning. Despite being trained with minimal supervision, it generalizes effectively to complex image- and video-based evaluation tasks, enabling consistent and interpretable judgments across diverse multimodal inputs.
 
15
 
16
  ### Model Description
17
 
18
+ - We propose **Flex-Judge**, a reasoning-guided multimodal evaluator that leverages minimal textual reasoning data to robustly generalize across multiple modalities and evaluation formats.
19
+ - Our framework highlights reasoning-based text supervision as a powerful, cost-effective alternative to traditional annotation-intensive approaches, substantially advancing scalable, multimodal model-as-a-judge.
 
 
 
 
 
 
 
 
 
20
 
21
+ ### Model Sources
22
 
23
  <!-- Provide the basic links for the model. -->
24
+ - **Repository:** https://github.com/jongwooko/flex-judge
25
+ - **Paper:** [Flex-Judge: Text-Only Reasoning Unleashes Zero-Shot Multimodal Evaluators
26
+ ](https://arxiv.org/abs/2505.18601)
 
27
 
28
  ## Uses
29
 
30
  <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
31
+ For more comprehensive usage examples and implementation details, please refer to our official repository.
32
 
33
+ ### Requirements
34
 
35
  <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
36
 
37
+ ```
38
+ pip install git+https://github.com/huggingface/transformers accelerate
39
+ pip install qwen-vl-utils[decord]==0.0.8
40
+ pip install vllm
41
+ pip install datasets
42
+ ```
43
 
44
+ ### Using 🤗 Transformers to Chat
45
 
46
  <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
47
 
48
+ Here we show a conde snippet to show you how to use the chat model with `transformers` and `qwen_vl_utils`:
49
+
50
+ ```
51
+ from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
52
+ from qwen_vl_utils import process_vision_info
53
+ from datasets import load_dataset
54
+
55
+ import torch
56
+
57
+
58
+ # default: Load the model on the available device(s)
59
+ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
60
+ "jongwooko/Flex-VL-7B", torch_dtype="auto", device_map="auto"
61
+ )
62
+
63
+ # We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
64
+ # model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
65
+ # "jongwooko/Flex-VL-7B",
66
+ # torch_dtype=torch.bfloat16,
67
+ # attn_implementation="flash_attention_2",
68
+ # device_map="auto",
69
+ # )
70
+
71
+ # default processer
72
+ processor = AutoProcessor.from_pretrained("jongwooko/Flex-VL-7B")
73
+
74
+ # Example
75
+ example = load_dataset('MMInstruction/VL-RewardBench', split='test')[0]
76
+ question, image = example["query"], example["image"]
77
+ answer1, answer2 = example["response"]
78
+
79
+ # System prompt for Flex-Judge
80
+ SYSTEM_PROMPT = (
81
+ "You are a helpful assistant. The assistant first performs a detailed, "
82
+ "step-by-step reasoning process in its mind and then provides the user with"
83
+ "the answer. The reasoning process and answer are enclosed within <think> "
84
+ "reasoning process here, explaining each step of your evaluation for both "
85
+ "assistants </think><answer> answer here </answer>. Now the user asks you "
86
+ "to judge the performance of two AI assistants in response to the question. "
87
+ "Score assistants 1-10 (higher=better). Criteria includes helpfulness, "
88
+ "relevance, accuracy, and level of detail. Avoid order, length, style or "
89
+ "other bias. After thinking, when you finally reach a conclusion, clearly "
90
+ "provide your evaluation scores within <answer> </answer> tags, i.e., for "
91
+ "example, <answer>3</answer><answer>5</answer>"
92
+ )
93
+
94
+ messages = [
95
+ {
96
+ "role": "system", "content": SYSTEM_PROMPT
97
+ },
98
+ {
99
+ "role": "user",
100
+ "content": [
101
+ {
102
+ "type": "image",
103
+ "image": image,
104
+ },
105
+ {"type": "text", "text": "[Question]\n{question}\n\n[Assistant 1's Answer]\n{answer1}\n\n[Assistant 2's Answer]\n{answer2}"},
106
+ ]
107
+ },
108
+ ]
109
+
110
+ # Preparation for inference
111
+ text = processor.apply_chat_template(
112
+ messages, tokenize=False, add_generation_prompt=True
113
+ )
114
+ image_inputs, video_inputs = process_vision_info(messages)
115
+ inputs = processor(
116
+ text=[text+"\n<think>\n\n"],
117
+ images=image_inputs,
118
+ videos=video_inputs,
119
+ padding=True,
120
+ return_tensors="pt",
121
+ )
122
+ inputs = inputs.to("cuda")
123
+
124
+ # Inference: Generation of the output
125
+ generated_ids = model.generate(**inputs, max_new_tokens=4096)
126
+ generated_ids_trimmed = [
127
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
128
+ ]
129
+ output_text = processor.batch_decode(
130
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
131
+ )
132
+ print(output_text)
133
+ ```
134
+
135
+ ### Using vLLM
136
+
137
+ Here, we recommend using `vllm` instead of `transformers` to improve inference speed. The results in our papers are based on the `vllm` library.
138
+
139
+ ```
140
+ from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
141
+ from datasets import load_dataset
142
+ from vllm import LLM, SamplingParams
143
+
144
+ # default: Load the model on the available device(s)
145
+ llm = LLM(
146
+ "jongwooko/Flex-VL-7B",
147
+ tensor_parallel_size=4,
148
+ limit_mm_per_prompt={"image": 1}, # The maximum number to accept
149
+ )
150
+ sampling_params = SamplingParams(
151
+ max_tokens=4096,
152
+ temperature=0.2,
153
+ top_p=0.95,
154
+ )
155
+
156
+ # default processer
157
+ processor = AutoProcessor.from_pretrained("jongwooko/Flex-VL-7B", use_fast=True)
158
+
159
+ # Example
160
+ example = load_dataset('MMInstruction/VL-RewardBench', split='test')[0]
161
+ question, image = example["query"], example["image"]
162
+ answer1, answer2 = example["response"]
163
+
164
+ # System prompt for Flex-Judge
165
+ SYSTEM_PROMPT = (
166
+ "You are a helpful assistant. The assistant first performs a detailed, "
167
+ "step-by-step reasoning process in its mind and then provides the user with"
168
+ "the answer. The reasoning process and answer are enclosed within <think> "
169
+ "reasoning process here, explaining each step of your evaluation for both "
170
+ "assistants </think><answer> answer here </answer>. Now the user asks you "
171
+ "to judge the performance of two AI assistants in response to the question. "
172
+ "Score assistants 1-10 (higher=better). Criteria includes helpfulness, "
173
+ "relevance, accuracy, and level of detail. Avoid order, length, style or "
174
+ "other bias. After thinking, when you finally reach a conclusion, clearly "
175
+ "provide your evaluation scores within <answer> </answer> tags, i.e., for "
176
+ "example, <answer>3</answer><answer>5</answer>"
177
+ )
178
+
179
+ messages = [
180
+ {
181
+ "role": "system", "content": SYSTEM_PROMPT
182
+ },
183
+ {
184
+ "role": "user",
185
+ "content": [
186
+ {"type": "text", "text": "<|vision_start|><|image_pad|><|vision_end|>\n\n[Question]\n{question}\n\n[Assistant 1's Answer]\n{answer1}\n\n[Assistant 2's Answer]\n{answer2}"},
187
+ ]
188
+ },
189
+ ]
190
+
191
+ # Preparation for inference
192
+ text = processor.apply_chat_template(
193
+ messages, tokenize=False, add_generation_prompt=True
194
+ )
195
+ inputs = {"prompt": text, "multi_modal_data": {"image": [image]}}
196
+
197
+ # Inference: Generation of the output
198
+ outputs = llm.generate([inputs], sampling_params=sampling_params)
199
+ output_text = outputs[0].outputs[0].text
200
+ print (output_text)
201
+ ```
202
+
203
+ ## Citation
204
 
205
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
206
 
207
  **BibTeX:**
208
 
209
+ ```
210
+ @article{ko2025flex,
211
+ title={Flex-Judge: Text-Only Reasoning Unleashes Zero-Shot Multimodal Evaluators},
212
+ author={Ko, Jongwoo and Kim, Sungnyun and Cho, Sungwoo and Yun, Se-Young},
213
+ journal={arXiv preprint arXiv:2505.18601},
214
+ year={2025}
215
+ }
216
+ ```