跳到主要内容

MiniCPM5-1B

MiniCPM 文本系列

MiniCPM5-1B 是 MiniCPM5 系列的首个模型,面向本地助手、coding agent、工具调用流程以及需要紧凑模型的推理场景。它在较小部署成本下提供原生长上下文能力,并通过同一份权重支持 Think / No Think 两种对话模式。

选择适合运行环境的 BF16、GGUF 或 MLX 权重;需要训练或研究时,可进一步查看 SFT 与 Base 版本。

模型下载​

当前主推版本:MiniCPM5-1B(BF16 / GGUF / MLX):

快速上手​

对三种最常用的推理路径,可以按下面方式启动服务或本地推理。

vLLM(OpenAI 兼容服务,NVIDIA GPU)​

Bash
pip install "vllm>=0.21" && vllm serve openbmb/MiniCPM5-1B --port 8000

测试请求:

Bash
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "openbmb/MiniCPM5-1B",
"messages": [{"role": "user", "content": "你是谁?可以简单介绍一下自己吗?"}],
"max_tokens": 128,
"temperature": 0.7
}'

SGLang(OpenAI 兼容服务,NVIDIA GPU)​

Bash
pip install "sglang[srt]>=0.5.12" && python -m sglang.launch_server --model-path openbmb/MiniCPM5-1B --port 30000

测试请求:

Bash
curl http://localhost:30000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "openbmb/MiniCPM5-1B",
"messages": [{"role": "user", "content": "你是谁?可以简单介绍一下自己吗?"}],
"max_tokens": 128,
"temperature": 0.7
}'

Transformers(Python 本地推理,CPU 或 GPU)​

Bash
pip install -U "transformers>=5.6" accelerate torch

本地推理测试:

Python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "openbmb/MiniCPM5-1B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto",
)

messages = [{"role": "user", "content": "你是谁?可以简单介绍一下自己吗?"}]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
enable_thinking=False,
return_tensors="pt",
).to(model.device)

outputs = model.generate(inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))

推荐的 chat template 采样参数:

模式推荐采样参数启用方式
Thinktemperature=0.9, top_p=0.95enable_thinking=True
No Thinktemperature=0.7, top_p=0.95enable_thinking=False

其余后端(llama.cpp / Ollama / LM Studio / MLX)见 cookbook 表格。

工具调用(Function Call)​

工具调用推荐使用 SGLang:MiniCPM5-1B 以 XML 格式产出工具调用,SGLang 原生内置的 minicpm5 parser 会自动把它转成 OpenAI 兼容的 tool_calls 字段。

Bash
python -m sglang.launch_server --model-path openbmb/MiniCPM5-1B --port 30000 \
--tool-call-parser minicpm5 # 或:--tool-call-parser auto

相关资源​

开发者精选

查看全部 →