MiniCPM-o 介绍
了解项目的详细信息和使用方法
端侧可用的 GPT-4o 级视觉、语音、多模态实时流式大模型
MiniCPM-o 是从 MiniCPM-V 升级的最新端侧多模态大模型系列。该系列模型可以以端到端方式,接受图像、视频、文本、音频作为输入,并生成高质量文本和语音输出。自2024年2月以来,我们以实现高性能和高效部署为目标,发布了6个版本的模型。目前系列中最值得关注的模型包括:
-
MiniCPM-o 2.6: 🔥🔥🔥 MiniCPM-o 系列的最新、性能最佳模型。总参数量 8B,视觉、语音和多模态流式能力达到了 GPT-4o-202405 级别,是开源社区中模态支持最丰富、性能最佳的模型之一。在新的语音模式中,MiniCPM-o 2.6 支持可配置声音的中英双语语音对话,还具备情感/语速/风格控制、端到端声音克隆、角色扮演等进阶能力。模型也进一步提升了 MiniCPM-V 2.6 的 OCR、可信行为、多语言支持和视频理解等视觉能力。基于其领先的视觉 token 密度,MiniCPM-V 2.6 成为了首个支持在 iPad 等端侧设备上进行多模态实时流式交互的多模态大模型。
-
MiniCPM-V 2.6: MiniCPM-V 系列中性能最佳的模型。总参数量 8B,单图、多图和视频理解性能超越了 GPT-4V。它取得了优于 GPT-4o mini、Gemini 1.5 Pro 和 Claude 3.5 Sonnet等的单图理解表现,并成为了首个支持在 iPad 等端侧设备上进行实时视频理解的多模态大模型。
MiniCPM-o 2.6
MiniCPM-o 2.6 是 MiniCPM-o 系列的最新、性能最佳模型。该模型基于 SigLip-400M、Whisper-medium-300M、ChatTTS-200M 和 Qwen2.5-7B 构建,共 8B 参数,通过端到端方式训练和推理。相比 MiniCPM-V 2.6,该模型在性能上有了显著提升,并支持了实时语音对话和多模态流式交互的新功能。MiniCPM-o 2.6 的主要特性包括:
-
🔥 领先的视觉能力。 MiniCPM-o 2.6 在 OpenCompass 榜单上(综合 8 个主流多模态评测基准)平均得分 70.2,以 8B 量级的大小在单图理解方面超越了 GPT-4o-202405、Gemini 1.5 Pro 和 Claude 3.5 Sonnet 等主流商用闭源多模态大模型。此外,它的多图和视频理解表现也优于 GPT-4V 和 Claude 3.5 Sonnet,并展现出了优秀的上下文学习能力。
-
🎙 出色的语音能力。 MiniCPM-o 2.6 支持可配置声音的中英双语实时对话。MiniCPM-o 2.6 在语音理解任务(如 ASR 和 STT 等)优于 GPT-4o-realtime,并在语音对话的语义和声学评估中展现了开源模型中最高的语音生成性能。它还支持情绪/语速/风格控制、语音克隆、角色扮演等进阶能力。
-
🎬 强大的多模态流式交互能力。 作为一项新功能,MiniCPM-o 2.6 能够接受连续的视频和音频流,并和用户进行实时语音交互。在针对实时视频理解、全模态视音频理解、多模态上下文理解的综合评测基准 StreamingBench 中,MiniCPM-o 2.6 取得开源社区最佳水平,并超过了 GPT-4o-202408 和 Claude 3.5 Sonnet。
-
💪 强大的 OCR 能力及其他功能。 MiniCPM-o 2.6 进一步优化了 MiniCPM-V 2.6 的众多视觉理解能力,其可以处理任意长宽比的图像,像素数可达 180 万(如 1344x1344)。在 OCRBench 上取得25B 以下最佳水平,超过 GPT-4o-202405 等商用闭源模型。基于最新的 RLHF-V、RLAIF-V 和 VisCPM 技术,其具备了可信的多模态行为,在 MMHal-Bench 上超过了 GPT-4o 和 Claude 3.5,并支持英语、中文、德语、法语、意大利语、韩语等30多种语言。
-
🚀 卓越的效率。 除了对个人用户友好的模型大小,MiniCPM-o 2.6 还表现出最先进的视觉 token 密度(即每个视觉 token 编码的像素数量)。它仅需 640 个 token 即可处理 180 万像素图像,比大多数模型少 75%。这一特性优化了模型的推理速度、首 token 延迟、内存占用和功耗。因此,MiniCPM-o 2.6 可以支持 iPad 等终端设备上的高效多模态实时流式交互。
-
💫 易于使用。
MiniCPM-o 2.6 可以通过多种方式轻松使用:(1) llama.cpp 支持在本地设备上进行高效的 CPU 推理,(2) int4 和 GGUF 格式的量化模型,有 16 种尺寸,(3) vLLM 支持高吞吐量和内存高效的推理,(4) 通过LLaMA-Factory框架针对新领域和任务进行微调,(5) 使用 Gradio 快速设置本地 WebUI 演示,(6) 部署于服务器的在线 demo。
模型架构。
- 端到端全模态架构。 通过端到端的方式连接和训练不同模态的编/解码模块以充分利用丰富的多模态知识。模型完全使用 CE 损失端到端训练。
- 全模态流式机制。 (1) 我们将不同模态的离线编/解码器改造为适用于流式输入/输出的在线模块。 (2) 我们针对大语言模型基座设计了时分复用的全模态流式信息处理机制,将平行的不同模态的信息流拆分重组为周期性时间片序列。
- 可配置的声音方案。 我们设计了新的多模态系统提示,包含传统文本系统提示词,和用于指定模型声音的语音系统提示词。模型可在推理时灵活地通过文字或语音样例控制声音风格,并支持端到端声音克隆和音色创建等高级能力。

性能评估

