Update README.md
Browse filesAdd an extended description
README.md
CHANGED
|
@@ -1,198 +1,216 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
|
| 10 |
-
[Flex-Judge
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
## Model Details
|
| 14 |
|
| 15 |
### Model Description
|
| 16 |
|
| 17 |
-
|
| 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
|
| 30 |
|
| 31 |
<!-- Provide the basic links for the model. -->
|
| 32 |
-
|
| 33 |
-
- **
|
| 34 |
-
|
| 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 |
-
###
|
| 42 |
|
| 43 |
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
###
|
| 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 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
[
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 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 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|