OpenBMB 开源社区/MiniCPM-V-4.6
模型介绍
文件和版本
Pull Requests
讨论
分析

一款口袋级多模态大模型(MLLM),让你的手机也能实现超高效图像与视频理解

GitHub | MiniCPM 维基百科(中文) | CookBook | Demo | 飞书

新闻动态

  • [2026.05.17] ⭐️⭐️⭐️ 我们正式发布了 MiniCPM-V 4.6 的 API 服务,并同步提供公开免费的 API 密钥!立即体验它。

MiniCPM-V 4.6

MiniCPM-V 4.6 是我们迄今为止最便于边缘部署的模型。该模型基于 SigLIP2-400M 和 Qwen3.5-0.8B 语言模型构建,继承了 MiniCPM-V 系列在单图、多图及视频理解方面的强大能力,同时显著提升了计算效率。此外,它还引入了 4 倍/16 倍混合视觉令牌压缩机制。MiniCPM-V 4.6 的突出特性包括:

  • 🔥 领先的基础能力。 MiniCPM-V 4.6 在 Artificial Analysis 智能指数评测中斩获 13 分,超越 Qwen3.5-0.8B 的 10 分,且令牌成本降低 19 倍;也优于 Qwen3.5-0.8B-Thinking 的 11 分,令牌成本降低 43 倍。同时,它还超越了参数量更大的 Ministral 3 3B(得分 11)。

  • 💪 强大的多模态能力。 MiniCPM-V 4.6 在绝大多数视觉-语言理解任务上优于 Qwen3.5-0.8B,并在 OpenCompass、RefCOCO、HallusionBench、MUIRBench 和 OCRBench 等多个基准测试中达到 Qwen3.5 2B 级别的能力水平。

  • 🚀 超高效架构。 基于 LLaVA-UHD v4 的最新技术,MiniCPM-V 4.6 将视觉编码的计算量(FLOPs)降低了 50% 以上。这使得 MiniCPM-V 4.6 在效率上甚至优于更小的模型,其令牌吞吐量约为 Qwen3.5-0.8B 的 1.5 倍。它还支持 4 倍/16 倍混合视觉令牌压缩率,可在精度与速度之间灵活切换。

  • 📱 广泛的移动平台覆盖。 MiniCPM-V 4.6 可部署于 iOS、Android 和 HarmonyOS 三大主流移动平台。所有边缘适配代码均已开源,开发者只需几步操作即可复现端侧体验。

  • 🛠️ 开发者友好。 MiniCPM-V 4.6 已适配 vLLM、SGLang、llama.cpp、Ollama 等推理框架,并支持 SWIFT 和 LLaMA-Factory 等微调生态。开发者可在消费级 GPU 上快速为全新领域和任务定制模型。我们提供了覆盖 GGUF、BNB、AWQ 和 GPTQ 格式的多种量化版本。

评测

整体性能(指令模型)

点击查看 MiniCPM-V 4.6-Thinking 性能表现

高并发吞吐量

单请求 TTFT(首令牌延迟,毫秒)

应用示例

总览

MiniCPM-V 4.6 可部署于三大主流端侧平台——iOS、Android 与 HarmonyOS。以下片段均为手机真机录屏,未经任何后期处理。

iPhone
iPhone 17 Pro Max
Android
Redmi K70
HarmonyOS
HUAWEI nova 14

使用方法

基于 Transformers 进行推理

安装
pip install "transformers[torch]>=5.7.0" torchvision torchcodec

关于 CUDA 兼容性的说明: torchcodec(用于视频解码)可能与某些 CUDA 版本存在兼容性问题。例如,torch>=2.11 默认捆绑 CUDA 13.1,而使用 CUDA 12.x 的环境可能会遇到类似 RuntimeError: Could not load libtorchcodec 的错误。有两种解决方法:

  1. 将 torchcodec 替换为 PyAV — 支持图像和视频推理,且不受 CUDA 版本限制:
    pip install "transformers[torch]>=5.7.0" torchvision av
  2. 固定 torch 的 CUDA 版本,使其与你的环境匹配(例如 CUDA 12.8):
    pip install "transformers>=5.7.0" torchvision torchcodec --index-url https://download.pytorch.org/whl/cu128
加载模型
from transformers import AutoModelForImageTextToText, AutoProcessor

model_id = "openbmb/MiniCPM-V-4.6"

processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(
    model_id, torch_dtype="auto", device_map="auto"
)

# Flash Attention 2 is recommended for better acceleration and memory saving,
# especially in multi-image and video scenarios.
# model = AutoModelForImageTextToText.from_pretrained(
#     model_id,
#     torch_dtype=torch.bfloat16,
#     attn_implementation="flash_attention_2",
#     device_map="auto",
# )
图像推理
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/refract.png"},
            {"type": "text", "text": "What causes this phenomenon?"},
        ],
    }
]

downsample_mode = "16x"  # Using `downsample_mode="4x"` for Finer Detail