点击查看视觉理解能力详细评测结果。
图像理解能力
Model | Size | Token Density+ | OpenCompass | OCRBench | MathVista mini | ChartQA | MMVet | MMStar | MME | MMB1.1 test | AI2D | MMMU val | HallusionBench | TextVQA val | DocVQA test | MathVerse mini | MathVision | MMHal Score |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proprietary | ||||||||||||||||||
GPT-4o-20240513 | - | 1088 | 69.9 | 736 | 61.3 | 85.7 | 69.1 | 63.9 | 2328.7 | 82.2 | 84.6 | 69.2 | 55.0 | - | 92.8 | 50.2 | 30.4 | 3.6 |
Claude3.5-Sonnet | - | 750 | 67.9 | 788 | 61.6 | 90.8 | 66.0 | 62.2 | 1920.0 | 78.5 | 80.2 | 65.9 | 49.9 | - | 95.2 | - | - | 3.4 |
Gemini 1.5 Pro | - | - | 64.4 | 754 | 57.7 | 81.3 | 64.0 | 59.1 | 2110.6 | 73.9 | 79.1 | 60.6 | 45.6 | 73.5 | 86.5 | - | 19.2 | - |
GPT-4o-mini-20240718 | - | 1088 | 64.1 | 785 | 52.4 | - | 66.9 | 54.8 | 2003.4 | 76.0 | 77.8 | 60.0 | 46.1 | - | - | - | - | 3.3 |
Open Source | ||||||||||||||||||
Cambrian-34B | 34B | 1820 | 58.3 | 591 | 50.3 | 75.6 | 53.2 | 54.2 | 2049.9 | 77.8 | 79.5 | 50.4 | 41.6 | 76.7 | 75.5 | - | - | - |
GLM-4V-9B | 13B | 784 | 59.1 | 776 | 51.1 | - | 58.0 | 54.8 | 2018.8 | 67.9 | 71.2 | 46.9 | 45.0 | - | - | - | - | - |
Pixtral-12B | 12B | 256 | 61.0 | 685 | 56.9 | 81.8 | 58.5 | 54.5 | - | 72.7 | 79.0 | 51.1 | 47.0 | 75.7 | 90.7 | - | - | - |
DeepSeek-VL2-27B (4B) | 27B | 672 | 66.4 | 809 | 63.9 | 86.0 | 60.0 | 61.9 | 2253.0 | 81.2 | 83.8 | 54.0 | 45.3 | 84.2 | 93.3 | - | - | 3.0 |
Qwen2-VL-7B | 8B | 784 | 67.1 | 866 | 58.2 | 83.0 | 62.0 | 60.7 | 2326.0 | 81.8 | 83.0 | 54.1 | 50.6 | 84.3 | 94.5 | 31.9 | 16.3 | 3.2 |
LLaVA-OneVision-72B | 72B | 182 | 68.1 | 741 | 67.5 | 83.7 | 60.6 | 65.8 | 2261.0 | 85.0 | 85.6 | 56.8 | 49.0 | 80.5 | 91.3 | 39.1 | - | 3.5 |
InternVL2.5-8B | 8B | 706 | 68.3 | 822 | 64.4 | 84.8 | 62.8 | 62.8 | 2344.0 | 83.6 | 84.5 | 56.0 | 50.1 | 79.1 | 93.0 | 39.5 | 19.7 | 3.4 |
MiniCPM-V 2.6 | 8B | 2822 | 65.2 | 852* | 60.6 | 79.4 | 60.0 | 57.5 | 2348.4* | 78.0 | 82.1 | 49.8* | 48.1* | 80.1 | 90.8 | 25.7 | 18.3 | 3.6 |
MiniCPM-o 2.6 | 8B | 2822 | 70.2 | 897* | 71.9* | 86.9* | 67.5 | 64.0 | 2372.0* | 80.5 | 85.8 | 50.4* | 51.9 | 82.0 | 93.5 | 41.4* | 23.1* | 3.8 |
注意:闭源模型的 Token Density 由 API 收费方式估算得到。
多图和视频理解能力
Model | Size | BLINK val | Mantis Eval | MIRB | Video-MME (wo / w subs) |
---|---|---|---|---|---|
Proprietary | |||||
GPT-4o-20240513 | - | 68 | - | - | 71.9/77.2 |
GPT4V | - | 54.6 | 62.7 | 53.1 | 59.9/63.3 |
Open-source | |||||
LLaVA-NeXT-Interleave 14B | 14B | 52.6 | 66.4 | 30.2 | - |
LLaVA-OneVision-72B | 72B | 55.4 | 77.6 | - | 66.2/69.5 |
MANTIS 8B | 8B | 49.1 | 59.5 | 34.8 | - |
Qwen2-VL-7B | 8B | 53.2 | 69.6* | 67.6* | 63.3/69.0 |
InternVL2.5-8B | 8B | 54.8 | 67.7 | 52.5 | 64.2/66.9 |
MiniCPM-V 2.6 | 8B | 53 | 69.1 | 53.8 | 60.9/63.6 |
MiniCPM-o 2.6 | 8B | 56.7 | 71.9 | 58.6 | 63.9/67.9 |
点击查看语音理解和生成能力的详细评测结果。
语音理解能力
Task | Size | ASR (zh) | ASR (en) | AST | Emotion | |||||
---|---|---|---|---|---|---|---|---|---|---|
Metric | CER↓ | WER↓ | BLEU↑ | ACC↑ | ||||||
Dataset | AISHELL-1 | Fleurs zh | WenetSpeech test-net | LibriSpeech test-clean | GigaSpeech | TED-LIUM | CoVoST en2zh | CoVoST zh2en | MELD emotion | |
Proprietary | ||||||||||
GPT-4o-Realtime | - | 7.3* | 5.4* | 28.9* | 2.6* | 12.9* | 4.8* | 37.1* | 15.7* | 33.2* |
Gemini 1.5 Pro | - | 4.5* | 5.9* | 14.3* | 2.9* | 10.6* | 3.0* | 47.3* | 22.6* | 48.4* |
Open-Source | ||||||||||
Qwen2-Audio-7B | 8B | - | 7.5 | - | 1.6 | - | - | 45.2 | 24.4 | 55.3 |
Qwen2-Audio-7B-Instruct | 8B | 2.6* | 6.9* | 10.3* | 3.1* | 9.7* | 5.9* | 39.5* | 22.9* | 17.4* |
GLM-4-Voice-Base | 9B | 2.5 | - | - | 2.8 | - | - | - | - | |
MiniCPM-o 2.6 | 8B | 1.6 | 4.4 | 6.9 | 1.7 | 8.7 | 3.0 | 48.2 | 27.2 | 52.4 |
语音生成能力。
Task | Size | SpeechQA | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Metric | ACC↑ | G-Eval (10 point)↑ | Semantic ELO score↑ | Acoustic ELO score↑ | Overall ELO score↑ | UTMOS↑ | ASR-WER↓ | |||
Dataset | Speech Llama Q. | Speech Web Q. | Speech Trivia QA | Speech AlpacaEval | AudioArena | |||||
Proprietary | ||||||||||
GPT-4o-Realtime | 71.7 | 51.6 | 69.7 | 7.4 | 1157 | 1203 | 1200 | 4.2 | 2.3 | |
Open-Source | ||||||||||
GLM-4-Voice | 9B | 50.0 | 32.0 | 36.4 | 5.1 | 999 | 1147 | 1035 | 4.1 | 11.7 |
Llama-Omni | 8B | 45.3 | 22.9 | 10.7 | 3.9 | 960 | 878 | 897 | 3.2 | 24.3 |
Moshi | 7B | 43.7 | 23.8 | 16.7 | 2.4 | 871 | 808 | 875 | 2.8 | 8.2 |
Mini-Omni | 1B | 22.0 | 12.8 | 6.9 | 2.5 | 926 | 803 | 865 | 3.4 | 10.0 |
MiniCPM-o 2.6 | 8B | 61.0 | 40.0 | 40.2 | 5.1 | 1088 | 1163 | 1131 | 4.2 | 9.8 |
端到端声音克隆能力。
Task | TTS | |
---|---|---|
Metric | SIMO↑ | SIMO↑ |
Dataset | Seed-TTS test-zh | Seed-TTS test-en |
F5-TTS | 76 | 67 |
CosyVoice | 75 | 64 |
FireRedTTS | 63 | 46 |
MiniCPM-o 2.6 | 57 | 47 |
点击查看多模态流式交互能力评测详细结果。
多模态流式交互能力: StreamingBench 分数
Model | Size | Real-Time Video Understanding | Omni-Source Understanding | Contextual Understanding | Overall | |||
---|---|---|---|---|---|---|---|---|
Proprietary | ||||||||
Gemini 1.5 Pro | - | 77.4 | 67.8 | 51.1 | 70.3 | |||
GPT-4o-202408 | - | 74.5 | 51.0 | 48.0 | 64.1 | |||
Claude-3.5-Sonnet | - | 74.0 | 41.4 | 37.8 | 59.7 | |||
Open-source | ||||||||
VILA-1.5 | 8B | 61.5 | 37.5 | 26.7 | 49.5 | |||
LongVA | 7B | 63.1 | 35.9 | 30.2 | 50.7 | |||
LLaVA-Next-Video-34B | 34B | 69.8 | 41.7 | 34.3 | 56.7 | |||
Qwen2-VL-7B | 8B | 71.2 | 40.7 | 33.1 | 57.0 | |||
InternVL2-8B | 8B | 70.1 | 42.7 | 34.1 | 57.0 | |||
VITA-1.5 | 8B | 70.9 | 40.8 | 35.8 | 57.4 | |||
LLaVA-OneVision-7B | 8B | 74.3 | 40.8 | 31.0 | 58.4 | |||
InternLM-XC2.5-OL-7B | 8B | 75.4 | 46.2 | 33.6 | 60.8 | |||
MiniCPM-V 2.6 | 8B | 72.4 | 40.2 | 33.4 | 57.7 | |||
MiniCPM-o 2.6 | 8B | 79.9 | 53.4 | 38.5 | 66.0 |
典型示例
以下为 MiniCPM-o 2.6 的 iPad Pro 实机演示和 web demo 演示样例:



Click to view more details of MiniCPM-V 2.6
MiniCPM-V 2.6
MiniCPM-V 2.6 是 MiniCPM-V 系列中最新、性能最佳的模型。该模型基于 SigLip-400M 和 Qwen2-7B 构建,共 8B 参数。与 MiniCPM-Llama3-V 2.5 相比,MiniCPM-V 2.6 性能提升显著,并引入了多图和视频理解的新功能。MiniCPM-V 2.6 的主要特点包括:
-
🔥 领先的性能。 MiniCPM-V 2.6 在最新版本 OpenCompass 榜单上(综合 8 个主流多模态评测基准)平均得分 65.2,以8B量级的大小在单图理解方面超越了 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 还表现出最先进的视觉 token 密度(即每个视觉 token 编码的像素数量)。它仅需 640 个 token 即可处理 180 万像素图像,比大多数模型少 75%。这一特性优化了模型的推理速度、首 token 延迟、内存占用和功耗。因此,MiniCPM-V 2.6 可以支持 iPad 等终端设备上的高效实时视频理解。
-
💫 易于使用。 MiniCPM-V 2.6 可以通过多种方式轻松使用:(1) llama.cpp 和 ollama 支持在本地设备上进行高效的 CPU 推理,(2) int4 和 GGUF 格式的量化模型,有 16 种尺寸,(3) vLLM 支持高吞吐量和内存高效的推理,(4) 针对新领域和任务进行微调,(5) 使用 Gradio 快速设置本地 WebUI 演示,(6) 在线demo即可体验。
性能评估

