finalf0 commited on
Commit
725ce06
1 Parent(s): 09b758e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +357 -0
README.md ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: visual-question-answering
3
+ ---
4
+
5
+ ## MiniCPM-V 2.0
6
+ **MiniCPM-V 2.8B** is an efficient version with promising performance for deployment. The model is built based on SigLip-400M and [MiniCPM-2.4B](https://github.com/OpenBMB/MiniCPM/), connected by a perceiver resampler. Our latest version, **MiniCPM-V 2.0** has several notable features.
7
+
8
+ - 🔥 **State-of-the-art Performance.**
9
+
10
+ MiniCPM-V 2.0 achieves **state-of-the-art performance** on multiple benchmarks (including OCRBench, TextVQA, MME, MMB, MathVista, etc) among models under 7B parameters. It even **outperforms strong Qwen-VL-Chat 9.6B, CogVLM-Chat 17.4B, and Yi-VL 34B on OpenCompass, a comprehesive evaluation over 11 popular benchmarks**. Notably, MiniCPM-V 2.0 shows **strong OCR capability**, achieving **comparable performance to Gemini Pro in scene-text understanding**, and **state-of-the-art performance on OCRBench** among open-source models.
11
+
12
+ - 🏆 **Trustworthy Behavior.**
13
+
14
+ LMMs are known for suffering from hallucination, often generating text not factually grounded in images. MiniCPM-V 2.0 is **the first end-side LMM aligned via multimodal RLHF for trustworthy behavior** (using the recent [RLHF-V](https://rlhf-v.github.io/) [CVPR'24] series technique). This allows the model to **match GPT-4V in preventing hallucinations** on Object HalBench.
15
+
16
+ - 🌟 **High-Resolution Images at Any Aspect Raito.**
17
+
18
+ MiniCPM-V 2.0 can accept **1.8 million pixel (e.g., 1344x1344) images at any aspect ratio**. This enables better perception of fine-grained visual information such as small objects and optical characters, which is achieved via a recent technique from [LLaVA-UHD](https://arxiv.org/pdf/2403.11703.pdf).
19
+
20
+ - ⚡️ **High Efficiency.**
21
+
22
+ MiniCPM-V 2.0 can be **efficiently deployed on most GPU cards and personal computers**, and **even on end devices such as mobile phones**. For visual encoding, we compress the image representations into much fewer tokens via a perceiver resampler. This allows MiniCPM-V 2.0 to operate with **favorable memory cost and speed during inference even when dealing with high-resolution images**.
23
+
24
+
25
+
26
+ - 🙌 **Bilingual Support.**
27
+
28
+ MiniCPM-V 2.0 **supports strong bilingual multimodal capabilities in both English and Chinese**. This is enabled by generalizing multimodal capabilities across languages, a technique from [VisCPM](https://arxiv.org/abs/2308.12038) [ICLR'24 Spotlight].
29
+
30
+ ## Evaluation <!-- omit in toc -->
31
+
32
+ <div align="center">
33
+ <img src=assets/minicpmv-2-peformance.png width=66% />
34
+ </div>
35
+ <details>
36
+ <summary>Click to view results on TextVQA, DocVQA, OCRBench, OpenCompass, MME, MMBench, MMMU, MathVista, LLaVA Bench, Object HalBench. </summary>
37
+ <div align="center">
38
+
39
+ <table style="margin: 0px auto;">
40
+ <thead>
41
+ <tr>
42
+ <th align="left">Model</th>
43
+ <th>Size</th>
44
+ <th>TextVQA val</th>
45
+ <th>DocVQA test</th>
46
+ <th>OCRBench</th>
47
+ <th>OpenCompass</th>
48
+ <th nowrap="nowrap" >MME</th>
49
+ <th>MMB dev(en)</th>
50
+ <th>MMB dev(zh)</th>
51
+ <th>MMMU val</th>
52
+ <th>MathVista</th>
53
+ <th>LLaVA Bench</th>
54
+ <th nowrap="nowrap">Object HalBench</th>
55
+ </tr>
56
+ </thead>
57
+ <tbody align="center">
58
+ <tr>
59
+ <td colspan="12" align="left"><strong>Proprietary models</strong></td>
60
+ </tr>
61
+ <tr>
62
+ <td nowrap="nowrap" align="left">Gemini Pro Vision</td>
63
+ <td>- </td>
64
+ <td>74.6</td>
65
+ <td>88.1</td>
66
+ <td>680</td>
67
+ <td>63.8</td>
68
+ <td>2148.9</td>
69
+ <td>75.2</td>
70
+ <td>74.0</td>
71
+ <td>48.9</td>
72
+ <td>45.8</td>
73
+ <td>79.9</td>
74
+ <td>- </td>
75
+ </tr>
76
+ <tr>
77
+ <td nowrap="nowrap" align="left">GPT-4V</td>
78
+ <td>- </td>
79
+ <td>78.0</td>
80
+ <td>88.4</td>
81
+ <td>516</td>
82
+ <td>63.2</td>
83
+ <td>1771.5</td>
84
+ <td>75.1</td>
85
+ <td>75.0</td>
86
+ <td>53.8</td>
87
+ <td>47.8</td>
88
+ <td>93.1</td>
89
+ <td>86.4 / 92.7</td>
90
+ </tr>
91
+ <tr>
92
+ <td colspan="12" align="left"><strong>Open-source models 6B~34B</strong></td>
93
+ </tr>
94
+ <tr>
95
+ <td nowrap="nowrap" align="left" >Yi-VL-6B</td>
96
+ <td align="right" >6.7B</td>
97
+ <td>45.5*</td>
98
+ <td>17.1*</td>
99
+ <td>290</td>
100
+ <td>49.3</td>
101
+ <td>1915.1 </td>
102
+ <td>68.6 </td>
103
+ <td>68.3 </td>
104
+ <td>40.3 </td>
105
+ <td>28.8 </td>
106
+ <td>51.9 </td>
107
+ <td>- </td>
108
+ </tr>
109
+ <tr>
110
+ <td nowrap="nowrap" align="left" >Qwen-VL-Chat</td>
111
+ <td align="right" >9.6B</td>
112
+ <td>61.5</td>
113
+ <td>62.6</td>
114
+ <td>488 </td>
115
+ <td>52.1 </td>
116
+ <td>1860.0 </td>
117
+ <td>60.6 </td>
118
+ <td>56.7 </td>
119
+ <td>37.0 </td>
120
+ <td>33.8 </td>
121
+ <td>67.7 </td>
122
+ <td>56.2 / 80.0</td>
123
+ </tr>
124
+ <tr>
125
+ <td nowrap="nowrap" align="left" >Yi-VL-34B</td>
126
+ <td align="right" >34B</td>
127
+ <td>43.4*</td>
128
+ <td>16.9*</td>
129
+ <td>290</td>
130
+ <td>52.6 </td>
131
+ <td>2050.2</td>
132
+ <td>71.1</td>
133
+ <td>71.4</td>
134
+ <td>45.1</td>
135
+ <td>30.7</td>
136
+ <td>62.3</td>
137
+ <td>- </td>
138
+ </tr>
139
+ <tr>
140
+ <td nowrap="nowrap" align="left" >DeepSeek-VL-7B</td>
141
+ <td align="right" >7.3B</td>
142
+ <td>64.7*</td>
143
+ <td>47.0* </td>
144
+ <td>435</td>
145
+ <td>55.6 </td>
146
+ <td>1765.4 </td>
147
+ <td>74.1 </td>
148
+ <td>72.8 </td>
149
+ <td>38.3 </td>
150
+ <td>36.8</td>
151
+ <td>77.8 </td>
152
+ <td>- </td>
153
+ </tr>
154
+ <tr>
155
+ <td nowrap="nowrap" align="left" >TextMonkey</td>
156
+ <td align="right" >9.7B</td>
157
+ <td>64.3</td>
158
+ <td>66.7 </td>
159
+ <td>558</td>
160
+ <td>- </td>
161
+ <td>- </td>
162
+ <td>- </td>
163
+ <td>- </td>
164
+ <td>- </td>
165
+ <td>-</td>
166
+ <td>- </td>
167
+ <td>- </td>
168
+ </tr>
169
+ <tr>
170
+ <td nowrap="nowrap" align="left" >CogVLM-Chat</td>
171
+ <td align="right" >17.4B</td>
172
+ <td>70.4</td>
173
+ <td>33.3*</td>
174
+ <td>590 </td>
175
+ <td>52.5 </td>
176
+ <td>1736.6 </td>
177
+ <td>63.7 </td>
178
+ <td>53.8 </td>
179
+ <td>37.3 </td>
180
+ <td>34.7 </td>
181
+ <td>73.9 </td>
182
+ <td>73.6 / 87.4 </td>
183
+ </tr>
184
+ <tr>
185
+ <td colspan="12" align="left"><strong>Open-source models 1B~3B </strong></td>
186
+ </tr>
187
+ <tr>
188
+ <td nowrap="nowrap" align="left" >DeepSeek-VL-1.3B</td>
189
+ <td align="right" >1.7B</td>
190
+ <td>58.4*</td>
191
+ <td>37.9*</td>
192
+ <td>413</td>
193
+ <td>46.0 </td>
194
+ <td>1531.6 </td>
195
+ <td>64.0 </td>
196
+ <td>61.2 </td>
197
+ <td>33.8 </td>
198
+ <td>29.4 </td>
199
+ <td>51.1 </td>
200
+ <td>- </td>
201
+ </tr>
202
+ <tr>
203
+ <td nowrap="nowrap" align="left" >MobileVLM V2</td>
204
+ <td align="right" >3.1B</td>
205
+ <td>57.5</td>
206
+ <td>19.4*</td>
207
+ <td>-</td>
208
+ <td>-</td>
209
+ <td>1440.5(P) </td>
210
+ <td>63.2 </td>
211
+ <td>-</td>
212
+ <td>-</td>
213
+ <td>-</td>
214
+ <td>-</td>
215
+ <td>-</td>
216
+ </tr>
217
+ <tr>
218
+ <td nowrap="nowrap" align="left" >Mini-Gemini</td>
219
+ <td align="right" >2.2B</td>
220
+ <td>56.2</td>
221
+ <td>34.2*</td>
222
+ <td>-</td>
223
+ <td>-</td>
224
+ <td>1653.0 </td>
225
+ <td>59.8 </td>
226
+ <td>- </td>
227
+ <td>31.7 </td>
228
+ <td>-</td>
229
+ <td>- </td>
230
+ <td>- </td>
231
+ </tr>
232
+ <tr>
233
+ <td nowrap="nowrap" align="left" >MiniCPM-V</td>
234
+ <td align="right" >2.8B </td>
235
+ <td>60.6</td>
236
+ <td>38.2 </td>
237
+ <td>366</td>
238
+ <td>47.6</td>
239
+ <td>1650.2 </td>
240
+ <td>67.9 </td>
241
+ <td>65.3 </td>
242
+ <td><strong>38.3</strong></td>
243
+ <td>28.9</td>
244
+ <td>51.3 </td>
245
+ <td>78.4 / 88.5 </td>
246
+ </tr>
247
+ <tr>
248
+ <td nowrap="nowrap" align="left" ><strong>MiniCPM-V 2.0</strong></td>
249
+ <td align="right" >2.8B </td>
250
+ <td><strong>74.1</strong></td>
251
+ <td><strong>71.9</strong> </td>
252
+ <td><strong>605</strong></td>
253
+ <td><strong>55.0</strong></td>
254
+ <td><strong>1808.6</strong> </td>
255
+ <td><strong>69.6</strong> </td>
256
+ <td><strong>68.1</strong> </td>
257
+ <td>38.2 </td>
258
+ <td><strong>38.7</strong></td>
259
+ <td><strong>69.2</strong> </td>
260
+ <td><strong>85.5 / 92.2 </strong></td>
261
+ </tr>
262
+ </tbody>
263
+ </table>
264
+
265
+ </div>
266
+ * We evaluate the officially released checkpoint by ourselves.
267
+
268
+ </details>
269
+
270
+ ## Examples <!-- omit in toc -->
271
+
272
+ <table align="center">
273
+ <p align="center">
274
+ <img src="assets/minicpmv2-cases_2.png" width=95%/>
275
+ </p>
276
+ </table>
277
+
278
+ We deploy MiniCPM-V 2.0 on end devices. The demo video is the raw screen recording on a Xiaomi 14 Pro without edition.
279
+
280
+ <table align="center">
281
+ <p align="center">
282
+ <img src="assets/gif_cases/station.gif" width=36%/>
283
+ <img src="assets/gif_cases/english_menu.gif" width=36%/>
284
+ </p>
285
+ </table>
286
+
287
+
288
+
289
+
290
+ ## Demo
291
+ Click here to try out the Demo of [MiniCPM-V-2.0](http://120.92.209.146:80).
292
+
293
+ ## Deployment on Mobile Phone
294
+ MiniCPM-V-2.0 can be deployed on mobile phones with Android and Harmony operating systems. 🚀 Try it out [here](https://github.com/OpenBMB/mlc-MiniCPM).
295
+
296
+
297
+ ## Usage
298
+ Inference using Huggingface transformers on Nivdia GPUs or Mac with MPS (Apple silicon or AMD GPUs). Requirements tested on python 3.10:
299
+ ```
300
+ Pillow==10.1.0
301
+ timm==0.9.10
302
+ torch==2.1.2
303
+ torchvision==0.16.2
304
+ transformers==4.36.0
305
+ sentencepiece==0.1.99
306
+ ```
307
+
308
+ ```python
309
+ # test.py
310
+ import torch
311
+ from PIL import Image
312
+ from transformers import AutoModel, AutoTokenizer
313
+
314
+ model = AutoModel.from_pretrained('openbmb/MiniCPM-V-2.0', trust_remote_code=True, torch_dtype=torch.bfloat16)
315
+ # For Nvidia GPUs support BF16 (like A100, H100, RTX3090)
316
+ model = model.to(device='cuda', dtype=torch.bfloat16)
317
+ # For Nvidia GPUs do NOT support BF16 (like V100, T4, RTX2080)
318
+ #model = model.to(device='cuda', dtype=torch.float16)
319
+ # For Mac with MPS (Apple silicon or AMD GPUs).
320
+ # Run with `PYTORCH_ENABLE_MPS_FALLBACK=1 python test.py`
321
+ #model = model.to(device='mps', dtype=torch.float16)
322
+
323
+ tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
324
+ model.eval()
325
+
326
+ image = Image.open('xx.jpg').convert('RGB')
327
+ question = 'What is in the image?'
328
+ msgs = [{'role': 'user', 'content': question}]
329
+
330
+ res, context, _ = model.chat(
331
+ image=image,
332
+ msgs=msgs,
333
+ context=None,
334
+ tokenizer=tokenizer,
335
+ sampling=True,
336
+ temperature=0.7
337
+ )
338
+ print(res)
339
+ ```
340
+
341
+ Please look at [GitHub](https://github.com/OpenBMB/OmniLMM) for more detail about usage.
342
+
343
+
344
+ ## MiniCPM-V 1.0 <!-- omit in toc -->
345
+ Please see the info about MiniCPM-V 1.0 [here](./minicpm_v1.md).
346
+
347
+ ## License
348
+
349
+ #### Model License
350
+ * The code in this repo is released according to [Apache-2.0](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE)
351
+ * The usage of MiniCPM-V's parameters is subject to ["General Model License Agreement - Source Notes - Publicity Restrictions - Commercial License"](https://github.com/OpenBMB/General-Model-License/blob/main/)
352
+ * The parameters are fully open to acedemic research
353
+ * Please contact cpm@modelbest.cn to obtain a written authorization for commercial uses. Free commercial use is also allowed after registration.
354
+
355
+ #### Statement
356
+ * As a LLM, MiniCPM-V generates contents by learning a large mount of texts, but it cannot comprehend, express personal opinions or make value judgement. Anything generated by MiniCPM-V does not represent the views and positions of the model developers
357
+ * 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.