MMR1/MMR1-Math-v0-7B
61.6k
1---2base_model:3- Qwen/Qwen2.5-VL-7B-Instruct4language:5- en6library_name: transformers7license: apache-2.08pipeline_tag: image-text-to-text9tags:10- multi-modal11- large-language-model12---13 14<p align="center">15 <img src="https://github.com/LengSicong/MMR1/blob/main/assets/logo.png?raw=true" width="150" style="margin-bottom: 0.2;"/>16<p>17 18<h3 align="center">19MMR1: Advancing the Frontiers of Multimodal Reasoning</a></h3>20<h5 align="center"> If you like our project, please give us a star ⭐ on <a href="https://github.com/LengSicong/MMR1">Github</a> to support us. 🙏🙏 </h2>21 22## 📰 News23* **[2025.03.11]** 🔥🔥 Release MMR1-Math-v0, achieving SOTA with only 6k data!24 25## Links26Code: https://github.com/LengSicong/MMR127 28## Model Description29MMR1-Math-v0-7B is a Large Multimodal Model specialized in mathematical tasks. Remarkably, MMR1-Math-v0-7B achieves state-of-the-art performance among open-source 7B multimodal models, competing effectively even against proprietary models with significantly larger parameter sizes—all trained using only 6k carefully curated data instances.30 31### Key Highlights:32 33- **SOTA Performance**: Sets a new **state-of-the-art** benchmark on math-related multimodal tasks among open-source 7B models.34 35- **Minimal Training Data**: Remarkably achieves top-tier performance with just **6k** high-quality samples from **public training datasets**.36 37- **Efficient Training with GRPO**: 6 hours of RL training with 64 H100s for 15 epochs.38 39- **Public and High-Quality Data**: Publicly sourced datasets, rigorously filtered and balanced across both difficulty and mathematical problem types.40 41- **Balanced Data Strategy**: Uniform sampling of data based on both task difficulty (filtering out overly simple problems) and mathematical reasoning diversity.42 43 44## Evaluation Results45 46We evaluated our model using [VLMEvalKit](https://github.com/open-compass/VLMEvalKit/tree/main) on four mathematical reasoning benchmarks: MathVista_MINI, MathVision, LogicVista, and MathVerse_MINI.47 48We also include results on the MathVerse_MINI_Vision_Only_cot (MathVerse_V) subset to maintain consistency with the VLMEvalKit leaderboard. The table below compares our model's performance against various open-source and proprietary models.49 50| Model | size | MathVista | MathVision | LogicVista | MathVerse | MathVerse_V |51|-------|:----:|:--------------:|:----------:|:----------:|:--------------:|:-------------------:|52| **Close-sourced** | | | | | | |53| [GPT-4o 1120](https://openai.com/index/gpt-4o-system-card/) | - | 60.0 | 31.2 | 52.8 | 40.6 | - |54| [Gemini-2.0-flash](https://deepmind.google/technologies/gemini/flash/) | - | 70.4 | 43.6 | 52.3 | 47.8 | - |55| [Claude3.7-Sonnet](https://www.anthropic.com/news/claude-3-7-sonnet) | - | 66.8 | 41.9 | 58.2 | 46.7 | - |56| **R1-related** | | | | | | |57| [LLaVA-CoT](https://github.com/PKU-YuanGroup/LLaVA-CoT) | 11B | 52.5 | 19.9 | 39.6 | 22.6 | - |58| [Open-R1-Multimodal](https://github.com/EvolvingLMMs-Lab/open-r1-multimodal) | 7B | 60.6 | - | - | - | - |59| [Mulberry](https://github.com/HJYao00/Mulberry) | 7B | 63.1 | - | - | - | - |60| [LMM-R1](https://arxiv.org/abs/2503.07536) | 3B | 63.2 | 26.4 | - | - | 41.6 |61| [R1-Onevision](https://github.com/Fancy-MLLM/R1-Onevision?tab=readme-ov-file) | 7B | - | 26.2 | - | - | 44.1 |62| [MM-Eureka](https://github.com/ModalMinds/MM-EUREKA) | 8B | 67.1 | 22.2 | - | - | 40.4 |63| [MM-Eureka](https://github.com/ModalMinds/MM-EUREKA) | 38B | 64.2 | 26.6 | - | - | 48.9 |64| **Open-sourced** | | | | | | |65| [Ovis2-8b](https://github.com/AIDC-AI/Ovis) | 8B | 71.8 | 25.9 | 39.4 | 42.3 | - |66| [MiniCPM-o-2.6](https://github.com/OpenBMB/MiniCPM-o) | 8B | **71.9** | 21.7 | 36.0 | 35.0 | - |67| [Qwen2.5-VL](https://github.com/QwenLM/Qwen2.5-VL) (official) | 7B | 68.2 | 25.4 | 47.9 | 41.1 | - |68| [Qwen2.5-VL](https://github.com/QwenLM/Qwen2.5-VL) (reproduced) | 7B | 67.5 | 25.6 | 46.8 | 42.5 | 46.9 |69| **Ours** | | | | | | |70| **MMR1-math-v0** | 7B | 71.0 | **30.2** | **50.8** | **45.1** | **49.8** |71 72 73 74### Quick Start75```python76from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor77from qwen_vl_utils import process_vision_info78# default: Load the model on the available device(s)79model = Qwen2_5_VLForConditionalGeneration.from_pretrained(80 "MMR1/MMR1-Math-v0-7B", 81 torch_dtype=torch.bfloat16,82 attn_implementation="flash_attention_2",83 device_map="auto",84)85# default processer86processor = AutoProcessor.from_pretrained("MMR1/MMR1-Math-v0-7B")87# Example input88messages = [89 {90 "role": "user",91 "content": [92 {93 "type": "image",94 "image": "path/to/image.jpeg",95 },96 {"type": "text", "text": "Describe this image."},97 ],98 }99]100# Preparation for inference101text = processor.apply_chat_template(102 messages, tokenize=False, add_generation_prompt=True103)104image_inputs, video_inputs = process_vision_info(messages)105inputs = processor(106 text=[text],107 images=image_inputs,108 videos=video_inputs,109 padding=True,110 return_tensors="pt",111)112inputs = inputs.to("cuda")113# Inference: Generation of the output114generated_ids = model.generate(**inputs, max_new_tokens=128)115generated_ids_trimmed = [116 out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)117]118output_text = processor.batch_decode(119 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False120)121print(output_text)122```123<details>124<summary>Batch inference</summary>125 126```python127# Sample messages for batch inference128messages1 = [129 {130 "role": "user",131 "content": [132 {"type": "image", "image": "file:///path/to/image1.jpg"},133 {"type": "image", "image": "file:///path/to/image2.jpg"},134 {"type": "text", "text": "What are the common elements in these pictures?"},135 ],136 }137]138messages2 = [139 {"role": "system", "content": "You are a helpful assistant."},140 {"role": "user", "content": "Who are you?"},141]142# Combine messages for batch processing143messages = [messages1, messages2]144# Preparation for batch inference145texts = [146 processor.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)147 for msg in messages148]149image_inputs, video_inputs = process_vision_info(messages)150inputs = processor(151 text=texts,152 images=image_inputs,153 videos=video_inputs,154 padding=True,155 return_tensors="pt",156)157inputs = inputs.to("cuda")158# Batch Inference159generated_ids = model.generate(**inputs, max_new_tokens=128)160generated_ids_trimmed = [161 out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)162]163output_texts = processor.batch_decode(164 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False165)166print(output_texts)167```168</details>169 170 171## Citation172 173If you find MMR1 useful for your research and applications, please cite using this BibTeX:174 175```bibtex176@misc{MMR1-Math2025,177 title={MMR1: Advancing the Frontiers of Multimodal Reasoning},178 author={Sicong Leng*, Jing Wang*, Jiaxi Li*, Hao Zhang*, Zhiqiang Hu, Boqiang Zhang, Hang Zhang, Yuming Jiang, Xin Li, Fan Wang, Yu Rong, Aixin Sun†, Shijian Lu†},179 year={2025},180 howpublished={\url{https://github.com/LengSicong/MMR1}},181}182```