点击查看 OpenCompass, MME, MMVet, OCRBench, MMMU, MathVista, MMB, AI2D, TextVQA, DocVQA, HallusionBench, Object HalBench 上的单图评测结果详情。
Model | Size | Token Density+ | OpenCompass | MME | MMVet | OCRBench | MMMU val | MathVista mini | MMB1.1 test | AI2D | TextVQA val | DocVQA test | HallusionBench | Object HalBench |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proprietary | ||||||||||||||
GPT-4o | - | 1088 | 69.9 | 2328.7 | 69.1 | 736 | 69.2 | 61.3 | 82.2 | 84.6 | - | 92.8 | 55.0 | 17.6 |
Claude 3.5 Sonnet | - | 750 | 67.9 | 1920.0 | 66.0 | 788 | 65.9 | 61.6 | 78.5 | 80.2 | - | 95.2 | 49.9 | 13.8 |
Gemini 1.5 Pro | - | - | 64.4 | 2110.6 | 64.0 | 754 | 60.6 | 57.7 | 73.9 | 79.1 | 73.5 | 86.5 | 45.6 | - |
GPT-4o mini | - | 1088 | 64.1 | 2003.4 | 66.9 | 785 | 60.0 | 52.4 | 76.0 | 77.8 | - | - | 46.1 | 12.4 |
GPT-4V | - | 1088 | 63.5 | 2070.2 | 67.5 | 656 | 61.7 | 54.7 | 79.8 | 78.6 | 78.0 | 87.2 | 43.9 | 14.2 |
Step-1V | - | - | 59.5 | 2206.4 | 63.3 | 625 | 49.9 | 44.8 | 78.0 | 79.2 | 71.6 | - | 48.4 | - |
Qwen-VL-Max | - | 784 | 58.3 | 2281.7 | 61.8 | 684 | 52.0 | 43.4 | 74.6 | 75.7 | 79.5 | 93.1 | 41.2 | 13.4 |
Open-source | ||||||||||||||
LLaVA-NeXT-Yi-34B | 34B | 157 | 55.0 | 2006.5 | 50.7 | 574 | 48.8 | 40.4 | 77.8 | 78.9 | 69.3 | - | 34.8 | 12.6 |
Mini-Gemini-HD-34B | 34B | 157 | - | 2141 | 59.3 | 518 | 48.0 | 43.3 | - | 80.5 | 74.1 | 78.9 | - | - |
Cambrian-34B | 34B | 1820 | 58.3 | 2049.9 | 53.2 | 591 | 50.4 | 50.3 | 77.8 | 79.5 | 76.7 | 75.5 | 41.6 | 14.7 |
GLM-4V-9B | 13B | 784 | 59.1 | 2018.8 | 58.0 | 776 | 46.9 | 51.1 | 67.9 | 71.2 | - | - | 45.0 | - |
InternVL2-8B | 8B | 706 | 64.1 | 2215.1 | 54.3 | 794 | 51.2 | 58.3 | 79.4 | 83.6 | 77.4 | 91.6 | 45.0 | 21.3 |
MiniCPM-Llama-V 2.5 | 8B | 1882 | 58.8 | 2024.6 | 52.8 | 725 | 45.8 | 54.3 | 72.0 | 78.4 | 76.6 | 84.8 | 42.4 | 10.3 |
MiniCPM-V 2.6 | 8B | 2822 | 65.2 | 2348.4* | 60.0 | 852* | 49.8* | 60.6 | 78.0 | 82.1 | 80.1 | 90.8 | 48.1* | 8.2 |
+ Token Density:每个视觉 token 在最大分辨率下编码的像素数,即最大分辨率下的像素数 / 视觉 token 数。
注意:闭源模型的 Token Density 由 API 收费方式估算得到。
点击查看 Mantis Eval, BLINK, Mathverse mv, Sciverse mv, MIRB 上的多图评测结果详情。
Model | Size | Mantis Eval | BLINK val | Mathverse mv | Sciverse mv | MIRB |
---|---|---|---|---|---|---|
Proprietary | ||||||
GPT-4V | - | 62.7 | 54.6 | 60.3 | 66.9 | 53.1 |
LLaVA-NeXT-Interleave-14B | 14B | 66.4 | 52.6 | 32.7 | 30.2 | - |
Open-source | ||||||
Emu2-Chat | 37B | 37.8 | 36.2 | - | 27.2 | - |
CogVLM | 17B | 45.2 | 41.1 | - | - | - |
VPG-C | 7B | 52.4 | 43.1 | 24.3 | 23.1 | - |
VILA 8B | 8B | 51.2 | 39.3 | - | 36.5 | - |
InternLM-XComposer-2.5 | 8B | 53.1* | 48.9 | 32.1* | - | 42.5 |
InternVL2-8B | 8B | 59.0* | 50.9 | 30.5* | 34.4* | 56.9* |
MiniCPM-V 2.6 | 8B | 69.1 | 53.0 | 84.9 | 74.9 | 53.8 |
点击查看 Video-MME 和 Video-ChatGPT 上的视频评测结果详情。
Model | Size | Video-MME | Video-ChatGPT | |||||
---|---|---|---|---|---|---|---|---|
w/o subs | w subs | Correctness | Detail | Context | Temporal | Consistency | ||
Proprietary | ||||||||
Claude 3.5 Sonnet | - | 60.0 | 62.9 | - | - | - | - | - |
GPT-4V | - | 59.9 | 63.3 | - | - | - | - | - |
Open-source | ||||||||
LLaVA-NeXT-7B | 7B | - | - | 3.39 | 3.29 | 3.92 | 2.60 | 3.12 |
LLaVA-NeXT-34B | 34B | - | - | 3.29 | 3.23 | 3.83 | 2.51 | 3.47 |
CogVLM2-Video | 12B | - | - | 3.49 | 3.46 | 3.23 | 2.98 | 3.64 |
LongVA | 7B | 52.4 | 54.3 | 3.05 | 3.09 | 3.77 | 2.44 | 3.64 |
InternVL2-8B | 8B | 54.0 | 56.9 | - | - | - | - | - |
InternLM-XComposer-2.5 | 8B | 55.8 | - | - | - | - | - | - |
LLaVA-NeXT-Video | 32B | 60.2 | 63.0 | 3.48 | 3.37 | 3.95 | 2.64 | 3.28 |
MiniCPM-V 2.6 | 8B | 60.9 | 63.6 | 3.59 | 3.28 | 3.93 | 2.73 | 3.62 |
点击查看 TextVQA, VizWiz, VQAv2, OK-VQA上的少样本评测结果详情。
Model | Size | Shot | TextVQA val | VizWiz test-dev | VQAv2 test-dev | OK-VQA val |
---|---|---|---|---|---|---|
Flamingo | 80B | 0* | 35.0 | 31.6 | 56.3 | 40.6 |
4 | 36.5 | 39.6 | 63.1 | 57.4 | ||
8 | 37.3 | 44.8 | 65.6 | 57.5 | ||
IDEFICS | 80B | 0* | 30.9 | 36.0 | 60.0 | 45.2 |
4 | 34.3 | 40.4 | 63.6 | 52.4 | ||
8 | 35.7 | 46.1 | 64.8 | 55.1 | ||
OmniCorpus | 7B | 0* | 43.0 | 49.8 | 63.2 | 45.5 |
4 | 45.4 | 51.3 | 64.5 | 46.5 | ||
8 | 45.6 | 52.2 | 64.7 | 46.6 | ||
Emu2 | 37B | 0 | 26.4 | 40.4 | 33.5 | 26.7 |
4 | 48.2 | 54.6 | 67.0 | 53.2 | ||
8 | 49.3 | 54.7 | 67.8 | 54.1 | ||
MM1 | 30B | 0 | 26.2 | 40.4 | 48.9 | 26.7 |
8 | 49.3 | 54.7 | 70.9 | 54.1 | ||
MiniCPM-V 2.6+ | 8B | 0 | 43.9 | 33.8 | 45.4 | 23.9 |
4 | 63.6 | 60.5 | 65.5 | 50.1 | ||
8 | 64.6 | 63.4 | 68.2 | 51.4 |
+ 我们在没有进行监督微调 (SFT) 的情况下评估预训练的模型权重 (ckpt)。
典型示例