inputs = processor.apply_chat_template(
    messages, tokenize=True, add_generation_prompt=True,
    return_dict=True, return_tensors="pt",
    downsample_mode=downsample_mode,
    max_slice_nums=36,
).to(model.device)

generated_ids = model.generate(**inputs, downsample_mode=downsample_mode, max_new_tokens=512)
generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
    generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text[0])
视频推理
messages = [
    {
        "role": "user",
        "content": [
            {"type": "video", "url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/football.mp4"},
            {"type": "text", "text": "Describe this video in detail. Follow the timeline and focus on on-screen text, interface changes, main actions, and scene changes."},
        ],
    }
]

downsample_mode = "16x"  # Using `downsample_mode="4x"` for Finer Detail

inputs = processor.apply_chat_template(
    messages, tokenize=True, add_generation_prompt=True,
    return_dict=True, return_tensors="pt",
    downsample_mode=downsample_mode,
    max_num_frames=128,
    stack_frames=1,
    max_slice_nums=1,
    use_image_id=False,
).to(model.device)

generated_ids = model.generate(**inputs, downsample_mode=downsample_mode, max_new_tokens=2048)
generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
    generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text[0])
高级参数

您可以通过向 apply_chat_template 传递额外参数来自定义图像/视频处理:

参数默认值适用范围说明
downsample_mode"16x"图像与视频视觉令牌下采样。"16x" 合并令牌以提升效率;"4x" 保留 4 倍令牌以呈现更精细的细节。该参数也必须传递给 generate()。
max_slice_nums9图像与视频对高分辨率图像进行切分时的最大切片数量。数值越大,大尺寸图像保留的细节越多。建议:图像设为 36,视频设为 1。
max_num_frames128仅视频max_num_frames 参数动态控制时间上下文长度并防止显存溢出:
短视频(时长 ≤ max_num_frames 秒):处理器默认采用 1 FPS 采样,逐秒捕捉细节,不会触及上限。
长视频(时长 > max_num_frames 秒):处理器自动切换为均匀采样,从整个时间线中均匀选取恰好 max_num_frames 帧。
stack_frames1仅视频每秒总采样点数。1 = 仅主帧(不堆叠)。N(N>1)= 每秒 1 个主帧 + N−1 个子帧;子帧合成为网格图像并与主帧交错排列。建议短视频设为 1,长视频设为 3 或 5。
use_image_idTrue图像与视频是否在每个图像/帧占位符前添加 <image_id>N</image_id> 标签。图像设为 True,视频设为 False。

注意: downsample_mode 必须同时传递给 apply_chat_template(确保占位符数量正确)和 generate(供视觉编码器使用)。其余参数只需传递给 apply_chat_template。

使用 transformers serve 进行服务部署

Hugging Face Transformers 内置了一个轻量级的 OpenAI 兼容服务器,适用于快速测试和中度负载部署。

pip install "transformers[serving]>=5.7.0"

启动服务器:

transformers serve openbmb/MiniCPM-V-4.6 --port 8000 --host 0.0.0.0 --continuous-batching

发送请求:

curl -s http://localhost:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "openbmb/MiniCPM-V-4.6",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/refract.png"}},
        {"type": "text", "text": "What causes this phenomenon?"}
      ]
    }]
  }'

工具调用示例:

curl -s http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "openbmb/MiniCPM-V-4.6",
  "messages": [{"role": "user", "content": [
    {"type": "text", "text": "the weather of Beijing"}
  ]}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get the current weather for a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {"type": "string", "description": "City name"}
        },
        "required": ["location"]
      }
    }
  }]
}'

模型会先返回一段自然语言解释,随后在内容字段中嵌入一个结构化的<tool_call>块。请注意,transformers 库目前尚未为该格式添加专门的工具调用解析器,因此现阶段需要借助正则表达式手动提取工具调用。

{
    "id": "f4f09c7d-8045-4cb1-ade9-07aa5dee637d",
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "I need to check the current weather for Beijing, so I will call the get_weather function.\n\n<tool_call>\n<function=get_weather>\n<parameter=location>\nBeijing\n</parameter>\n</function>\n</tool_call>",
                "role": "assistant"
            }
        }
    ],
    "created": 1778748859,
    "model": "openbmb/MiniCPM-V-4.6@main",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 47,
        "prompt_tokens": 283,
        "total_tokens": 330
    }
}

处理模型输出中的转义换行符

在某些情况下,模型可能会将转义换行符 \n 以字符串字面量的形式输出,而非实际的换行。为了正确渲染文本,尤其是在 UI 层中,您可以使用以下实用函数。该函数会谨慎地将字面量 \n 替换为真实换行,同时保护那些 \n 具有特定语义的场景。

实用函数:

import re

_PATTERN = re.compile(
    r'(```[\s\S]*?```'       # fenced code blocks
    r'|`[^`]+`'              # inline code
    r'|\$\$[\s\S]*?\$\$'     # display math
    r'|\$[^$]+\$'            # inline math
    r'|\\$[\s\S]*?\\$'     # $...$
    r'|\\

$$[\s\S]*?\\$$

'     # 

$$...$$


    r')'
    r'|(?<!\\)(?:\\r\\n|\\[nr])'
)

def normalize_response_text(text: str) -> str:
    """
    Lightweight post-processing: Converts literal '\\n' to actual newlines, 
    while protecting code blocks, inline code, and LaTeX commands.
    """
    if not isinstance(text, str) or "\\" not in text:
        return text
    return _PATTERN.sub(lambda m: m.group(1) or '\n', text)

在 iOS、Android 与 HarmonyOS 平台上部署 MiniCPM-V 4.6

我们已将 MiniCPM-V 4.6 适配至 iOS、Android 与 HarmonyOS 平台,所有端侧适配代码均已全面开源。开发者只需几步即可复现端侧部署体验。请访问我们的端侧部署仓库获取各平台构建指南,或前往下载页面直接体验预构建应用。

在其他推理与训练框架中使用 MiniCPM-V 4.6

MiniCPM-V 4.6 支持多种推理与训练框架。以下为各框架的快速上手命令,完整详情请参阅我们的 Cookbook。

vLLM — 完整指南
vllm serve openbmb/MiniCPM-V-4.6 \
  --port 8000 \
  --enable-auto-tool-choice \
  --tool-call-parser qwen3_coder \
  --default-chat-template-kwargs '{"enable_thinking": false}'

注意: --enable-auto-tool-choice 和 --tool-call-parser qwen3_coder 用于启用工具/函数调用支持。如果你不需要使用工具,可以省略这些参数,直接运行 vllm serve openbmb/MiniCPM-V-4.6 即可。

curl -s http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "openbmb/MiniCPM-V-4.6",
  "messages": [{"role": "user", "content": [
    {"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/refract.png"}},
    {"type": "text", "text": "What causes this phenomenon?"}
  ]}]
}'

工具调用示例:

curl -s http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "openbmb/MiniCPM-V-4.6",
  "messages": [{"role": "user", "content": [
    {"type": "text", "text": "北京的天气"}
  ]}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get the current weather for a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {"type": "string", "description": "City name"}
        },
        "required": ["location"]
      }
    }
  }]
}'
SGLang — 完整指南
python -m sglang.launch_server --model openbmb/MiniCPM-V-4.6 --port 30000
curl -s http://localhost:30000/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "openbmb/MiniCPM-V-4.6",
  "messages": [{"role": "user", "content": [
    {"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/refract.png"}},
    {"type": "text", "text": "What causes this phenomenon?"}
  ]}]
}'
llama.cpp — 完整指南
llama-server -m MiniCPM-V-4.6-Q4_K_M.gguf --port 8080
curl -s http://localhost:8080/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "MiniCPM-V-4.6",
  "messages": [{"role": "user", "content": [
    {"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/refract.png"}},
    {"type": "text", "text": "What causes this phenomenon?"}
  ]}]
}'
Ollama — 完整指南
ollama run minicpm-v-4.6

在交互式会话中,直接粘贴图片路径或URL即可与模型进行对话。

LLaMA-Factory(微调)— 完整指南
llamafactory-cli train examples/train_lora/minicpmv4_6_lora_sft.yaml
ms-swift(微调)— 完整指南
swift sft --model_type minicpm-v-4_6 --dataset <your-dataset>

许可证

模型许可证

  • MiniCPM-o/V 模型的权重与代码均依据 Apache-2.0 许可证开源发布。

声明

  • 作为多模态大语言模型(MLLMs),MiniCPM-o/V 系列模型通过学习大量多模态语料生成内容,但无法理解、表达个人观点或进行价值判断。MiniCPM-o/V 模型生成的任何内容均不代表模型开发者的观点与立场。
  • 对于因使用 MiniCPM-o/V 模型而产生的任何问题,包括但不限于数据安全问题、舆情风险,或因模型被误导、滥用、传播或误用而引发的任何风险与问题,我们概不负责。

技术报告与关键技术论文

👏 欢迎探索 MiniCPM-o/V 的关键技术以及我们团队的其他多模态项目:

技术报告: MiniCPM-o 4.5 | MiniCPM-V 4.5 | MiniCPM-o 2.6 | MiniCPM-Llama3-V 2.5 | MiniCPM-V 2.0

其他多模态项目: VisCPM | RLPR | RLHF-V | LLaVA-UHD | RLAIF-V | LLaVA-UHD-v4

引用

如果您觉得我们的模型、代码或论文对您有帮助,恳请引用我们的论文 📝 并为我们点亮星标 ⭐️!

@proceedings{yu2025minicpmv45cookingefficient,
      title={MiniCPM-V 4.5: Cooking Efficient MLLMs via Architecture, Data, and Training Recipe}, 
      author={Tianyu Yu and Zefan Wang and Chongyi Wang and Fuwei Huang and Wenshuo Ma and Zhihui He and Tianchi Cai and Weize Chen and Yuxiang Huang and Yuanqian Zhao and others},
      year={2025},
      url={https://arxiv.org/abs/2509.18154}, 
}

@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}
}