lmms-lab/Qwen2-VL-7B-GRPO-8k
Model Summary
This model is 7B parameter models trained on 8k curated dataset with GRPO
- Repository: EvolvingLMMs-Lab/open-r1-multimodal
- Languages: English, Chinese
Generation
The generation of this model is the same as the original Qwen/Qwen2-VL-7B-Instruct
simply changes the model_id in from pretrained would works
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
from qwen_vl_utils import process_vision_info
SYSTEM_PROMPT = (
"A conversation between User and Assistant. The user asks a question, and the Assistant solves it. The assistant "
"first thinks about the reasoning process in the mind and then provides the user with the answer. The reasoning "
"process and answer are enclosed within <think> </think> and <answer> </answer> tags, respectively, i.e., "
"<think> reasoning process here </think><answer> answer here </answer>"
)
# default: Load the model on the available device(s)
model = Qwen2VLForConditionalGeneration.from_pretrained(
"lmms-lab/Qwen2-VL-7B-GRPO-8k", torch_dtype="auto", device_map="cuda"
)
# default processer
processor = AutoProcessor.from_pretrained("lmms-lab/Qwen2-VL-7B-GRPO-8k")
# The default range for the number of visual tokens per image in the model is 4-16384. You can set min_pixels and max_pixels according to your needs, such as a token count range of 256-1280, to balance speed and memory usage.
# min_pixels = 256*28*28
# max_pixels = 1280*28*28
# processor = AutoProcessor.from_pretrained("lmms-lab/Qwen2-VL-7B-GRPO-8k", min_pixels=min_pixels, max_pixels=max_pixels)
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{
"role": "user",
"content": [
{
"type": "image",
"image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
},
{"type": "text", "text": "Describe this image."},
],
}
]
# Preparation for inference
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
Training
Model
- Architecture: Qwen/Qwen2-VL-7B-Instruct
- Initialized Model: Qwen/Qwen2-VL-7B-Instruct
- Data: lmms-lab/multimodal-open-r1-8k-verified
- Precision: bfloat16
- Downloads last month
- 24
Inference Providers
NEW
This model is not currently available via any of the supported third-party Inference Providers, and
HF Inference API was unable to determine this model's library.