1. 前言
近期百度正式开源了文心大模型 4.5 多模态系列。该系列包含 10 款模型,涵盖 8 个混合专家模型(激活参数规模 47B/3B)及 2 个稠密参数模型(0.3B)。其中 4 款 VL 模型支持多模态特性,可理解图片、音频、视频等非文本内容。作为产业级知识增强大模型,其在多项基准测试中表现突出。本次将深入测评其部署流程及实际推理效果。

2. 测评环境
2.1 硬件配置
- CPU: 16 核 X86 架构 Intel 处理器
- 内存:64G
- GPU: Nvidia A100 80G 显存
2.2 软件环境
- 操作系统:Ubuntu 22.04
- Python: 3.10
- PyTorch: 2.7
2.3 模型选择
核心能力为多模态,选用 ERNIE-4.5-VL-28B-A3B-Paddle。横向对比模型为通义千问的 Qwen2.5-VL-32B-Instruct。
3. 模型部署
得益于 AI 框架的成熟,部署已无显著卡点。百度飞桨框架支持基于 Transformer 的快速部署。相比千问模型文件(68GB),文心大模型仅 55GB,在显存消耗上略有优势。
3.1 环境准备
需一台 80G 显存的 A100 主机,可通过主流算力租赁平台获取。
3.2 安装 PaddlePaddle GPU 版
python -m pip install paddlepaddle-gpu==3.1.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
3.3 安装 FastDeploy
针对 A100 显卡专用版本:
python -m pip install fastdeploy-gpu -i https://www.paddlepaddle.org.cn/packages/stable/fastdeploy-gpu-80_90/ --extra-index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
注意:若使用 4090 显卡,请参考官方文档调整安装命令。
3.4 一键部署与推理
执行以下命令完成下载并启动服务:
python -m fastdeploy.entrypoints.openai.api_server \
--model baidu/ERNIE-4.5-VL-28B-A3B-Paddle \
--port 8180 \
--metrics-port 8181 \
--engine-worker-queue-port 8182 \
--max-model-len 32768 \
--enable-mm \
--reasoning-parser ernie-45-vl \
--max-num-seqs 32
成功启动后,端口 8180 将处于监听状态,表示模型已就绪。
4. 多模态图像识别测评
4.1 明星人物识别
以奥黛丽·赫本在厨房操作烤箱的照片为例,对比两个模型的识别结果。
Qwen2.5-VL-32B 结果 识别出女性在厨房操作烤箱,描述了场景构造和物体摆放,但未识别出具体人物身份。
ERNIE-4.5-VL-28B-A3B 结果 精准识别出人物为奥黛丽·赫本,并对环境和元素进行了详细分析。
对比分析 尽管参数量略少,文心大模型在多模态识别精度上表现更佳,且响应速度优于千问。
4.2 Gradio 前端交互
为方便调用,使用 Gradio 构建前端页面,支持图文输入。关键逻辑如下:
import gradio as gr
import requests
import json
import os
from PIL import Image
import io
import time
import uuid
def process_multimodal_input(image, text_input, history):
"""处理多模态输入并调用 API"""
if image is None and not text_input.strip():
return history, "请上传图片或输入文本"
# 准备 API 请求
url = "http://127.0.0.1:8180/v1/chat/completions"
headers = {"Content-Type": "application/json"}
content = []
# 如果有图片,添加图片内容
if image is not None:
temp_dir = "temp_images"
os.makedirs(temp_dir, exist_ok=True)
temp_path = os.path.abspath(f"{temp_dir}/temp_image_{uuid.uuid4()}.jpg")
image.save(temp_path)
image_url = f"file://{temp_path}"
content.append({"type": "image_url", "image_url": {"url": image_url}})
# 添加文本到内容
if text_input.strip():
content.append({"type": "text", "text": text_input})
else:
if image is not None:
content.append({"type": "text", "text": "描述一下这张图片"})
# 更新历史记录中的用户消息
user_message = {"role": "user", "content": content}
messages = []
# 添加历史消息(仅文本部分)
for msg in history:
if msg[0]:
messages.append({"role": "user", "content": [{"type": "text", "text": msg[0]}]})
if msg[1]:
messages.append({"role": "assistant", "content": msg[1]})
messages.append(user_message)
payload = {"messages": messages}
history.append((text_input if text_input.strip() else "图片查询", None))
yield history, ""
try:
response = requests.post(url, headers=headers, data=json.dumps(payload))
response_data = response.json()
if "choices" in response_data and len(response_data["choices"]) > 0:
result = response_data["choices"][0]["message"]["content"]
history[-1] = (history[-1][0], result)
yield history, ""
else:
error_msg = "无法获取响应,API 返回格式异常。"
history[-1] = (history[-1][0], error_msg)
yield history, ""
except Exception as e:
error_msg = f"发生错误:{str(e)}"
history[-1] = (history[-1][0], error_msg)
yield history, ""
def clear_chat():
"""清除聊天历史"""
return [], ""
with gr.Blocks(title="文心大模型 4.5") as demo:
with gr.Column():
with gr.Row():
gr.Markdown("# 文心大模型 4.5 - 多模态大模型智能助手")
chatbot = gr.Chatbot(height=500)
image_input = gr.Image(type="pil", label="", visible=False)
text_input = gr.Textbox(placeholder="输入消息或上传图片...", label="", lines=4, max_lines=10)
with gr.Row():
upload_btn = gr.UploadButton("🖼️", file_types=["image"])
send_btn = gr.Button("发送")
with gr.Row():
gr.Markdown("© 2025 文心大模型 4.5 | 基于 Gradio 构建")
def handle_image_upload(image):
return image
upload_btn.upload(fn=handle_image_upload, inputs=[upload_btn], outputs=[image_input])
send_btn.click(fn=process_multimodal_input, inputs=[image_input, text_input, chatbot], outputs=[chatbot, text_input]).then(
fn=lambda: None, inputs=[], outputs=[image_input]
)
text_input.submit(fn=process_multimodal_input, inputs=[image_input, text_input, chatbot], outputs=[chatbot, text_input]).then(
fn=lambda: None, inputs=[], outputs=[image_input]
)
if __name__ == "__main__":
demo.queue()
demo.launch(server_name="0.0.0.0")
4.3 验证码识别
测试一张复杂验证码图片,模型不仅识别出字符,还精准区分了大小写。效果远超市面常规 OCR 模型,接近专业视觉算法水平。
5. 自媒体创作场景测评
5.1 爆文分析
将一篇 10W+ 阅读量文章输入模型,要求分析爆点。模型从选题、观点、语言表达等维度给出了清晰结论,有助于快速掌握爆款写作手法。
5.2 创意生成
设定职场自媒体场景,询问灵感话题。模型结合痛点与趋势,输出了多个高潜力话题方向。
5.3 内容创作
指定标题《30 岁转行避坑指南》,要求撰写 1100 字公众号文章。模型生成的初稿结构完整、共鸣感强,仅需微调即可发布。
6. 总结
通过本次深度测评,文心大模型 4.5 展现出以下优势:
- 参数灵活:覆盖 0.3B 至 474B,兼顾性能与效率。
- 部署便捷:基于 GitCode 托管,飞桨框架支持一条命令快速部署。
- 多模态能力强:人物识别、OCR 验证码准确率极高,有望替代部分传统视觉算法。
- 场景化落地:在自媒体辅助创作领域表现优异,显著提升生产效率。

