模型概述
模型特點
模型能力
使用案例
🚀 MiniCPM-V-2_6-RK3588-1.1.4
MiniCPM-V-2_6的此版本已轉換為可在RK3588 NPU上運行,採用了['w8a8', 'w8a8_g128', 'w8a8_g256', 'w8a8_g512']量化方式。該模型已使用以下LoRA進行優化:
兼容RKLLM版本:1.1.4
🔗 實用鏈接
- 官方RKLLM GitHub
- RockhipNPU Reddit
- EZRKNN-LLM
- 這些開發者的相關內容:marty1885 和 happyme531
- 轉換工具:ez-er-rkllm-toolkit
📄 原始模型卡片
以下是基礎模型MiniCPM-V-2_6的原始模型卡片:
MiniCPM-V 2.6:適用於手機的單圖像、多圖像和視頻的GPT - 4V級多模態大語言模型
MiniCPM-V 2.6 是MiniCPM-V系列中最新且功能最強大的模型。該模型基於SigLip - 400M和Qwen2 - 7B構建,總參數達80億。與MiniCPM-Llama3-V 2.5相比,其性能有顯著提升,並引入了多圖像和視頻理解的新特性。MiniCPM-V 2.6的顯著特性包括:
- 🔥 卓越性能:在最新版本的OpenCompass綜合評估中,MiniCPM-V 2.6在8個流行基準測試中平均得分達到65.2。僅80億參數的它,在單圖像理解方面超越了廣泛使用的專有模型,如GPT - 4o mini、GPT - 4V、Gemini 1.5 Pro和Claude 3.5 Sonnet。
- 🖼️ 多圖像理解和上下文學習:MiniCPM-V 2.6能夠對多圖像進行對話和推理。在Mantis - Eval、BLINK、Mathverse mv和Sciverse mv等流行的多圖像基準測試中取得了領先的性能,並展現出了良好的上下文學習能力。
- 🎬 視頻理解:MiniCPM-V 2.6可以接受視頻輸入,進行對話併為時空信息提供密集字幕。在有/無字幕的Video - MME測試中,它的表現優於GPT - 4V、Claude 3.5 Sonnet和LLaVA - NeXT - Video - 34B。
- 💪 強大的OCR能力及其他特性:MiniCPM-V 2.6可以處理任意寬高比、像素高達180萬(如1344x1344)的圖像。在OCRBench測試中取得了領先的性能,超越了GPT - 4o、GPT - 4V和Gemini 1.5 Pro等專有模型。基於最新的RLAIF-V和VisCPM技術,它具有可靠的行為,在Object HalBench上的幻覺率顯著低於GPT - 4o和GPT - 4V,並支持英語、中文、德語、法語、意大利語、韓語等多語言能力。
- 🚀 高效性能:除了模型規模友好外,MiniCPM-V 2.6還展現出了領先的令牌密度(即每個視覺令牌編碼的像素數)。處理180萬像素圖像時僅生成640個令牌,比大多數模型少75%。這直接提高了推理速度、首令牌延遲、內存使用效率和功耗。因此,MiniCPM-V 2.6可以在iPad等終端設備上高效支持即時視頻理解。
- 💫 易於使用:MiniCPM-V 2.6可以通過多種方式輕鬆使用:
🔍 評估結果
單圖像評估
在OpenCompass、MME、MMVet、OCRBench、MMMU、MathVista、MMB、AI2D、TextVQA、DocVQA、HallusionBench、Object HalBench等基準測試中的單圖像評估結果如下:

多圖像評估
在Mantis Eval、BLINK Val、Mathverse mv、Sciverse mv、MIRB等基準測試中的多圖像評估結果如下:

視頻評估
在Video - MME和Video - ChatGPT等基準測試中的視頻評估結果如下:

點擊查看TextVQA、VizWiz、VQAv2、OK - VQA的少樣本評估結果。

📷 示例展示





點擊查看更多示例。


我們在終端設備上部署了MiniCPM-V 2.6。演示視頻是在iPad Pro上未經編輯的原始屏幕錄製。