点击查看更多示例。


我们将 MiniCPM-V 2.6 部署在iPad Pro上,并录制了以下演示视频。
Chat with Our Demo on Gradio 🤗
我们提供由 Hugging Face Gradio 支持的在线和本地 Demo。Gradio 是目前最流行的模型部署框架,支持流式输出、进度条、process bars 和其他常用功能。
Online Demo
欢迎试用 Online Demo: MiniCPM-V 2.6 | MiniCPM-Llama3-V 2.5 | MiniCPM-V 2.0 。
本地 WebUI Demo
您可以使用以下命令轻松构建自己的本地 WebUI Demo, 体验实时流式视频/语音通话。
- 启动model server:
shell1pip install -r requirements_o2.6.txt 2 3python web_demos/minicpm-o_2.6/model_server.py
请确保 transformers==4.44.2
,其他版本目前可能会有兼容性问题,我们正在解决。
如果你使用的低版本的 Pytorch,你可能会遇到这个错误"weight_norm_fwd_first_dim_kernel" not implemented for 'BFloat16'
, 请在模型初始化的时候添加 self.minicpmo_model.tts.float()
- 启动web server:
shell1# Make sure Node and PNPM is installed. 2sudo apt-get update 3sudo apt-get install nodejs npm 4npm install -g pnpm 5 6 7cd web_demos/minicpm-o_2.6/web_server 8# 为https创建自签名证书, 要申请浏览器摄像头和麦克风权限须启动https. 9bash ./make_ssl_cert.sh # output key.pem and cert.pem 10 11pnpm install # install requirements 12pnpm run dev # start server
推理
模型库
模型 | 设备 | 资源 | 简介 | 下载链接 |
---|---|---|---|---|
MiniCPM-o 2.6 | GPU | 18 GB | 最新版本,提供端侧 GPT-4o 级的视觉、语音、多模态流式交互能力。 | 🤗 ![]() |
MiniCPM-o 2.6 gguf | CPU | 8 GB | gguf 版本,更低的内存占用和更高的推理效率。 | 🤗 ![]() |
MiniCPM-o 2.6 int4 | GPU | 9 GB | int4量化版,更低显存占用。 | 🤗 ![]() |
MiniCPM-V 2.6 | GPU | 17 GB | 提供出色的端侧单图、多图、视频理解能力。 | 🤗 ![]() |
MiniCPM-V 2.6 gguf | CPU | 6 GB | gguf 版本,更低的内存占用和更高的推理效率。 | 🤗 ![]() |
MiniCPM-V 2.6 int4 | GPU | 7 GB | int4量化版,更低显存占用。 | 🤗 ![]() |
更多历史版本模型
多轮对话
请确保 transformers==4.44.2
,其他版本目前可能会有兼容性问题
shell1pip install -r requirements_o2.6.txt

