Views
No views yet

transformers library. Ensure you have transformers and Pillow installed.pip install transformers Pillow1from transformers import AutoProcessor, AutoModelForCausalLM
2from PIL import Image
3import torch
4
5# Load the model and processor
6# Replace "WaltonFuture/Qwen2.5VL-3b-RLCS" with "WaltonFuture/Qwen2.5VL-7b-RLCS" for the 7B model.
7model_id = "WaltonFuture/Qwen2.5VL-3b-RLCS"
8
9processor = AutoProcessor.from_pretrained(model_id)
10model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
11
12# Example image (replace with your image path or a PIL Image object)
13# Make sure to provide a valid image path.
14# For example, download an image locally:
15# import requests
16# from io import BytesIO
17# image_url = "https://www.ilusionviajera.com/wp-content/uploads/2021/04/paris-eiffel-tower-in-spring.jpg"
18# response = requests.get(image_url)
19# image = Image.open(BytesIO(response.content)).convert("RGB")
20image_path = "path/to/your/image.jpg" # Replace with your image path
21image = Image.open(image_path).convert("RGB")
22
23# Prepare the chat messages in the required multimodal format
24messages = [
25 {
26 "role": "user",
27 "content": [
28 {"type": "image", "image": image},
29 {"type": "text", "text": "Describe this image in detail and answer any questions about it. For example, what is the main subject?"},
30 ],
31 }
32]
33
34# Apply the model's chat template to format the input
35text = processor.apply_chat_template(
36 messages,
37 tokenize=False,
38 add_generation_prompt=True
39)
40
41# Process the inputs (text and image) for the model
42input_ids = processor(text=text, images=image, return_tensors="pt").input_ids.to(model.device)
43
44# Generate the response
45outputs = model.generate(input_ids=input_ids, max_new_tokens=512, do_sample=True, temperature=0.7)
46
47# Decode the generated tokens to a human-readable response
48response = processor.batch_decode(outputs, skip_special_tokens=True)[0]
49
50print(response)| Stage | Data |
|---|---|
| Cold Start | Multimodal-Cold-Start |
| RL | Multimodal-RL-Data |
| Backbone | Our model |
|---|---|
| Qwen2.5-VL-7b | Qwen2.5VL-7b-RL-with-Cold-Start |
| Qwen2.5-VL-3b | Qwen2.5VL-3b-RL-with-Cold-Start |
1@article{wei2025advancing,
2 title={Advancing Multimodal Reasoning via Reinforcement Learning with Cold Start},
3 author={Wei, Lai and Li, Yuting and Zheng, Kaipeng and Wang, Chen and Wang, Yue and Kong, Linghe and Sun, Lichao and Huang, Weiran},
4 journal={arXiv preprint arXiv:2505.22334},
5 year={2025}
6}