Summary: This open-source 9B-parameter model enables real-time, natural multimodal interaction on edge devices. It excels in video analysis, document parsing, and speech tasks, offering superior performance with efficient on-device deployment.
大家好,我是 Jack。
临近过年,各家大模型又到了疯狂冲业绩的时刻。
面壁智能也发布了他们的新一代全模态模型 MiniCPM-o 4.5。
如果你经常网上冲浪,一定刷到过很多人拍自家小猫,让某 AI 看着别偷吃零食的视频,结果主人偷偷拿走零食,AI 却冤枉说是小猫偷吃的。
而 MiniCPM-o 4.5 则可以实时读取视频里的每一帧,清楚地知道并不是小猫偷吃了,而是被"狗"主人拿走了。
给大家看一下效果:
MiniCPM-o 4.5 不再是死板的"对讲机"回合制交互,能「边看、边听、主动说」,跟你进行自由互动。
整个对话过程,更智能,更自然。
沿袭面壁小钢炮一贯的"高密度"特点,MiniCPM-o 4.5 仅靠 9B 参数,在全模态、视觉理解、文档解析、语音理解和生成、声音克隆等方面全面领先。
并且,MiniCPM-o 4.5 是完全开源的!
Github 开源地址:
https://github.com/OpenBMB/MiniCPM-o
Hugging Face 开源地址:
https://huggingface.co/openbmb/MiniCPM-o-4_5
一、MiniCPM-o 4.5
看到这里,可能有小伙伴疑惑。现在都那么多大参数量的多模态模型了,为什么还发 9B 小参数量的模型?
因为它的应用场景是在端侧设备。
将 MiniCPM-o 4.5 部署到智能眼镜里,它就能帮我们识别手里的牌:
可以看到大部分都说对了,如果针对麻将识别做 fintune,效果应该好很多。
想象一下,智能眼镜再加上一些打牌策略给你推荐,教你打牌,帮你记牌。这个时候,看你牌技大涨的麻友,可能就坐不住了。
甚至还可以帮助视障人士识别盲道。
想要在算力有限的端侧设备上使用 AI 大模型的能力,要么调用云端 API 大模型服务,要么就需要在端侧设备上直接部署这种小模型。
现在走进一个封闭一点的电梯或者房间,网络信号都要卡一下的今天,显然端侧本地部署的方案,是更可靠的。
而 MiniCPM-o 4.5 也算是目前,端侧战力最强的多模态大模型了。
MiniCPM-o 4.5 不仅在模型能力密度上再上台阶,也一直致力于追求大模型的极致「能效比」,通过更低的显存占用、更快的响应速度,确保在提供 SOTA 级全模态表现的同时,实现了最佳的推理效率和最低的推理开销。
MiniCPM-o 4.5 采用了端到端的全模态架构,并创新地加入了全双工多模态实时流机制、主动交互机制、可配置语音建模设计,造就了 MiniCPM-o 4.5 与人一样自然的交互能力与体验。
端到端全模态架构: 各模态的编码器/解码器与大语言模型通过稠密特征以端到端的方式进行紧密连接。这种设计实现了更好的信息流转与控制,有助于在训练过程中充分挖掘和利用丰富的多模态知识。
全双工多模态实时流机制: 1、将离线模态编码器/解码器转化为支持流式输入/输出的在线全双工版本。语音解码器采用文本与语音 token 交错建模的方式,支持全双工语音生成(即与新输入实时同步),同时也提升了长语音(如超过 1 分钟)生成的稳定性。2、时分复用:我们在毫秒级时间线上同步所有输入和输出流,并利用时分复用机制在语言模型主干中进行统一建模。该机制将并行的全模态流划分为微小周期性时间片内的顺序信息组,从而实现高效的全模态流式处理。
主动交互机制: 语言模型模块会持续监控输入的视频和音频流,并以 1Hz 的频率自动决策是否发言。这种高频决策能力结合全双工特性,是实现主动提醒、主动评论等"主动交互"能力的关键。
可配置语音建模设计: 延续了 MiniCPM-o 2.6 的多模态系统提示词设计,同时包含文本系统提示词和音频系统提示词(用于指定音色)。这使得模型在推理阶段能够通过简单的参考音频实现声音克隆和角色扮演。
二、使用教程
你可以直接在他们的官网体验:
https://minicpm-omni.openbmb.cn/
也可以在 Hugginface 上使用部署好的模型:
https://huggingface.co/spaces/openbmb/MiniCPM-o-4_5-Demo
如果你想要本地部署,可以直接找到他们开源的模型:
https://huggingface.co/openbmb/MiniCPM-o-4_5
如果你不想要 TTS 语音功能,可以用以下指令安装:
pip install "transformers==4.51.0" accelerate "torch>=2.3.0,<=2.8.0" "torchaudio<=2.8.0" "minicpmo-utils>=1.0.2"
如果你想要 TTS 语音功能,可以安装 minicpmo-utils[all]:
pip install "transformers==4.51.0" accelerate "torch>=2.3.0,<=2.8.0" "torchaudio<=2.8.0" "minicpmo-utils[all]>=1.0.2"
差别就在 minicpmo 这个依赖库上。
安装好这些,因为涉及到处理视频,所以需要用到 ffmpeg。
Windows 用户可以直接去官网下载 exe 文件直接安装:
https://www.ffmpeg.org/
然后配置好环境变量即可。
如果是 macOS (Homebrew) 操作系统,可以直接使用指令:
brew install ffmpeg
Ubuntu/Debian:
sudo apt update && sudo apt install ffmpeg
然后就可以通过 API 下载模型,并进行模型初始化:
import torch
from transformers import AutoModel
# Load omni model (default: init_vision=True, init_audio=True, init_tts=True)
# For vision-only model: set init_audio=False and init_tts=False
# For audio-only model: set init_vision=False
model = AutoModel.from_pretrained(
"openbmb/MiniCPM-o-4_5",
trust_remote_code=True,
attn_implementation="sdpa", # sdpa or flash_attention_2
torch_dtype=torch.bfloat16,
init_vision=True,
init_audio=True,
init_tts=True,
)
model.eval().cuda()
# Initialize TTS for audio output in chat or streaming mode
model.init_tts(streaming=False) # or streaming=True
# Convert simplex model to duplex mode
duplex_model = model.as_duplex()
# Convert duplex model back to simplex mode
simplex_model = duplex_model.as_simplex(reset_session=True)
聊天的打开也很简单,对视频进行抽帧,每一帧图像都保存到一个 list 里,在保存到 dict 构造成 dict 数据,最后调用 model.chat 函数做分析。
想要加快分析视频的速度,一个最简单的方法就是在抽帧频率这里做修改:
from minicpmo.utils import get_video_frame_audio_segments
model = ...
model.init_tts(streaming=False)
video_path = "assets/Skiing.mp4"
# Optional: Set reference audio for voice cloning
ref_audio_path = "assets/HT_ref_audio.wav"
sys_msg = model.get_sys_prompt(ref_audio=ref_audio_path, mode="omni", language="en")
# Use stack_frames=5 for high refresh rate mode
video_frames, audio_segments, stacked_frames = get_video_frame_audio_segments(video_path, stack_frames=1)
omni_contents = []
for i in range(len(video_frames)):
omni_contents.append(video_frames[i])
omni_contents.append(audio_segments[i])
if stacked_frames is not None and stacked_frames[i] is not None:
omni_contents.append(stacked_frames[i])
msg = {"role": "user", "content": omni_contents}
msgs = [sys_msg, msg]
# Set generate_audio=True and output_audio_path to save TTS output
generate_audio = True
output_audio_path = "output.wav"
res = model.chat(
msgs=msgs,
max_new_tokens=4096,
do_sample=True,
temperature=0.7,
use_tts_template=True,
enable_thinking=False,
omni_mode=True, # Required for omni inference
generate_audio=generate_audio,
output_audio_path=output_audio_path,
max_slice_nums=1, # Increase for HD mode
)
print(res)
# Example output: "The person in the picture is skiing down a snowy mountain slope."
# import IPython
# IPython.display.Audio("output.wav")
更详细的说明,可以看 Huggingface 上放出的 demo,都有详细调用代码:
如果你对于 MiniCPM-o-4_5 的运行速度,有要求,那可以用这里的 cpp 部署,官方也有详细的教程:
https://github.com/OpenSQZ/MiniCPM-V-CookBook/blob/main/deployment/llama.cpp/minicpm-o4_5_llamacpp.md
直接使用 llama.cpp,先克隆这个项目:
git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp
然后用 CMake 和 CPU 编译 llama.cpp:
cmake -B build
cmake --build build --config Release
也可以用 GPU 编译:
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release
编译的详细教程可以看这个:
https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md
然后你可以直接下载官方的 GGUF 模型文件:
https://huggingface.co/openbmb/MiniCPM-o-4_5-gguf
你也可以通过 Pytorch 版本的,自己做一个格式转换,变成 llama.cpp 可用的模型格式:
https://huggingface.co/openbmb/MiniCPM-o-4_5
bash ./tools/omni/convert/run_convert.sh
# You need to modify the paths in the script:
MODEL_DIR="/path/to/MiniCPM-o-4_5" # Source model
LLAMACPP_DIR="/path/to/llamacpp" # llamacpp directory
OUTPUT_DIR="${CONVERT_DIR}/gguf" # Output directory
PYTHON="/path/to/python" # Python path
然后就可以通过以下命令行,调用大模型了,速度更快:
cd build/bin/
# run f16 version
./llama-mtmd-cli -m ../MiniCPM-o-4_5/model/Model-8.2B-F16.gguf --mmproj ../MiniCPM-o-4_5/mmproj-model-f16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image xx.jpg -p "What is in the image?"
# run quantized int4 version
./llama-mtmd-cli -m ../MiniCPM-o-4_5/model/ggml-model-Q4_K_M.gguf --mmproj ../MiniCPM-o-4_5/mmproj-model-f16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image xx.jpg -p "What is in the image?"
# or run in interactive mode
./llama-mtmd-cli -m ../MiniCPM-o-4_5/model/ggml-model-Q4_K_M.gguf --mmproj ../MiniCPM-o-4_5/mmproj-model-f16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image xx.jpg -i
# run with reasoning enabled (think mode without token limit)
./llama-mtmd-cli -m ../MiniCPM-o-4_5/model/ggml-model-Q4_K_M.gguf --mmproj ../MiniCPM-o-4_5/mmproj-model-f16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image xx.jpg --jinja --reasoning-budget -1 -p "what is it?"
# run with reasoning disabled (no think mode)
./llama-mtmd-cli -m ../MiniCPM-o-4_5/model/ggml-model-Q4_K_M.gguf --mmproj ../MiniCPM-o-4_5/mmproj-model-f16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image xx.jpg --jinja --reasoning-budget 0 -p "what is it?"
三、絮叨
MiniCPM-o 4.5 的效果还是蛮惊艳的,在端侧设备上,属于 top 级别的大模型了,想要在移动设备上部署大模型的小伙伴,可以试试它。
好了,本期的内容就是这么多,如果对于你有所帮助的话,记得点赞转发。
我是 Jack,我们下期再见~
没有评论:
发表评论