Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- ZTE-AIM/Curr-ReFT-data
|
| 5 |
+
base_model:
|
| 6 |
+
- Qwen/Qwen2.5-VL-3B-Instruct
|
| 7 |
+
- Qwen/Qwen2.5-VL-7B-Instruct
|
| 8 |
+
pipeline_tag: image-text-to-text
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
## Curr-ReFT-data
|
| 12 |
+
[\[📂 GitHub\]](https://github.com/ding523/Curr_REFT)
|
| 13 |
+
[\[🤗 HF Dataset\]](https://huggingface.co/datasets/ZTE-AIM/Curr-ReFT-data)
|
| 14 |
+
## Curr-ReFT-model
|
| 15 |
+
[\[🤗 Curr-ReFT-3B\]](https://huggingface.co/ZTE-AIM/3B-Curr-ReFT)
|
| 16 |
+
[\[🤗 Curr-ReFT-7B\]](https://huggingface.co/ZTE-AIM/7B-Curr-ReFT)
|
| 17 |
+
## Model Overview
|
| 18 |
+
|
| 19 |
+
This is a multimodal large language model fine-tuned from Qwen2.5-VL using our innovative **Curr-ReFT** methodology. The model has undergone a two-stage training process: first through Curriculum Reinforcement Learning, which gradually increases task complexity, followed by Rejected Sample based Self-improvement to maintain foundational capabilities.
|
| 20 |
+
The model significantly enhances vision-language understanding and reasoning capabilities, making it exceptionally well-suited for complex tasks such as visual reasoning, detailed image understanding, and multimodal problem-solving. With its robust ability to perform sophisticated multimodal reasoning, Curr-ReFT emerges as a powerful AI assistant capable of addressing a wide range of challenges across diverse domains with improved accuracy and contextual awareness.
|
| 21 |
+
|
| 22 |
+
## Training Configuration
|
| 23 |
+
- Framework: The training process uses the open-source **R1-V** library, with **Qwen2.5-VL-Instruct** as the base model. This model comes in three variants: 3B, 7B.
|
| 24 |
+
|
| 25 |
+
The training configuration for grpo is as follows:
|
| 26 |
+
```python
|
| 27 |
+
max_pixels 401408
|
| 28 |
+
per_device_train_batch_size: 1
|
| 29 |
+
gradient_accumulation_steps: 1
|
| 30 |
+
learning_rate: 1.0e-5
|
| 31 |
+
|
| 32 |
+
num_train_epochs: 1.0
|
| 33 |
+
lr_scheduler_type: cosine
|
| 34 |
+
bf16: true
|
| 35 |
+
flash_attn: fa2
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
## Usage
|
| 39 |
+
|
| 40 |
+
You can load the model using the Hugging Face `transformers` library:
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
|
| 44 |
+
import torch
|
| 45 |
+
from qwen_vl_utils import process_vision_info
|
| 46 |
+
|
| 47 |
+
MODEL_ID = "Curr-ReFT-3B"
|
| 48 |
+
processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True)
|
| 49 |
+
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 50 |
+
MODEL_ID,
|
| 51 |
+
trust_remote_code=True,
|
| 52 |
+
torch_dtype=torch.bfloat16
|
| 53 |
+
).to("cuda").eval()
|
| 54 |
+
|
| 55 |
+
messages = [
|
| 56 |
+
{
|
| 57 |
+
"role": "user",
|
| 58 |
+
"content": [
|
| 59 |
+
{"type": "image", "image": "<your image path>"},
|
| 60 |
+
{"type": "text", "text": "Hint: Please answer the question and provide the final answer at the end. Question: Which number do you have to write in the last daisy?"},
|
| 61 |
+
],
|
| 62 |
+
}
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
# Preparation for inference
|
| 66 |
+
text = processor.apply_chat_template(
|
| 67 |
+
messages, tokenize=False, add_generation_prompt=True
|
| 68 |
+
)
|
| 69 |
+
image_inputs, video_inputs = process_vision_info(messages)
|
| 70 |
+
inputs = processor(
|
| 71 |
+
text=[text],
|
| 72 |
+
images=image_inputs,
|
| 73 |
+
videos=video_inputs,
|
| 74 |
+
padding=True,
|
| 75 |
+
return_tensors="pt",
|
| 76 |
+
)
|
| 77 |
+
inputs = inputs.to(model.device)
|
| 78 |
+
|
| 79 |
+
generated_ids = model.generate(**inputs, max_new_tokens=4096)
|
| 80 |
+
generated_ids_trimmed = [
|
| 81 |
+
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 82 |
+
]
|
| 83 |
+
output_text = processor.batch_decode(
|
| 84 |
+
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 85 |
+
)
|
| 86 |
+
print(output_text)
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
# Institution
|
| 92 |
+
- ZTE-AIM
|
| 93 |
+
- University of Science and Technology of China
|
| 94 |
+
|
| 95 |
+
## Model Contact
|
| 96 | |
| 97 | |
| 98 | |
| 99 |
+
|