minpeter commited on
Commit
7525e5f
·
verified ·
1 Parent(s): efac1b2

diff for compatibility

Browse files
Files changed (4) hide show
  1. README.md +11 -177
  2. config.json +5 -2
  3. generation_config.json +1 -1
  4. tokenizer_config.json +2 -2
README.md CHANGED
@@ -12,188 +12,22 @@ tags:
12
  - custom_code
13
  ---
14
 
 
 
 
 
 
15
 
16
- <h1>A GPT-4V Level Multimodal LLM on Your Phone</h1>
17
 
18
- [GitHub](https://github.com/OpenBMB/MiniCPM-V) | [Demo](https://huggingface.co/spaces/openbmb/MiniCPM-Llama3-V-2_5) | <a href="https://github.com/OpenBMB/MiniCPM-V/blob/main/docs/wechat.md" target="_blank"> WeChat</a>
19
 
 
 
20
 
21
- ## News <!-- omit in toc -->
22
 
23
- #### 📌 Pinned
24
-
25
- * [2025.01.14] 🔥🔥 🔥 We open source [**MiniCPM-o 2.6**](https://huggingface.co/openbmb/MiniCPM-o-2_6), with significant performance improvement over **MiniCPM-V 2.6**, and support real-time speech-to-speech conversation and multimodal live streaming. Try it now.
26
-
27
- * [2024.08.10] 🚀🚀🚀 MiniCPM-Llama3-V 2.5 is now fully supported by [official](https://github.com/ggerganov/llama.cpp) llama.cpp! GGUF models of various sizes are available [here](https://huggingface.co/openbmb/MiniCPM-Llama3-V-2_5-gguf).
28
- * [2024.08.06] 🔥🔥🔥 We open-source [**MiniCPM-V 2.6**](https://huggingface.co/openbmb/MiniCPM-V-2_6), which outperforms GPT-4V on single image, multi-image and video understanding. It advances popular features of MiniCPM-Llama3-V 2.5, and can support real-time video understanding on iPad. Try it now!
29
- * [2024.08.03] MiniCPM-Llama3-V 2.5 technical report is released! See [here](https://github.com/OpenBMB/MiniCPM-V/tree/main/docs/MiniCPM_Llama3_V_25_technical_report.pdf).
30
- * [2024.07.19] MiniCPM-Llama3-V 2.5 supports vLLM now! See [here](https://github.com/OpenBMB/MiniCPM-V/tree/main?tab=readme-ov-file#vllm).
31
- * [2024.05.28] 💫 We now support LoRA fine-tuning for MiniCPM-Llama3-V 2.5, using only 2 V100 GPUs! See more statistics [here](https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#model-fine-tuning-memory-usage-statistics).
32
- * [2024.05.23] 🔥🔥🔥 MiniCPM-V tops GitHub Trending and HuggingFace Trending! Our demo, recommended by Hugging Face Gradio’s official account, is available [here](https://huggingface.co/spaces/openbmb/MiniCPM-Llama3-V-2_5). Come and try it out!
33
- * [2024.05.20] We open-soure MiniCPM-Llama3-V 2.5, it has improved OCR capability and supports 30+ languages, representing the first end-side MLLM achieving GPT-4V level performance! We provide [efficient inference](#deployment-on-mobile-phone) and [simple fine-tuning](https://github.com/OpenBMB/MiniCPM-V/blob/main/finetune/readme.md). Try it now!
34
-
35
-
36
- ## Model Summary
37
-
38
- **MiniCPM-Llama3-V 2.5** is the latest model in the MiniCPM-V series. The model is built on SigLip-400M and Llama3-8B-Instruct with a total of 8B parameters. It exhibits a significant performance improvement over MiniCPM-V 2.0. Notable features of MiniCPM-Llama3-V 2.5 include:
39
-
40
- - 🔥 **Leading Performance.**
41
- MiniCPM-Llama3-V 2.5 has achieved an average score of 65.1 on OpenCompass, a comprehensive evaluation over 11 popular benchmarks. **With only 8B parameters, it surpasses widely used proprietary models like GPT-4V-1106, Gemini Pro, Claude 3 and Qwen-VL-Max** and greatly outperforms other Llama 3-based MLLMs.
42
-
43
- - 💪 **Strong OCR Capabilities.**
44
- MiniCPM-Llama3-V 2.5 can process images with any aspect ratio and up to 1.8 million pixels (e.g., 1344x1344), achieving an **700+ score on OCRBench, surpassing proprietary models such as GPT-4o, GPT-4V-0409, Qwen-VL-Max and Gemini Pro**. Based on recent user feedback, MiniCPM-Llama3-V 2.5 has now enhanced full-text OCR extraction, table-to-markdown conversion, and other high-utility capabilities, and has further strengthened its instruction-following and complex reasoning abilities, enhancing multimodal interaction experiences.
45
-
46
- - 🏆 **Trustworthy Behavior.**
47
- Leveraging the latest [RLAIF-V](https://github.com/RLHF-V/RLAIF-V/) method (the newest technology in the [RLHF-V](https://github.com/RLHF-V) [CVPR'24] series), MiniCPM-Llama3-V 2.5 exhibits more trustworthy behavior. It achieves **10.3%** hallucination rate on Object HalBench, lower than GPT-4V-1106 (13.6%), achieving the best-level performance within the open-source community. [Data released](https://huggingface.co/datasets/openbmb/RLAIF-V-Dataset).
48
-
49
- - 🌏 **Multilingual Support.**
50
- Thanks to the strong multilingual capabilities of Llama 3 and the cross-lingual generalization technique from [VisCPM](https://github.com/OpenBMB/VisCPM), MiniCPM-Llama3-V 2.5 extends its bilingual (Chinese-English) multimodal capabilities to **over 30 languages including German, French, Spanish, Italian, Korean, Japanese etc.** [All Supported Languages](./assets/minicpm-llama-v-2-5_languages.md).
51
-
52
- - 🚀 **Efficient Deployment.**
53
- MiniCPM-Llama3-V 2.5 systematically employs **model quantization, CPU optimizations, NPU optimizations and compilation optimizations**, achieving high-efficiency deployment on edge devices. For mobile phones with Qualcomm chips, we have integrated the NPU acceleration framework QNN into llama.cpp for the first time. After systematic optimization, MiniCPM-Llama3-V 2.5 has realized a **150-fold acceleration in multimodal large model end-side image encoding** and a **3-fold increase in language decoding speed**.
54
-
55
- - 💫 **Easy Usage.**
56
- MiniCPM-Llama3-V 2.5 can be easily used in various ways: (1) [llama.cpp](https://github.com/OpenBMB/llama.cpp/blob/minicpm-v2.5/examples/minicpmv/README.md) and [ollama](https://github.com/OpenBMB/ollama/tree/minicpm-v2.5/examples/minicpm-v2.5) support for efficient CPU inference on local devices, (2) [GGUF](https://huggingface.co/openbmb/MiniCPM-Llama3-V-2_5-gguf) format quantized models in 16 sizes, (3) efficient [LoRA](https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning) fine-tuning with only 2 V100 GPUs, (4) [streaming output](https://huggingface.co/openbmb/MiniCPM-Llama3-V-2_5#usage), (5) quick local WebUI demo setup with [Gradio](https://github.com/OpenBMB/MiniCPM-V/blob/main/web_demo_2.5.py) and [Streamlit](https://github.com/OpenBMB/MiniCPM-V/blob/main/web_demo_streamlit-2_5.py), and (6) interactive demos on [HuggingFace Spaces](https://huggingface.co/spaces/openbmb/MiniCPM-Llama3-V-2_5).
57
-
58
- ### Evaluation <!-- omit in toc -->
59
-
60
- Results on TextVQA, DocVQA, OCRBench, OpenCompass MultiModal Avg , MME, MMBench, MMMU, MathVista, LLaVA Bench, RealWorld QA, Object HalBench.
61
-
62
- <div align="center">
63
- <img src="https://cdn-uploads.huggingface.co/production/uploads/64abc4aa6cadc7aca585dddf/v2KE3wqQgM05ZW3dH2wbx.png" width="110%" />
64
- </div>
65
-
66
-
67
- Evaluation results of multilingual LLaVA Bench
68
- <div align="center">
69
- <img src="assets/minicpmv-llama3-v2.5/llavabench_compare.png" width="110%" />
70
- </div>
71
-
72
-
73
- ### Examples <!-- omit in toc -->
74
-
75
- <table align="center">
76
- <p align="center">
77
- <img src="assets/minicpmv-llama3-v2.5/cases_all.png" width=95%/>
78
- </p>
79
- </table>
80
-
81
- We deploy MiniCPM-Llama3-V 2.5 on end devices. The demo video is the raw screen recording on a Xiaomi 14 Pro without edition.
82
-
83
- <table align="center">
84
- <p align="center">
85
- <img src="assets/gif_cases/ticket.gif" width=40% style="display:inline-block;"/>
86
- <img src="assets/gif_cases/meal_plan.gif" width=40% style="display:inline-block;"/>
87
- </p>
88
- </table>
89
-
90
- <table align="center">
91
- <p align="center">
92
- <img src="assets/gif_cases/1-4.gif" width=80%/>
93
- </p>
94
- </table>
95
-
96
-
97
-
98
- ## Demo
99
- Click here to try out the Demo of [MiniCPM-Llama3-V 2.5](https://huggingface.co/spaces/openbmb/MiniCPM-Llama3-V-2_5).
100
-
101
- ## Deployment on Mobile Phone
102
- Coming soon.
103
-
104
- ## Usage
105
- Inference using Huggingface transformers on NVIDIA GPUs. Requirements tested on python 3.10:
106
- ```
107
- Pillow==10.1.0
108
- torch==2.1.2
109
- torchvision==0.16.2
110
- transformers==4.40.0
111
- sentencepiece==0.1.99
112
- ```
113
-
114
- ```python
115
- # test.py
116
- import torch
117
- from PIL import Image
118
- from transformers import AutoModel, AutoTokenizer
119
-
120
- model = AutoModel.from_pretrained('openbmb/MiniCPM-Llama3-V-2_5', trust_remote_code=True, torch_dtype=torch.float16)
121
- model = model.to(device='cuda')
122
-
123
- tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-Llama3-V-2_5', trust_remote_code=True)
124
- model.eval()
125
-
126
- image = Image.open('xx.jpg').convert('RGB')
127
- question = 'What is in the image?'
128
- msgs = [{'role': 'user', 'content': question}]
129
-
130
- res = model.chat(
131
- image=image,
132
- msgs=msgs,
133
- tokenizer=tokenizer,
134
- sampling=True, # if sampling=False, beam_search will be used by default
135
- temperature=0.7,
136
- # system_prompt='' # pass system_prompt if needed
137
- )
138
- print(res)
139
-
140
- ## if you want to use streaming, please make sure sampling=True and stream=True
141
- ## the model.chat will return a generator
142
- res = model.chat(
143
- image=image,
144
- msgs=msgs,
145
- tokenizer=tokenizer,
146
- sampling=True,
147
- temperature=0.7,
148
- stream=True
149
- )
150
-
151
- generated_text = ""
152
- for new_text in res:
153
- generated_text += new_text
154
- print(new_text, flush=True, end='')
155
- ```
156
-
157
- Please look at [GitHub](https://github.com/OpenBMB/MiniCPM-V) for more detail about usage.
158
-
159
-
160
- ## Inference with llama.cpp<a id="llamacpp"></a>
161
- MiniCPM-Llama3-V 2.5 can run with llama.cpp now! See our fork of [llama.cpp](https://github.com/OpenBMB/llama.cpp/tree/minicpm-v2.5/examples/minicpmv) for more detail.
162
-
163
-
164
- ## Int4 quantized version
165
- Download the int4 quantized version for lower GPU memory (8GB) usage: [MiniCPM-Llama3-V-2_5-int4](https://huggingface.co/openbmb/MiniCPM-Llama3-V-2_5-int4).
166
-
167
- ## MiniCPM-V 2.0 <!-- omit in toc -->
168
- Please see the info about MiniCPM-V 2.0 [here](https://huggingface.co/openbmb/MiniCPM-V-2).
169
 
170
  ## License
171
- #### Model License
172
- * The code in this repo is released under the [Apache-2.0](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE) License.
173
- * The usage of MiniCPM-V series model weights must strictly follow [MiniCPM Model License.md](https://github.com/OpenBMB/MiniCPM/blob/main/MiniCPM%20Model%20License.md).
174
- * The models and weights of MiniCPM are completely free for academic research. after filling out a ["questionnaire"](https://modelbest.feishu.cn/share/base/form/shrcnpV5ZT9EJ6xYjh3Kx0J6v8g) for registration, are also available for free commercial use.
175
-
176
-
177
-
178
- #### Statement
179
- * As an LLM, MiniCPM-Llama3-V 2.5 generates contents by learning a large mount of texts, but it cannot comprehend, express personal opinions or make value judgement. Anything generated by MiniCPM-Llama3-V 2.5 does not represent the views and positions of the model developers
180
- * We will not be liable for any problems arising from the use of the MinCPM-V open Source model, including but not limited to data security issues, risk of public opinion, or any risks and problems arising from the misdirection, misuse, dissemination or misuse of the model.
181
-
182
- ## Key Techniques and Other Multimodal Projects
183
-
184
- 👏 Welcome to explore key techniques of MiniCPM-V 2.6 and other multimodal projects of our team:
185
-
186
- [VisCPM](https://github.com/OpenBMB/VisCPM/tree/main) | [RLHF-V](https://github.com/RLHF-V/RLHF-V) | [LLaVA-UHD](https://github.com/thunlp/LLaVA-UHD) | [RLAIF-V](https://github.com/RLHF-V/RLAIF-V)
187
-
188
- ## Citation
189
-
190
- If you find our work helpful, please consider citing our papers 📝 and liking this project ❤️!
191
 
192
- ```bib
193
- @article{yao2024minicpmv,
194
- title={MiniCPM-V: A GPT-4V Level MLLM on Your Phone},
195
- author={Yao, Yuan and Yu, Tianyu and Zhang, Ao and Wang, Chongyi and Cui, Junbo and Zhu, Hongji and Cai, Tianchi and Li, Haoyu and Zhao, Weilin and He, Zhihui and Chen, Qianyu and Zhou, Huarong and Zou, Zhensheng and Zhang, Haoye and Hu, Shengding and Zheng, Zhi and Zhou, Jie and Cai, Jie and Han, Xu and Zeng, Guoyang and Li, Dahai and Liu, Zhiyuan and Sun, Maosong},
196
- journal={arXiv preprint 2408.01800},
197
- year={2024},
198
- }
199
- ```
 
12
  - custom_code
13
  ---
14
 
15
+ <!-- header start -->
16
+ <p align="center">
17
+ <img src="https://huggingface.co/datasets/FriendliAI/documentation-images/resolve/main/model-card-assets/friendliai.png" width="100%" alt="FriendliAI Logo">
18
+ </p>
19
+ <!-- header end -->
20
 
 
21
 
22
+ # openbmb/MiniCPM-Llama3-V-2_5
23
 
24
+ * Model creator: [openbmb](https://huggingface.co/openbmb)
25
+ * Original model: [MiniCPM-Llama3-V-2_5](https://huggingface.co/openbmb/MiniCPM-Llama3-V-2_5)
26
 
27
+ ## Differences
28
 
29
+ * Added missing eos_token (`<|eot_id|>`) to config.json
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  ## License
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ Refer to the license of the original model card.
 
 
 
 
 
 
 
config.json CHANGED
@@ -14,7 +14,10 @@
14
  "batch_vision_input": true,
15
  "bos_token_id": 128000,
16
  "drop_vision_last_layer": false,
17
- "eos_token_id": 128001,
 
 
 
18
  "hidden_act": "silu",
19
  "hidden_size": 4096,
20
  "image_size": 448,
@@ -52,4 +55,4 @@
52
  "patch_size": 14
53
  },
54
  "vocab_size": 128256
55
- }
 
14
  "batch_vision_input": true,
15
  "bos_token_id": 128000,
16
  "drop_vision_last_layer": false,
17
+ "eos_token_id": [
18
+ 128001,
19
+ 128009
20
+ ],
21
  "hidden_act": "silu",
22
  "hidden_size": 4096,
23
  "image_size": 448,
 
55
  "patch_size": 14
56
  },
57
  "vocab_size": 128256
58
+ }
generation_config.json CHANGED
@@ -3,4 +3,4 @@
3
  "bos_token_id": 128000,
4
  "eos_token_id": 128001,
5
  "transformers_version": "4.40.0"
6
- }
 
3
  "bos_token_id": 128000,
4
  "eos_token_id": 128001,
5
  "transformers_version": "4.40.0"
6
+ }
tokenizer_config.json CHANGED
@@ -2058,7 +2058,7 @@
2058
  "bos_token": "<|begin_of_text|>",
2059
  "chat_template": "{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}",
2060
  "clean_up_tokenization_spaces": true,
2061
- "eos_token": "<|end_of_text|>",
2062
  "model_input_names": [
2063
  "input_ids",
2064
  "attention_mask"
@@ -2069,4 +2069,4 @@
2069
  "tokenizer_class": "MiniCPMVTokenizerFast",
2070
  "truncation_side": "right",
2071
  "unk_token": "<unk>"
2072
- }
 
2058
  "bos_token": "<|begin_of_text|>",
2059
  "chat_template": "{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}",
2060
  "clean_up_tokenization_spaces": true,
2061
+ "eos_token": "<|eot_id|>",
2062
  "model_input_names": [
2063
  "input_ids",
2064
  "attention_mask"
 
2069
  "tokenizer_class": "MiniCPMVTokenizerFast",
2070
  "truncation_side": "right",
2071
  "unk_token": "<unk>"
2072
+ }