匿名用户2024年07月31日
31阅读
开发技术minicpmv、Pytorch
所属分类ai
开源地址https://modelscope.cn/models/OpenBMB/MiniCPM-V

作品详情

MiniCPM-V

News

MiniCPM-V (i.e., OmniLMM-3B) is an efficient version with promising performance for deployment. The model is built based on SigLip-400M and MiniCPM-2.4B, connected by a perceiver resampler. Notable features of OmniLMM-3B include:

  • ⚡️ High Efficiency.

    MiniCPM-V can be efficiently deployed on most GPU cards and personal computers, and even on end devices such as mobile phones. In terms of visual encoding, we compress the image representations into 64 tokens via a perceiver resampler, which is significantly fewer than other LMMs based on MLP architecture (typically > 512 tokens). This allows OmniLMM-3B to operate with much less memory cost and higher speed during inference.

  • ? Promising Performance.

    MiniCPM-V achieves state-of-the-art performance on multiple benchmarks (including MMMU, MME, and MMbech, etc) among models with comparable sizes, surpassing existing LMMs built on Phi-2. It even achieves comparable or better performance than the 9.6B Qwen-VL-Chat.

  • ? Bilingual Support.

    MiniCPM-V is the first end-deployable LMM supporting bilingual multimodal interaction in English and Chinese. This is achieved by generalizing multimodal capabilities across languages, a technique from the ICLR 2024 spotlight paper.

Evaluation

Model Size MME MMB dev (en) MMB dev (zh) MMMU val CMMMU val
LLaVA-Phi 3.0B 1335 59.8 - - -
MobileVLM 3.0B 1289 59.6 - - -
Imp-v1 3B 1434 66.5 - - -
Qwen-VL-Chat 9.6B 1487 60.6 56.7 35.9 30.7
CogVLM 17.4B 1438 63.7 53.8 32.1 -
MiniCPM-V 3B 1452 67.9 65.3 37.2 32.1

Examples

Demo

Click here to try out the Demo of MiniCPM-V.

Deployment on Mobile Phone

Currently MiniCPM-V (i.e., OmniLMM-3B) can be deployed on mobile phones with Android and Harmony operating systems. ? Try it out here.

Usage

Inference using Huggingface transformers on Nivdia GPUs or Mac with MPS (Apple silicon or AMD GPUs). Requirements tested on python 3.10:

Pillow==10.1.0
timm==0.9.10
torch==2.1.2
torchvision==0.16.2
transformers==4.36.0
sentencepiece==0.1.99
# test.py
import torch
from PIL import Image
from modelscope import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True, torch_dtype=torch.bfloat16)
# For Nvidia GPUs support BF16 (like A100, H100, RTX3090)
model = model.to(device='cuda', dtype=torch.bfloat16)
# For Nvidia GPUs do NOT support BF16 (like V100, T4, RTX2080)
#model = model.to(device='cuda', dtype=torch.float16)
# For Mac with MPS (Apple silicon or AMD GPUs).
# Run with `PYTORCH_ENABLE_MPS_FALLBACK=1 python test.py`
#model = model.to(device='mps', dtype=torch.float16)

tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
model.eval()

image = Image.open('xx.jpg').convert('RGB')
question = 'What is in the image?'
msgs = [{'role': 'user', 'content': question}]

answer, context, _ = model.chat(
    image=image,
    msgs=msgs,
    context=None,
    tokenizer=tokenizer,
    sampling=True,
    temperature=0.7
)
print(answer)

License

Model License

  • The code in this repo is released under the Apache-2.0 License.
  • The usage of MiniCPM-V series model weights must strictly follow MiniCPM Model License.md.
  • The models and weights of MiniCPM are completely free for academic research. after filling out a "questionnaire" for registration, are also available for free commercial use.

Statement

  • 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
  • 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.
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论