💻 演示體驗
點擊此處嘗試MiniCPM-V 2.6的演示。
💻 使用示例
基礎用法
# test.py
import torch
from PIL import Image
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained('openbmb/MiniCPM-V-2_6', trust_remote_code=True,
attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager
model = model.eval().cuda()
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V-2_6', trust_remote_code=True)
image = Image.open('xx.jpg').convert('RGB')
question = 'What is in the image?'
msgs = [{'role': 'user', 'content': [image, question]}]
res = model.chat(
image=None,
msgs=msgs,
tokenizer=tokenizer
)
print(res)
## if you want to use streaming, please make sure sampling=True and stream=True
## the model.chat will return a generator
res = model.chat(
image=None,
msgs=msgs,
tokenizer=tokenizer,
sampling=True,
stream=True
)
generated_text = ""
for new_text in res:
generated_text += new_text
print(new_text, flush=True, end='')
高級用法
多圖像對話
點擊查看使用多圖像輸入運行MiniCPM-V 2.6的Python代碼。
import torch
from PIL import Image
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained('openbmb/MiniCPM-V-2_6', trust_remote_code=True,
attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager
model = model.eval().cuda()
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V-2_6', trust_remote_code=True)
image1 = Image.open('image1.jpg').convert('RGB')
image2 = Image.open('image2.jpg').convert('RGB')
question = 'Compare image 1 and image 2, tell me about the differences between image 1 and image 2.'
msgs = [{'role': 'user', 'content': [image1, image2, question]}]
answer = model.chat(
image=None,
msgs=msgs,
tokenizer=tokenizer
)
print(answer)
上下文少樣本學習
點擊查看使用少樣本輸入運行MiniCPM-V 2.6的Python代碼。
import torch
from PIL import Image
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained('openbmb/MiniCPM-V-2_6', trust_remote_code=True,
attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager
model = model.eval().cuda()
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V-2_6', trust_remote_code=True)
question = "production date"
image1 = Image.open('example1.jpg').convert('RGB')
answer1 = "2023.08.04"
image2 = Image.open('example2.jpg').convert('RGB')
answer2 = "2007.04.24"
image_test = Image.open('test.jpg').convert('RGB')
msgs = [
{'role': 'user', 'content': [image1, question]}, {'role': 'assistant', 'content': [answer1]},
{'role': 'user', 'content': [image2, question]}, {'role': 'assistant', 'content': [answer2]},
{'role': 'user', 'content': [image_test, question]}
]
answer = model.chat(
image=None,
msgs=msgs,
tokenizer=tokenizer
)
print(answer)
視頻對話
點擊查看使用視頻輸入運行MiniCPM-V 2.6的Python代碼。
import torch
from PIL import Image
from transformers import AutoModel, AutoTokenizer
from decord import VideoReader, cpu # pip install decord
model = AutoModel.from_pretrained('openbmb/MiniCPM-V-2_6', trust_remote_code=True,
attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager
model = model.eval().cuda()
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V-2_6', trust_remote_code=True)
MAX_NUM_FRAMES=64 # if cuda OOM set a smaller number
def encode_video(video_path):
def uniform_sample(l, n):
gap = len(l) / n
idxs = [int(i * gap + gap / 2) for i in range(n)]
return [l[i] for i in idxs]
vr = VideoReader(video_path, ctx=cpu(0))
sample_fps = round(vr.get_avg_fps() / 1) # FPS
frame_idx = [i for i in range(0, len(vr), sample_fps)]
if len(frame_idx) > MAX_NUM_FRAMES:
frame_idx = uniform_sample(frame_idx, MAX_NUM_FRAMES)
frames = vr.get_batch(frame_idx).asnumpy()
frames = [Image.fromarray(v.astype('uint8')) for v in frames]
print('num frames:', len(frames))
return frames
video_path ="video_test.mp4"
frames = encode_video(video_path)
question = "Describe the video"
msgs = [
{'role': 'user', 'content': frames + [question]},
]
# Set decode params for video
params={}
params["use_image_id"] = False
params["max_slice_nums"] = 2 # use 1 if cuda OOM and video resolution > 448*448
answer = model.chat(
image=None,
msgs=msgs,
tokenizer=tokenizer,
**params
)
print(answer)
更多使用細節請查看GitHub。
📦 llama.cpp推理
MiniCPM-V 2.6可以使用llama.cpp運行。更多細節請查看我們的llama.cpp分支。
📦 Int4量化版本
下載Int4量化版本以減少GPU內存(7GB)使用:MiniCPM-V-2_6-int4。
📄 許可證
模型許可證
- 本倉庫中的代碼遵循Apache - 2.0許可證發佈。
- MiniCPM-V系列模型權重的使用必須嚴格遵循MiniCPM模型許可證。
- MiniCPM的模型和權重完全免費用於學術研究。填寫“問卷”進行註冊後,MiniCPM-V 2.6的權重也可免費用於商業用途。
聲明
- 作為一個多模態大語言模型,MiniCPM-V 2.6通過學習大量的多模態語料生成內容,但它無法理解、表達個人觀點或進行價值判斷。MiniCPM-V 2.6生成的任何內容均不代表模型開發者的觀點和立場。
- 我們不對使用MinCPM-V模型所產生的任何問題負責,包括但不限於數據安全問題、輿論風險,或因模型的誤導、誤用、傳播或濫用而產生的任何風險和問題。
🔍 關鍵技術及其他多模態項目
👏 歡迎探索MiniCPM-V 2.6的關鍵技術以及我們團隊的其他多模態項目: VisCPM | RLHF-V | LLaVA-UHD | RLAIF-V
📚 引用
如果您覺得我們的工作有幫助,請考慮引用我們的論文 📝 並給這個項目點贊 ❤️!
@article{yao2024minicpm,
title={MiniCPM-V: A GPT-4V Level MLLM on Your Phone},
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 others},
journal={arXiv preprint arXiv:2408.01800},
year={2024}
}