python1import torch 2from PIL import Image 3from transformers import AutoModel, AutoTokenizer 4 5torch.manual_seed(100) 6 7model = AutoModel.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True, 8 attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager 9model = model.eval().cuda() 10tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True) 11 12image = Image.open('./assets/minicpmo2_6/show_demo.jpg').convert('RGB') 13 14# First round chat 15question = "What is the landform in the picture?" 16msgs = [{'role': 'user', 'content': [image, question]}] 17 18answer = model.chat( 19 msgs=msgs, 20 tokenizer=tokenizer 21) 22print(answer) 23 24# Second round chat, pass history context of multi-turn conversation 25msgs.append({"role": "assistant", "content": [answer]}) 26msgs.append({"role": "user", "content": ["What should I pay attention to when traveling here?"]}) 27 28answer = model.chat( 29 msgs=msgs, 30 tokenizer=tokenizer 31) 32print(answer)
你可以得到如下推理结果:
"The landform in the picture is a mountain range. The mountains appear to be karst formations, characterized by their steep, rugged peaks and smooth, rounded shapes. These types of mountains are often found in regions with limestone bedrock and are shaped by processes such as erosion and weathering. The reflection of the mountains in the water adds to the scenic beauty of the landscape."
"When traveling to this scenic location, it's important to pay attention to the weather conditions, as the area appears to be prone to fog and mist, especially during sunrise or sunset. Additionally, ensure you have proper footwear for navigating the potentially slippery terrain around the water. Lastly, respect the natural environment by not disturbing the local flora and fauna."
多图对话
点击查看 MiniCPM-o 2.6 多图输入的 Python 代码。
python1import torch 2from PIL import Image 3from transformers import AutoModel, AutoTokenizer 4 5model = AutoModel.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True, 6 attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager 7model = model.eval().cuda() 8tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True) 9 10image1 = Image.open('image1.jpg').convert('RGB') 11image2 = Image.open('image2.jpg').convert('RGB') 12question = 'Compare image 1 and image 2, tell me about the differences between image 1 and image 2.' 13 14msgs = [{'role': 'user', 'content': [image1, image2, question]}] 15 16answer = model.chat( 17 msgs=msgs, 18 tokenizer=tokenizer 19) 20print(answer)
少样本上下文对话
点击查看 MiniCPM-o 2.6 少样本上下文对话的 Python 代码。
python1import torch 2from PIL import Image 3from transformers import AutoModel, AutoTokenizer 4 5model = AutoModel.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True, 6 attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager 7model = model.eval().cuda() 8tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True) 9 10question = "production date" 11image1 = Image.open('example1.jpg').convert('RGB') 12answer1 = "2023.08.04" 13image2 = Image.open('example2.jpg').convert('RGB') 14answer2 = "2007.04.24" 15image_test = Image.open('test.jpg').convert('RGB') 16 17msgs = [ 18 {'role': 'user', 'content': [image1, question]}, {'role': 'assistant', 'content': [answer1]}, 19 {'role': 'user', 'content': [image2, question]}, {'role': 'assistant', 'content': [answer2]}, 20 {'role': 'user', 'content': [image_test, question]} 21] 22 23answer = model.chat( 24 msgs=msgs, 25 tokenizer=tokenizer 26) 27print(answer)
视频对话
点击查看 MiniCPM-o 2.6 视频输入的 Python 代码。
python1import torch 2from PIL import Image 3from transformers import AutoModel, AutoTokenizer 4from decord import VideoReader, cpu # pip install decord 5 6model = AutoModel.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True, 7 attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager 8model = model.eval().cuda() 9tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True) 10 11MAX_NUM_FRAMES=64 # if cuda OOM set a smaller number 12 13def encode_video(video_path): 14 def uniform_sample(l, n): 15 gap = len(l) / n 16 idxs = [int(i * gap + gap / 2) for i in range(n)] 17 return [l[i] for i in idxs] 18 19 vr = VideoReader(video_path, ctx=cpu(0)) 20 sample_fps = round(vr.get_avg_fps() / 1) # FPS 21 frame_idx = [i for i in range(0, len(vr), sample_fps)] 22 if len(frame_idx) > MAX_NUM_FRAMES: 23 frame_idx = uniform_sample(frame_idx, MAX_NUM_FRAMES) 24 frames = vr.get_batch(frame_idx).asnumpy() 25 frames = [Image.fromarray(v.astype('uint8')) for v in frames] 26 print('num frames:', len(frames)) 27 return frames 28 29video_path="video_test.mp4" 30frames = encode_video(video_path) 31question = "Describe the video" 32msgs = [ 33 {'role': 'user', 'content': frames + [question]}, 34] 35 36# Set decode params for video 37params = {} 38params["use_image_id"] = False 39params["max_slice_nums"] = 2 # use 1 if cuda OOM and video resolution > 448*448 40 41answer = model.chat( 42 msgs=msgs, 43 tokenizer=tokenizer, 44 **params 45) 46print(answer)
语音对话
初始化模型
python1import torch 2import librosa 3from transformers import AutoModel, AutoTokenizer 4 5model = AutoModel.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True, 6 attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa or flash_attention_2, no eager 7model = model.eval().cuda() 8tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True) 9 10model.init_tts() 11model.tts.float()
Mimick
点击查看 MiniCPM-o 2.6 端到端语音理解生成的 Python 代码。
Mimick
任务反映了模型的端到端语音建模能力。模型接受音频输入,输出语音识别(ASR)转录结果,并随后以高相似度重建原始音频。重建的音频相似度和原始音频越高,表明模型有越高的语音端到端建模基础能力。
python1mimick_prompt = "Please repeat each user's speech, including voice style and speech content." 2audio_input, _ = librosa.load('xxx.wav', sr=16000, mono=True) 3msgs = [{'role': 'user', 'content': [mimick_prompt,audio_input]}] 4res = model.chat( 5 msgs=msgs, 6 tokenizer=tokenizer, 7 sampling=True, 8 max_new_tokens=128, 9 use_tts_template=True, 10 temperature=0.3, 11 generate_audio=True, 12 output_audio_path='output.wav', # save the tts result to output_audio_path 13)
可配置声音的语音对话
点击查看个性化配置 MiniCPM-o 2.6 对话声音的 Python 代码。
python1ref_audio, _ = librosa.load('./assets/voice_01.wav', sr=16000, mono=True) # load the reference audio 2 3# Audio RolePlay: # With this mode, model will role-play the character based on the audio prompt. 4sys_prompt = model.get_sys_prompt(ref_audio=ref_audio, mode='audio_roleplay', language='en') 5user_question = {'role': 'user', 'content': [librosa.load('xxx.wav', sr=16000, mono=True)[0]]} 6 7# Audio Assistant: # With this mode, model will speak with the voice in ref_audio as a AI assistant. 8# sys_prompt = model.get_sys_prompt(ref_audio=ref_audio, mode='audio_assistant', language='en') 9# user_question = {'role': 'user', 'content': [librosa.load('xxx.wav', sr=16000, mono=True)[0]]} # Try to ask something!
python1msgs = [sys_prompt, user_question] 2res = model.chat( 3 msgs=msgs, 4 tokenizer=tokenizer, 5 sampling=True, 6 max_new_tokens=128, 7 use_tts_template=True, 8 generate_audio=True, 9 temperature=0.3, 10 output_audio_path='result.wav', 11) 12 13# round two 14history = msgs.append({'role': 'assistant', 'content': res}) 15user_question = {'role': 'user', 'content': [librosa.load('xxx.wav', sr=16000, mono=True)[0]]} 16msgs = history.append(user_question) 17res = model.chat( 18 msgs=msgs, 19 tokenizer=tokenizer, 20 sampling=True, 21 max_new_tokens=128, 22 use_tts_template=True, 23 generate_audio=True, 24 temperature=0.3, 25 output_audio_path='result_round_2.wav', 26) 27print(res)
更多语音任务
点击查看 MiniCPM-o 2.6 完成更多语音任务的 Python 代码。
python1''' 2Audio Understanding Task Prompt: 3Speech: 4 ASR with ZH(same as AST en2zh): 请仔细听这段音频片段,并将其内容逐字记录。 5 ASR with EN(same as AST zh2en): Please listen to the audio snippet carefully and transcribe the content. 6 Speaker Analysis: Based on the speaker's content, speculate on their gender, condition, age range, and health status. 7General Audio: 8 Audio Caption: Summarize the main content of the audio. 9 Sound Scene Tagging: Utilize one keyword to convey the audio's content or the associated scene. 10''' 11task_prompt = "\n" 12audio_input, _ = librosa.load('xxx.wav', sr=16000, mono=True) 13 14msgs = [{'role': 'user', 'content': [task_prompt,audio_input]}] 15 16res = model.chat( 17 msgs=msgs, 18 tokenizer=tokenizer, 19 sampling=True, 20 max_new_tokens=128, 21 use_tts_template=True, 22 generate_audio=True, 23 temperature=0.3, 24 output_audio_path='result.wav', 25) 26print(res)
python1''' 2Speech Generation Task Prompt: 3 Human Instruction-to-Speech: see https://voxinstruct.github.io/VoxInstruct/ 4 Example: 5 # 在新闻中,一个年轻男性兴致勃勃地说:“祝福亲爱的祖国母亲美丽富强!”他用低音调和低音量,慢慢地说出了这句话。 6 # Delighting in a surprised tone, an adult male with low pitch and low volume comments:"One even gave my little dog a biscuit" This dialogue takes place at a leisurely pace, delivering a sense of excitement and surprise in the context. 7 8 Voice Cloning or Voice Creation: With this mode, model will act like a TTS model. 9''' 10# Human Instruction-to-Speech: 11task_prompt = '' #Try to make some Human Instruction-to-Speech prompt 12msgs = [{'role': 'user', 'content': [task_prompt]}] # you can try to use the same audio question 13 14# Voice Cloning mode: With this mode, model will act like a TTS model. 15# sys_prompt = model.get_sys_prompt(ref_audio=ref_audio, mode='voice_cloning', language='en') 16# text_prompt = f"Please read the text below." 17# user_question = {'role': 'user', 'content': [text_prompt, "content that you want to read"]} # using same voice in sys_prompt to read the text. (Voice Cloning) 18# user_question = {'role': 'user', 'content': [text_prompt, librosa.load('xxx.wav', sr=16000, mono=True)[0]]} # using same voice in sys_prompt to read 'xxx.wav'. (Voice Creation) 19 20msgs = [sys_prompt, user_question] 21res = model.chat( 22 msgs=msgs, 23 tokenizer=tokenizer, 24 sampling=True, 25 max_new_tokens=128, 26 use_tts_template=True, 27 generate_audio=True, 28 temperature=0.3, 29 output_audio_path='result.wav', 30) 31 32
多模态流式交互
点击查看 MiniCPM-o 2.6 多模态流式交互的 Python 代码。
python1import math 2import numpy as np 3from PIL import Image 4from moviepy.editor import VideoFileClip 5import tempfile 6import librosa 7import soundfile as sf 8import torch 9from transformers import AutoModel, AutoTokenizer 10 11def get_video_chunk_content(video_path, flatten=True): 12 video = VideoFileClip(video_path) 13 print('video_duration:', video.duration) 14 15 with tempfile.NamedTemporaryFile(suffix=".wav", delete=True) as temp_audio_file: 16 temp_audio_file_path = temp_audio_file.name 17 video.audio.write_audiofile(temp_audio_file_path, codec="pcm_s16le", fps=16000) 18 audio_np, sr = librosa.load(temp_audio_file_path, sr=16000, mono=True) 19 num_units = math.ceil(video.duration) 20 21 # 1 frame + 1s audio chunk 22 contents= [] 23 for i in range(num_units): 24 frame = video.get_frame(i+1) 25 image = Image.fromarray((frame).astype(np.uint8)) 26 audio = audio_np[sr*i:sr*(i+1)] 27 if flatten: 28 contents.extend(["<unit>", image, audio]) 29 else: 30 contents.append(["<unit>", image, audio]) 31 32 return contents 33 34 35model = AutoModel.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True, 36 attn_implementation='sdpa', torch_dtype=torch.bfloat16) 37model = model.eval().cuda() 38tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True) 39 40model.init_tts() 41 42# If you are using an older version of PyTorch, you might encounter this issue "weight_norm_fwd_first_dim_kernel" not implemented for 'BFloat16', Please convert the TTS to float32 type. 43# model.tts.float() 44 45# https://huggingface.co/openbmb/MiniCPM-o-2_6/blob/main/assets/Skiing.mp4 46video_path="assets/Skiing.mp4" 47sys_msg = model.get_sys_prompt(mode='omni', language='en') 48# if use voice clone prompt, please set ref_audio 49# ref_audio_path = '/path/to/ref_audio' 50# ref_audio, _ = librosa.load(ref_audio_path, sr=16000, mono=True) 51# sys_msg = model.get_sys_prompt(ref_audio=ref_audio, mode='omni', language='en') 52 53contents = get_video_chunk_content(video_path) 54msg = {"role":"user", "content": contents} 55msgs = [sys_msg, msg] 56 57# please set generate_audio=True and output_audio_path to save the tts result 58generate_audio = True 59output_audio_path = 'output.wav' 60 61res = model.chat( 62 msgs=msgs, 63 tokenizer=tokenizer, 64 sampling=True, 65 temperature=0.5, 66 max_new_tokens=4096, 67 omni_input=True, # please set omni_input=True when omni inference 68 use_tts_template=True, 69 generate_audio=generate_audio, 70 output_audio_path=output_audio_path, 71 max_slice_nums=1, 72 use_image_id=False, 73 return_dict=True 74) 75print(res)
点击查看多模态流式推理设置。
注意:流式推理存在轻微的性能下降,因为音频编码并非全局的。
python1# a new conversation need reset session first, it will reset the kv-cache 2model.reset_session() 3 4contents = get_video_chunk_content(video_path, flatten=False) 5session_id = '123' 6generate_audio = True 7 8# 1. prefill system prompt 9res = model.streaming_prefill( 10 session_id=session_id, 11 msgs=[sys_msg], 12 tokenizer=tokenizer 13) 14 15# 2. prefill video/audio chunks 16for content in contents: 17 msgs = [{"role":"user", "content": content}] 18 res = model.streaming_prefill( 19 session_id=session_id, 20 msgs=msgs, 21 tokenizer=tokenizer 22 ) 23 24# 3. generate 25res = model.streaming_generate( 26 session_id=session_id, 27 tokenizer=tokenizer, 28 temperature=0.5, 29 generate_audio=generate_audio 30) 31 32audios = [] 33text = "" 34 35if generate_audio: 36 for r in res: 37 audio_wav = r.audio_wav 38 sampling_rate = r.sampling_rate 39 txt = r.text 40 41 audios.append(audio_wav) 42 text += txt 43 44 res = np.concatenate(audios) 45 sf.write("output.wav", res, samplerate=sampling_rate) 46 print("text:", text) 47 print("audio saved to output.wav") 48else: 49 for r in res: 50 text += r['text'] 51 print("text:", text)
多卡推理
您可以通过将模型的层分布在多个低显存显卡(12 GB 或 16 GB)上,运行 MiniCPM-Llama3-V 2.5。请查看该教程,详细了解如何使用多张低显存显卡载入模型并进行推理。
Mac 推理
点击查看 MiniCPM-Llama3-V 2.5 / MiniCPM-V 2.0 基于Mac MPS运行 (Apple silicon 或 AMD GPUs)的示例。
python1# test.py Need more than 16GB memory to run. 2import torch 3from PIL import Image 4from transformers import AutoModel, AutoTokenizer 5 6model = AutoModel.from_pretrained('openbmb/MiniCPM-Llama3-V-2_5', trust_remote_code=True, low_cpu_mem_usage=True) 7model = model.to(device='mps') 8 9tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-Llama3-V-2_5', trust_remote_code=True) 10model.eval() 11 12image = Image.open('./assets/hk_OCR.jpg').convert('RGB') 13question = 'Where is this photo taken?' 14msgs = [{'role': 'user', 'content': question}] 15 16answer, context, _ = model.chat( 17 image=image, 18 msgs=msgs, 19 context=None, 20 tokenizer=tokenizer, 21 sampling=True 22) 23print(answer)
运行:
shell1PYTORCH_ENABLE_MPS_FALLBACK=1 python test.py
手机端部署
MiniCPM-V 2.0 可运行在Android手机上,点击MiniCPM-V 2.0安装apk使用;
基于 llama.cpp、ollama、vLLM 的高效推理
llama.cpp 用法请参考我们的fork llama.cpp, 在iPad上可以支持 16~18 token/s 的流畅推理(测试环境:iPad Pro + M4)。
ollama 用法请参考我们的fork ollama, 在iPad上可以支持 16~18 token/s 的流畅推理(测试环境:iPad Pro + M4)。
点击查看, vLLM 现已官方支持MiniCPM-V 2.6、MiniCPM-Llama3-V 2.5 和 MiniCPM-V 2.0,MiniCPM-o 2.6 模型也可以临时用我们的 fork 仓库运行。
1. MiniCPM-o 2.6 1. 克隆我们的 vLLM fork 仓库: ```shell git clone https://github.com/OpenBMB/vllm.git cd vllm git checkout minicpmo ``` 2. 从源码进行安装: ```shell VLLM_USE_PRECOMPILED=1 pip install --editable . ``` 3. 用和之前同样的方式运行(下有样例).- 之前版本的 MiniCPM-V
- 安装 vLLM(>=0.5.4):
shell1pip install vllm
- 安装 timm 库: (可选,MiniCPM-V 2.0需安装)
shell1pip install timm=0.9.10
- 运行示例代码:(注意:如果使用本地路径的模型,请确保模型代码已更新到Hugging Face上的最新版)
python1from transformers import AutoTokenizer 2from PIL import Image 3from vllm import LLM, SamplingParams 4 5MODEL_NAME = "openbmb/MiniCPM-V-2_6" 6# MODEL_NAME = "openbmb/MiniCPM-O-2_6" 7# Also available for previous models 8# MODEL_NAME = "openbmb/MiniCPM-Llama3-V-2_5" 9# MODEL_NAME = "HwwwH/MiniCPM-V-2" 10 11image = Image.open("xxx.png").convert("RGB") 12tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True) 13llm = LLM( 14 model=MODEL_NAME, 15 trust_remote_code=True, 16 gpu_memory_utilization=1, 17 max_model_len=2048 18) 19 20messages = [{ 21 "role": 22 "user", 23 "content": 24 # Number of images 25 "(<image>./</image>)" + \ 26 "\nWhat is the content of this image?" 27}] 28prompt = tokenizer.apply_chat_template( 29 messages, 30 tokenize=False, 31 add_generation_prompt=True 32) 33 34# Single Inference 35inputs = { 36 "prompt": prompt, 37 "multi_modal_data": { 38 "image": image 39 # Multi images, the number of images should be equal to that of `(<image>./</image>)` 40 # "image": [image, image] 41 }, 42} 43# Batch Inference 44# inputs = [{ 45# "prompt": prompt, 46# "multi_modal_data": { 47# "image": image 48# }, 49# } for _ in 2] 50 51 52# 2.6 53stop_tokens = ['<|im_end|>', '<|endoftext|>'] 54stop_token_ids = [tokenizer.convert_tokens_to_ids(i) for i in stop_tokens] 55# 2.0 56# stop_token_ids = [tokenizer.eos_id] 57# 2.5 58# stop_token_ids = [tokenizer.eos_id, tokenizer.eot_id] 59 60sampling_params = SamplingParams( 61 stop_token_ids=stop_token_ids, 62 use_beam_search=True, 63 temperature=0, 64 best_of=3, 65 max_tokens=1024 66) 67 68outputs = llm.generate(inputs, sampling_params=sampling_params) 69 70print(outputs[0].outputs[0].text)
- 点击此处查看带视频推理和其他有关
vLLM
的信息。
微调
简易微调
我们支持使用 Huggingface Transformers 库简易地微调 MiniCPM-o 2.6、MiniCPM-V 2.6、MiniCPM-Llama3-V 2.5 和 MiniCPM-V 2.0 模型。
使用 LLaMA-Factory
我们支持使用 LLaMA-Factory 微调 MiniCPM-o-2.6 和 MiniCPM-V 2.6。LLaMA-Factory 提供了一种灵活定制 200 多个大型语言模型(LLM)微调(Lora/Full/Qlora)解决方案,无需编写代码,通过内置的 Web 用户界面 LLaMABoard 即可实现训练/推理/评估。它支持多种训练方法,如 sft/ppo/dpo/kto,并且还支持如 Galore/BAdam/LLaMA-Pro/Pissa/LongLoRA 等高级算法。
最佳实践: MiniCPM-o-2.6 | MiniCPM-V-2.6.
使用 SWIFT 框架
我们支持使用 SWIFT 框架微调 MiniCPM-V 系列模型。SWIFT 支持近 200 种大语言模型和多模态大模型的训练、推理、评测和部署。支持 PEFT 提供的轻量训练方案和完整的 Adapters 库支持的最新训练技术如 NEFTune、LoRA+、LLaMA-PRO 等。
参考文档:MiniCPM-V 1.0,MiniCPM-V 2.0 MiniCPM-V 2.6.
FAQs
点击查看 FAQs
模型局限性
我们实验发现 MiniCPM-o 2.6 存在一些显著的局限性,需要进一步研究和改进:
- 不稳定的语音输出。 语音生成可能会受到背景噪音和无意义声音的影响,表现不稳定。
- 重复响应。 当遇到连续相似的用户请求时,模型往往会重复相同的回答。
- Web Demo 延迟较高。 用户在使用远程服务器上部署的 web demo 时可能会产生较高延迟。我们推荐用户在本地部署来获得更低延迟的体验。
模型协议
- 本仓库中代码依照 Apache-2.0 协议开源
- MiniCPM-o/V 模型权重的使用则需要遵循 “MiniCPM模型商用许可协议.md”。
- MiniCPM 模型权重对学术研究完全开放,在填写“问卷”进行登记后亦允许免费商业使用。
声明
作为多模态大模型,MiniCPM-o/V 系列模型(包括 OmniLMM)通过学习大量的多模态数据来生成内容,但它无法理解、表达个人观点或价值判断,它所输出的任何内容都不代表模型开发者的观点和立场。
因此用户在使用本项目的系列模型生成的内容时,应自行负责对其进行评估和验证。如果由于使用本项目的系列开源模型而导致的任何问题,包括但不限于数据安全问题、公共舆论风险,或模型被误导、滥用、传播或不当利用所带来的任何风险和问题,我们将不承担任何责任。
机构
本项目由以下机构共同开发: