Type something to search...
惊艳来袭!Mini MiniCPM-o 2.6:超越GPT-4o的8B参数多模态LLM!

惊艳来袭!Mini MiniCPM-o 2.6:超越GPT-4o的8B参数多模态LLM!

在一项突破性的进展中,Mini CPM-o 在多模态大型语言模型 (LLM) 的世界中引起了轰动。凭借其 8 亿参数架构,它不仅在多个基准测试中超越了 GPT-4o,还在视觉、音频和其他多模态功能上与其相媲美。让我们深入探讨这一激动人心的发布、它的能力、安装过程和使用案例。

MiniCPM-o 2.6: 是什么?

MiniCPM-o 2.6: 是一种先进的多模态 LLM,能够无缝处理文本、图像、视频和音频作为输入。它提供高质量的输出,包括文本生成、语音合成和多模态交互。其性能证明了前沿创新的能力,在速度和准确性上超越了知名模型,同时在实时处理方面开辟了新的可能性。

MiniCPM-o 的关键特性

  1. 端到端多模态处理: 同时处理视觉、音频和文本输入,精度无与伦比。
  2. 双语实时语音转换: 支持实时语音到语音的转换,具有可自定义的声音。
  3. 情感、速度和风格控制: 实现情感调节、声音克隆和角色扮演场景等独特功能。
  4. 视频和音频理解: 高效提取视频和音频文件中的见解,使其成为创意和分析任务的多功能工具。
  5. 光学字符识别能力: 对图像进行光学字符识别,支持多种语言。
  6. 时分复用 (TDM): 一种用于在线多模态流媒体的新机制,确保无缝的实时性能。

该雷达图比较了多个模型(GPT-4o-2.2405、Gemini-1.5 Pro、Qwen2-VL、GLM-4-Voice 和 MiniCPM-o 2.6)在实时流媒体、语音对话和视觉理解基准等多个任务中的表现。它直观地突出了每个模型在不同评估类别中的优势和劣势。

在本地安装 MiniCPM-o

系统要求:

  • Python 3.10

分步指南:

  1. 克隆代码库: 从 GitHub 克隆 Mini CPM 2.6 代码库,该代码库是开源的,供社区使用。有关 CPU 的信息,请按照这些 步骤
https://github.com/OpenBMB/MiniCPM-o.git

2. 安装依赖项:使用提供的 requirements.txt 文件安装必要的库。

cd MiniCPM-o

## 创建 Conda 环境
conda create -n minicpm python=3.10
conda activate minicpm

## 安装依赖
pip install -r requirements_o2.6.txt

3. 启动模型服务器。

python web_demos/minicpm-o_2.6/model_server.py

4. 启动 Web 服务器。

## 确保已安装 Node 和 PNPM。
sudo apt-get update
sudo apt-get install nodejs npm
npm install -g pnpm

cd web_demos/minicpm-o_2.6/web_server
## 创建 https 的 ssl 证书,https 是请求摄像头和麦克风权限所必需的。
bash ./make_ssl_cert.sh  # 输出 key.pem 和 cert.pem

pnpm install  # 安装依赖
pnpm run dev  # 启动服务器

5. 如果您想在 Jupyter Notebook 中测试。启动 Jupyter Notebook:启动 Jupyter Notebook 以与模型进行交互。

conda install -c conda-forge --override-channels notebook -y
conda install -c conda-forge --override-channels ipywidgets -y
jupyter notebook

针对基于图像的输出。

import torch
from PIL import Image
from transformers import AutoModel, AutoTokenizer

torch.manual_seed(100)

model = AutoModel.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True,
    attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa 或 flash_attention_2, 不使用 eager
model = model.eval().cuda()
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True)

image = Image.open('./assets/minicpmo2_6/show_demo.jpg').convert('RGB')

## 第一轮对话
question = "图片中的地形是什么?"
msgs = [{'role': 'user', 'content': [image, question]}]

answer = model.chat(
    msgs=msgs,
    tokenizer=tokenizer
)
print(answer)

## 第二轮对话,传递多轮对话的历史上下文
msgs.append({"role": "assistant", "content": [answer]})
msgs.append({"role": "user", 'content': ["我在这里旅行时应该注意什么?"]})

answer = model.chat(
    msgs=msgs,
    tokenizer=tokenizer
)
print(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."

处理多张图片。

import torch
from PIL import Image
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True,
    attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa 或 flash_attention_2, 不使用 eager
model = model.eval().cuda()
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True)

image1 = Image.open('image1.jpg').convert('RGB')
image2 = Image.open('image2.jpg').convert('RGB')
question = '比较图像1和图像2,告诉我图像1和图像2之间的区别。'

msgs = [{'role': 'user', 'content': [image1, image2, question]}]

answer = model.chat(
    msgs=msgs,
    tokenizer=tokenizer
)
print(answer)

视频输入:

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-o-2_6', trust_remote_code=True,
    attn_implementation='sdpa', torch_dtype=torch.bfloat16) # sdpa 或 flash_attention_2, 不使用 eager
model = model.eval().cuda()
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-o-2_6', trust_remote_code=True)

MAX_NUM_FRAMES=64 # 如果 cuda OOM,设置一个更小的数字

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('帧数:', len(frames))
    return frames

video_path="video_test.mp4"
frames = encode_video(video_path)
question = "描述视频"
msgs = [
    {'role': 'user', 'content': frames + [question]}, 
]

## 设置视频解码参数
params = {}
params["use_image_id"] = False
params["max_slice_nums"] = 2 # 如果 cuda OOM 且视频分辨率 > 448*448,使用 1

answer = model.chat(
    msgs=msgs,
    tokenizer=tokenizer,
    **params
)
print(answer)

探索能力

视频理解:

MiniCPM-o 可以以惊人的准确性分析和描述视频。例如,它可以识别物体、环境,甚至视频中的细微细节,如表情和风景。

文本转语音 (TTS):

该模型在文本转语音方面表现出色,能够准确转录音频文件。它的双语能力确保在支持的语言中进行准确翻译。

OCR 功能:

虽然其英语 OCR 的准确性很高,但在某些语言中的表现良好但不算出色。这使得它成为以英语为中心的应用程序的强有力竞争者。

限制与观察

  • 语言支持: 虽然英语 OCR 功能强大,但多语言支持需要改进。
  • GPU 依赖性: 需要高性能 GPU 以获得最佳性能。

现实世界的应用

  1. 内容创作: 非常适合视频摘要、转录和配音任务。
  2. 客户支持: 通过实时双语语音转换和情感控制自动化互动。
  3. 数据分析: 从多模态数据中提取洞察,包括图像和视频。
  4. 教育与无障碍: 通过TTS和OCR增强视觉障碍用户的学习体验。

结论

MiniCPM-o 2.6 是多模态 LLMs 的重大飞跃,提供了处理多种数据类型的无与伦比的能力。其实时处理、双语 TTS 和视频分析为各行业的无数应用打开了大门。

如果您觉得这篇文章有启发,考虑在您的网络中关注和分享它。让我们一起探索 AI 创新的未来!

Related Posts

结合chatgpt-o3-mini与perplexity Deep Research的3步提示:提升论文写作质量的终极指南

结合chatgpt-o3-mini与perplexity Deep Research的3步提示:提升论文写作质量的终极指南

AI 研究报告和论文写作 合并两个系统指令以获得两个模型的最佳效果 Perplexity AI 的 Deep Research 工具提供专家级的研究报告,而 OpenAI 的 ChatGPT-o3-mini-high 擅长推理。我发现你可以将它们结合起来生成令人难以置信的论文,这些论文比任何一个模型单独撰写的都要好。你只需要将这个一次性提示复制到 **

阅读更多
让 Excel 过时的 10 种 Ai 工具:实现数据分析自动化,节省手工作业时间

让 Excel 过时的 10 种 Ai 工具:实现数据分析自动化,节省手工作业时间

Non members click here作为一名软件开发人员,多年来的一个发现总是让我感到惊讶,那就是人们还在 Excel

阅读更多
使用 ChatGPT 搜索网络功能的 10 种创意方法

使用 ChatGPT 搜索网络功能的 10 种创意方法

例如,提示和输出 你知道可以使用 ChatGPT 的“搜索网络”功能来完成许多任务,而不仅仅是基本的网络搜索吗? 对于那些不知道的人,ChatGPT 新的“搜索网络”功能提供实时信息。 截至撰写此帖时,该功能仅对使用 ChatGPT 4o 和 4o-mini 的付费会员开放。 ![](https://images.weserv.nl/?url=https://cdn-im

阅读更多
掌握Ai代理:解密Google革命性白皮书的10个关键问题解答

掌握Ai代理:解密Google革命性白皮书的10个关键问题解答

10 个常见问题解答 本文是我推出的一个名为“10 个常见问题解答”的新系列的一部分。在本系列中,我旨在通过回答关于该主题的十个最常见问题来分解复杂的概念。我的目标是使用简单的语言和相关的类比,使这些想法易于理解。 图片来自 [Solen Feyissa](https://unsplash.com/@solenfeyissa?utm_source=medium&utm_medi

阅读更多
在人工智能和技术领域保持领先地位的 10 项必学技能 📚

在人工智能和技术领域保持领先地位的 10 项必学技能 📚

在人工智能和科技这样一个动态的行业中,保持领先意味着不断提升你的技能。无论你是希望深入了解人工智能模型性能、掌握数据分析,还是希望通过人工智能转变传统领域如法律,这些课程都是你成功的捷径。以下是一个精心策划的高价值课程列表,可以助力你的职业发展,并让你始终处于创新的前沿。 1. 生成性人工智能简介课程: [生成性人工智能简介](https://genai.works

阅读更多
揭开真相!深度探悉DeepSeek AI的十大误区,您被误导了吗?

揭开真相!深度探悉DeepSeek AI的十大误区,您被误导了吗?

在AI军备竞赛中分辨事实与虚构 DeepSeek AI真的是它所宣传的游戏规则改变者,还是仅仅聪明的营销和战略炒作?👀 虽然一些人将其视为AI效率的革命性飞跃,但另一些人则认为它的成功建立在借用(甚至窃取的)创新和可疑的做法之上。传言称,DeepSeek的首席执行官在疫情期间像囤积卫生纸一样囤积Nvidia芯片——这只是冰山一角。 从其声称的550万美元培训预算到使用Open

阅读更多
Type something to search...