8000 GitHub - OpenBMB/MiniCPM: MiniCPM5: SOTA on-device LLMs, small yet powerful. · GitHub
[go: up one dir, main page]

Skip to content
OpenBMBPublic

About

MiniCPM5: SOTA on-device LLMs, small yet powerful.

Resources

Stars

12.0k stars

Watchers

90 watching

Forks

Repository files navigation

中文 | English

MiniCPM Tech Report | MiniCPM Wiki (in Chinese) | MiniCPM-V Repo | UltraData | Online Demo

Join our discord and Feishu/Lark | Join Us

✨ Highlights

MiniCPM5-15B-A2.5B is a sparse Mixture-of-Experts (MoE) model in the MiniCPM5 series, designed for on-device agents.

  • 📱 An efficient foundation model for on-device agents: Built for on-device agents, MiniCPM5-15B-A2.5B delivers efficient inference locally on phones and PCs. It is compatible with agent harnesses such as Codex, Claude Code, DeepSeek Harness, and WorkBuddy, and offers general-purpose work-agent and coding-agent capabilities. It provides reliable agent services while keeping users' private data entirely on-device.
  • ⚡ On-device inference speed: On an iPhone 18 Pro Max with no memory constraints, MiniCPM5-15B-A2.5B reaches a decoding speed of 52 tokens/s. Building on LES 1.0, MiniCPM5-15B-A2.5B further introduces native prefetch-routing training, improving expert-prefetch prediction accuracy by an average of about 11%. With about 3 GB of memory usage, it reaches 30 tokens/s on an iPhone 18 Pro Max.
  • 🏆 The top-performing LLM under 20B: MiniCPM5-15B-A2.5B demonstrates exceptional capability density, outperforming Qwen3.6-35B-A3B in overall capability with less than half the total parameter count of Qwen3.6-35B-A3B. On the AA-Index benchmark, it scores 11 and ranks first among models under 20B.
  • 🧠 IMO/CMO gold-medal-level reasoning: MiniCPM5-15B-A2.5B officially participated in the 2026 Chinese Mathematical Olympiad (CMO 2026) finals, earning an official gold-medal certification with a score of 123 out of 126. This model also achieved a score of 32 in a self-evaluation on the 2026 International Mathematical Olympiad (IMO 2026), surpassing the gold-medal cutoff of 29. MiniCPM5-15B-A2.5B is the first on-device model to reach IMO gold-medal level.

MiniCPM5-15B-A2.5B capability radar

🎬 Showcase

MiniCPM5-15B-A2.5B completes several agent tasks on its own, entirely on-device — planning, calling tools, and working step by step until each task is finished.

🔥 Changelog

  • 📌 [2026.12.03] MiniCPM5-15B-A2.5B is released: a sparse Mixture-of-Experts (MoE) model in the MiniCPM5 series, paired with deployment / fine-tuning Agent Skills.
  • [2026.09.07] MiniCPM5-2B is released: a compact 2B-class dense model for on-device and resource-constrained use, paired with deployment / fine-tuning Agent Skills.
  • [2026.05.19] MiniCPM5-1B is released: a compact 1B-class dense model for on-device and resource-constrained use, paired with deployment / fine-tuning Agent Skills.
  • [2026.02.11] MiniCPM-SALA is released: a sparse-and-linear hybrid attention model for million-token context modeling and efficient inference.
  • [2025.09.05] MiniCPM4.1 series is released: a trainable sparse-attention model with hybrid reasoning.
  • [2025.06.06] MiniCPM4 is released: an end-side model with over 5x generation acceleration on typical edge chips.
Older entries (2024 + InfLLM-V2 paper)
  • [2025.09.29] InfLLM-V2 paper is released! We can train a sparse attention model with only 5B long-text tokens.
  • [2024.09.05] We release MiniCPM3-4B! This model outperforms Phi-3.5-mini-instruct and GPT-3.5-Turbo-0125 and is comparable to several models with 7B-9B parameters like Llama3.1-8B-Instruct, Qwen2-7B-Instruct, and GLM-4-9B-Chat.
  • [2024.07.05] Released MiniCPM-S-1B! This model achieves an average sparsity of 87.89% in the FFN layer, reducing FFN FLOPs by 84%, while maintaining downstream task performance.
  • [2024.04.11] Released MiniCPM-2B-128k, MiniCPM-MoE-8x2B and MiniCPM-1B! Click here to read our technical blog.
  • [2024.02.01] Released MiniCPM-2B! This model performs similarly to Mistral-7B on public benchmarks (with better performance in Chinese, math, and code abilities) and overall outperforms models like Llama2-13B, MPT-30B, and Falcon-40B.

🧭 Quick Links

📦 Model Downloads

Current release: MiniCPM5-15B-A2.5B:

Model Description Download
MiniCPM5-15B-A2.5B BF16 final release (post-trained with RL + OPD) Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-SFT BF16 SFT-only checkpoint (before RL / OPD) Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-Midtrain BF16 mid-training checkpoint (before SFT) Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-Base BF16 base checkpoint (pre-training only) Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-GGUF GGUF for llama.cpp / Ollama / LM Studio Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-Q3_gud-LCO-GGUF Q3_gud quantized GGUF version for llama.cpp-omni Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-Q4_K_M-LCO-GGUF Q4_K_M quantized GGUF version for llama.cpp-omni Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-MLX MLX / 4bit for Apple Silicon Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-GPTQ GPTQ / 4bit quantized model Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-DSpark DSpark draft model for inference acceleration Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-DSpark-GGUF GGUF version of the DSpark draft model Hugging Face · ModelScope
MiniCPM5-15B-A2.5B-LiteRT the LiteRT-LM version of MiniCPM5-15B-A2.5B Hugging Face · ModelScope

Other models in the MiniCPM5 series:

MiniCPM5-2B

Model Description Download
MiniCPM5-2B BF16 final release (post-trained with RL + OPD) Hugging Face · ModelScope
MiniCPM5-2B-SFT BF16 SFT-only checkpoint (before RL / OPD) Hugging Face · ModelScope
MiniCPM5-2B-Midtrain BF16 mid-training checkpoint (before SFT) Hugging Face · ModelScope
MiniCPM5-2B-Base BF16 base checkpoint (pre-training only) Hugging Face · ModelScope
MiniCPM5-2B-GGUF GGUF for llama.cpp / Ollama / LM Studio Hugging Face · ModelScope
MiniCPM5-2B-MLX MLX / 4bit for Apple Silicon Hugging Face · ModelScope
MiniCPM5-2B-GPTQ GPTQ / 4bit quantized model Hugging Face · ModelScope
MiniCPM5-2B-DSpark DSpark draft model for inference acceleration Hugging Face · ModelScope

MiniCPM5-1B

Model Description Download
MiniCPM5-1B BF16 final release (post-trained with RL + OPD) Hugging Face · ModelScope
MiniCPM5-1B-SFT BF16 SFT-only checkpoint (before RL / OPD) Hugging Face · ModelScope
MiniCPM5-1B-Base BF16 base checkpoint (pre-training only) Hugging Face · ModelScope
MiniCPM5-1B-GGUF GGUF for llama.cpp / Ollama / LM Studio Hugging Face · ModelScope
MiniCPM5-1B-MLX MLX / 4bit for Apple Silicon Hugging Face · ModelScope

Other key releases:

HuggingFace ModelScope
MiniCPM-SALA MiniCPM-SALA
MiniCPM4.1-8B MiniCPM4.1-8B
MiniCPM4-0.5B MiniCPM4-0.5B
📋 Click to view earlier MiniCPM releases: 4, BitCPM, applications, MiniCPM3 / 2B / 1B

Earlier flagships:

HuggingFace ModelScope
MiniCPM4-8B MiniCPM4-8B

MiniCPM4.1 quantized & speculative variants:

HuggingFace ModelScope
MiniCPM4.1-8B-GPTQ MiniCPM4.1-8B-GPTQ
MiniCPM4.1-8B-AutoAWQ MiniCPM4.1-8B-AutoAWQ
MiniCPM-4.1-8B-Marlin MiniCPM-4.1-8B-Marlin
MiniCPM4.1-8B-GGUF MiniCPM4.1-8B-GGUF
MiniCPM4.1-8B-MLX MiniCPM4.1-8B-MLX
MiniCPM4.1-8B-Eagle3 MiniCPM4.1-8B-Eagle3

BitCPM4 ternary-quantized + MiniCPM4 Applications:

HuggingFace ModelScope
BitCPM4-1B BitCPM4-1B
BitCPM4-0.5B BitCPM4-0.5B
MiniCPM4-Survey MiniCPM4-Survey
MiniCPM4-MCP MiniCPM4-MCP

MiniCPM4 Eagle speculative decoding, QAT, and pre-2025 releases:

HuggingFace ModelScope
MiniCPM4-8B-Eagle-FRSpec MiniCPM4-8B-Eagle-FRSpec
MiniCPM4-8B-Eagle-FRSpec-QAT MiniCPM4-8B-Eagle-FRSpec-QAT
MiniCPM4-8B-Eagle-vLLM MiniCPM4-8B-Eagle-vLLM
MiniCPM4-8B-marlin-Eagle-vLLM MiniCPM4-8B-marlin-Eagle-vLLM
MiniCPM4-0.5B-QAT-Int4-unquantized MiniCPM4-0.5B-QAT-Int4-unquantized
MiniCPM4-0.5B-QAT-Int4-GPTQ-format MiniCPM4-0.5B-QAT-Int4-GPTQ-format
MiniCPM3-4B MiniCPM3-4B
MiniCPM-2B-sft MiniCPM-2B-sft
MiniCPM-2B-dpo MiniCPM-2B-dpo
MiniCPM-2B-128k MiniCPM-2B-128k
MiniCPM-MoE-8x2B MiniCPM-MoE-8x2B
MiniCPM-1B MiniCPM-1B
MiniCPM-S-1B MiniCPM-S-1B

🚀 MiniCPM5-15B-A2.5B

Introduction

MiniCPM5-15B-A2.5B is a sparse Mixture-of-Experts (MoE) model, designed for native on-device agents. It runs locally on phones, PCs, and other edge devices, providing general work, coding, tool-use, and complex reasoning capabilities under constrained resources. The model supports hybrid thinking and long-context understanding, enabling it to fit into real personal workflows while keeping data and execution on the user's device.

  • Type: Causal Language Model
  • Architecture: MiniCPM5MoEForCausalLM
  • Number of Parameters: 15B in total and 2.5B activated
  • Hidden Size: 2,048
  • Vocabulary Size: 130,560
  • Number of Layers: 28
  • Gated Attention:
    • Attention Heads (GQA): 32 Q heads / 2 KV heads
    • Head Dimension: 128
  • Feed-forward Network:
    • Layer 0: Dense MLP with an intermediate size of 8,192
    • Layers 1–27: MoE
      • Routed Experts: 160
      • Activated Experts: 16 routed + 1 shared
      • Expert Intermediate Size: 512
  • Context Length: 524,288

Evaluation Results

With only 15B total and 2.5B activated parameters, MiniCPM5-15B-A2.5B achieves outstanding performance, outperforming both 30B-class MoE models and 10B-class dense models. Among all compared MoE baselines, it ranks first on 22 out of 36 benchmarks across general knowledge, math, coding, long context, tool use, and agentic tasks. Even when compared against some 30B-class dense models, it maintains competitive performance, demonstrating exceptional capability density.

MiniCPM5-15B-A2.5B evaluation results

See eval/imo-harness for the code and instructions to reproduce the IMO 2026 evaluation.

Training Recipe

The training of MiniCPM5-15B-A2.5B is a practice of UltraData Tiered Data Management, covering three stages: pre-training, mid-training, and large-scale post-training.

During pre-training, the model goes through stable training and decay training to build core language capability. It then enters mid-training to further strengthen target capabilities and adapt to the target data distribution. Parts of the training corpus are released alongside the model as Ultra-FineWeb, Ultra-FineWeb-L3, UltraX, UltraData-Code and UltraData-Math.

We conducted large-scale post-training to strengthen the model's agentic and general-purpose capabilities. We synthesized millions of interactive environments with complex tasks and used JustRL-II for stable long-horizon reinforcement learning. We then used large-scale multi-teacher on-policy distillation (MOPD) to consolidate the capabilities of 22 specialized teachers into a single release model. Parts of our post-training data are released as UltraData-SFT-2605 and UltraData-SFT-Agent-2609.

MiniCPM5-15B-A2.5B Training Recipe

What does RL + OPD bring?

RL + OPD is a key part of MiniCPM5-15B-A2.5B post-training.

During the RL stage, we use JustRL II for large-scale reinforcement learning, enabling the model to continuously explore and iterate its policy across diverse environments and tasks. We train dedicated RL teachers for agentic, mathematical, coding, writing, and other domains to expand the model's capability frontier.

During the OPD stage, we merge 22 expert models produced by RL training into a unified general-purpose model. By incorporating an offline data-generation strategy, we significantly improve the training efficiency of multi-teacher on-policy distillation (MOPD). At each response position, we compute the reverse KL divergence between student and teacher full-vocabulary probability distributions as the advantage estimate, replacing the original verification-based advantage. OPD directly reuses the prompts used to train each RL teacher as distillation data, so no additional corpus construction is required.

On the agent benchmarks shown below, RL + OPD improves scores by an average of ↑7.85 points over the SFT baseline.

MiniCPM5-15B-A2.5B RL + OPD Gains

Quickstart

We recommend using the following sets of sampling parameters for generation:

  • General tasks:
    • Thinking mode: temperature=1.0, top_p=0.95, min_p=0.0. If you encounter repetitive outputs, try: temperature=1.0, top_p=0.95, min_p=0.0, repetition_penalty=1.05.
    • Non-thinking mode: temperature=0.7, top_p=0.80, top_k=20, min_p=0.0, presence_penalty=1.5, repetition_penalty=1.0.
  • Creative writing tasks:
    • Thinking mode: temperature=0.7, top_p=0.95, min_p=0.0, repetition_penalty=1.05.
    • Non-thinking mode: temperature=0.7, top_p=0.80, top_k=20, min_p=0.0, presence_penalty=0.5, repetition_penalty=1.0.

Please note that the support for sampling parameters varies across inference frameworks.

vLLM

Install:

MiniCPM5-15B-A2.5B can be used directly with vLLM. Please use the latest main branch that includes PR #69127 and PR #69128:

git clone https://github.com/vllm-project/vllm.git
cd vllm
pip install -e .

Or use the latest nightly wheel:

uv pip install -U vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightly

Standard mode: the following command starts an OpenAI-compatible API server with a default context length of 524,288 tokens. If you run out of GPU memory, increase --tensor-parallel-size or reduce --max-model-len:

vllm serve openbmb/MiniCPM5-15B-A2.5B --served-model-name MiniCPM5-15B-A2.5B --port 8000

You can also use the 4-bit quantized MiniCPM5-15B-A2.5B-GPTQ by simply replacing the model path.

Speculative decoding (DSpark): we also release MiniCPM5-15B-A2.5B-DSpark, a DSpark draft model trained for MiniCPM5-15B-A2.5B. Enable it in vLLM to accelerate decoding while keeping the target model's outputs unchanged. Use the argument --speculative-config '{"method":"dspark","model":"openbmb/MiniCPM5-15B-A2.5B-DSpark","num_speculative_tokens":7}':

vllm serve openbmb/MiniCPM5-15B-A2.5B --served-model-name MiniCPM5-15B-A2.5B --port 8000 \
  --speculative-config '{"method":"dspark","model":"openbmb/MiniCPM5-15B-A2.5B-DSpark","num_speculative_tokens":7}'

Tool-calling mode: enable tool calling with the arguments --enable-auto-tool-choice --tool-call-parser minicpm5 --reasoning-parser qwen3:

vllm serve openbmb/MiniCPM5-15B-A2.5B --served-model-name MiniCPM5-15B-A2.5B --port 8000 \
  --enable-auto-tool-choice --tool-call-parser minicpm5 --reasoning-parser qwen3

Request example:

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniCPM5-15B-A2.5B",
    "messages": [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}],
    "max_tokens": 512, "temperature": 1.0, "top_p": 0.95
  }'

See Tool Usage & Agentic Integration below for a tool-calling request example and agent harness integration guides.

SGLang

Install:

MiniCPM5-15B-A2.5B can be used directly with SGLang. Please use the latest main branch that includes PR #52071 and PR #52072:

git clone https://github.com/sgl-project/sglang.git
cd sglang
pip install -e "python[all]"

Standard mode: the following command starts an OpenAI-compatible API server with a default context length of 524,288 tokens. If you run out of GPU memory, increase --tp-size or reduce --context-length:

python -m sglang.launch_server --model-path openbmb/MiniCPM5-15B-A2.5B --served-model-name MiniCPM5-15B-A2.5B --port 8000

You can also use the 4-bit quantized MiniCPM5-15B-A2.5B-GPTQ by simply replacing the model path.

Speculative decoding (DSpark): we also release MiniCPM5-15B-A2.5B-DSpark, a DSpark draft model trained for MiniCPM5-15B-A2.5B. Enable it in SGLang to accelerate decoding while keeping the target model's outputs unchanged. Use the arguments --speculative-algorithm DSPARK --speculative-draft-model-path openbmb/MiniCPM5-15B-A2.5B-DSpark --speculative-dspark-block-size 7:

python -m sglang.launch_server --model-path openbmb/MiniCPM5-15B-A2.5B --served-model-name MiniCPM5-15B-A2.5B --port 8000 \
  --speculative-algorithm DSPARK --speculative-draft-model-path openbmb/MiniCPM5-15B-A2.5B-DSpark --speculative-dspark-block-size 7

Tool-calling mode: enable tool calling with the arguments --tool-call-parser minicpm5 --reasoning-parser qwen3:

python -m sglang.launch_server --model-path openbmb/MiniCPM5-15B-A2.5B --served-model-name MiniCPM5-15B-A2.5B --port 8000 \
  --tool-call-parser minicpm5 --reasoning-parser qwen3

Request example:

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniCPM5-15B-A2.5B",
    "messages": [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}],
    "max_tokens": 512, "temperature": 1.0, "top_p": 0.95
  }'

See Tool Usage & Agentic Integration below for a tool-calling request example and agent harness integration guides.

Llama.cpp

Install:

Use official llama.cpp b12847 or later to run the GGUF model. The following commands build llama-server from upstream source.

git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=ON
cmake --build build --config Release --target llama-server -j

For CPU-only builds, omit -DGGML_CUDA=ON. The built binaries are located in ./build/bin/; change to that directory before running the commands below:

Run Server: The following command starts an OpenAI-compatible API server with the Q4_K_M quantized weights:

./llama-server -m MiniCPM5-15B-A2.5B-Q4_K_M.gguf -a MiniCPM5-15B-A2.5B --port 8080 -ngl 99 -fa on --min-p 0 -c 8192 --jinja

Here -c 8192 sets the context length to 8192 (adjust as needed). llama.cpp sets min_p=0.05 by default, which discards tokens whose probability falls below 5% of the highest-probability token. This can actually trigger repetition — the discarded tokens are often exactly the ones the model needs to break out of a repetition loop, so we explicitly set --min-p 0 in the command to disable this filtering.

Other weights

If you have enough GPU memory, swap -m to the unquantized MiniCPM5-15B-A2.5B-BF16.gguf:

./llama-server -m MiniCPM5-15B-A2.5B-BF16.gguf -a MiniCPM5-15B-A2.5B --port 8080 -ngl 99 -fa on --min-p 0 -c 8192 --jinja

Or use the higher-precision quantized MiniCPM5-15B-A2.5B-Q8_0.gguf:

./llama-server -m MiniCPM5-15B-A2.5B-Q8_0.gguf -a MiniCPM5-15B-A2.5B --port 8080 -ngl 99 -fa on --min-p 0 -c 8192 --jinja

Speculative decoding (DSpark): we also release MiniCPM5-15B-A2.5B-DSpark-GGUF, the GGUF version of the DSpark draft model. Start with the following command:

./llama-server -m MiniCPM5-15B-A2.5B-Q4_K_M.gguf -a MiniCPM5-15B-A2.5B --port 8080 -ngl 99 -fa on --min-p 0 -c 8192 --jinja \
 -md MiniCPM5-15B-A2.5B-DSpark.gguf --spec-type draft-dspark --spec-draft-n-max 7 --spec-draft-p-min 0 --n-gpu-layers-draft 99

Here --spec-draft-n-max controls the maximum number of tokens the draft model predicts per speculation round, up to 7. If you use a quantized model, the acceptance rate may drop, in which case reduce this value (e.g., to 2) for better throughput.

Request example:

curl http://localhost:8080/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "MiniCPM5-15B-A2.5B",
        "messages": [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}],
        "temperature": 1.0, "top_p": 0.95, "min_p": 0.0, "max_tokens": 512
    }'

For Llama.cpp tool calling, see the tool-calling section of the Llama.cpp guide.

Transformers

# MiniCPM5 support is in Transformers 5.25.0 and newer
pip install -U "transformers>=5.25.0" accelerate torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "openbmb/MiniCPM5-15B-A2.5B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="auto", device_map="auto")
messages = [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}]
inputs = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    enable_thinking=True, # Set to False to disable thinking mode
    return_dict=True,
    return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

Tool Usage & Agentic Integration

MiniCPM5-15B-A2.5B natively supports thinking mode, single-turn parallel multi-tool calling, and long-horizon multi-turn agentic workflows.

Quick Example (Thinking On by Default / Disabling Thinking)

Notes:

  • Thinking mode is enabled by default (<think>...</think> precedes tool calls or responses). To disable thinking for lower latency, explicitly pass enable_thinking: false (chat_template_kwargs: {"enable_thinking": false} for Chat Completions, reasoning: {"effort": "none"} for Responses, or thinking: {"type": "disabled"} for Anthropic Messages).
  • The current chat_template.jinja does not strip historical thinking. In multi-step tool-calling loops and agent trajectories, passing back prior thinking (reasoning_content / reasoning / thinking) is strongly recommended to preserve chain-of-thought continuity and maximize Prefix KV Cache hit rates.
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get current weather for a city.",
        "parameters": {
            "type": "object",
            "properties": {
                "city": {"type": "string", "description": "City name"},
                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
            },
            "required": ["city"],
        },
    },
}]

resp = client.chat.completions.create(
    model="MiniCPM5-15B-A2.5B",
    messages=[{"role": "user", "content": "Check today's weather in Beijing and Shanghai in celsius."}],
    tools=tools,
    temperature=1.0, top_p=0.95,
    max_tokens=2048,
    # Uncomment to disable thinking mode:
    # extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
print(resp.choices[0].message.tool_calls)

Agent Harness Integration

Verified to work smoothly via the open-source manager CC Switch:

  • Claude Code (Anthropic Messages protocol)

  • Codex CLI / Desktop (OpenAI Responses protocol, with namespace multi-agent tool passthrough)

  • DeepSeek Harness (OpenAI Chat Completions, Responses, or Anthropic Messages)

  • WorkBuddy (OpenAI Chat Completions protocol)

For the full specification of request, parameter, response, and error formats, multi-turn parallel calling and historical thinking retention, local transformers usage, step-by-step harness setup, and FAQs, see Tool Usage Guide.

API Platform

MiniCPM5-15B-A2.5B is also available on the MiniCPM Open Platform for On-Device Open-Source Models. The platform offers an online playground and hosted API access to the MiniCPM family of on-device open-source models, covering text, multimodal, speech synthesis, real-time conversation, and document parsing, and is compatible with the OpenAI API specification.

After creating an API key in the console, set the base URL to https://api.modelbest.cn/v1, the model name to MiniCPM5-15B-A2.5B, and fill in your API key, and you can call it directly. See the API documentation for API key application and full usage details.

For questions, issues, or feedback, please reach us on Discord or our Feishu group.

Running on iOS

MiniCPM5-15B-A2.5B runs on iOS through MiniCPM-V-Apps:

  1. Install MiniCPM-V-Apps via TestFlight.

  2. In the app's model list, select MiniCPM5-15B-A2.5B and download it.

For faster inference, we recommend the quantized version: MiniCPM5-15B-A2.5B-Q3_gud-LCO-GGUF. See MiniCPM-V-Apps repository for the app and source code. For detailed installation instructions and frequently asked questions, see run MiniCPM5-15B-A2.5B on iOS.

GitHub Cookbooks and Agent Skills

MiniCPM5-15B-A2.5B uses the MiniCPM5 MoE architecture (MiniCPM5MoEForCausalLM), natively supported in Hugging Face Transformers (minicpm5_moe), so no trust_remote_code is needed. Step-by-step deployment and fine-tuning instructions are available in the GitHub cookbooks below. Agent Skills are provided as GitHub resources for coding agents such as Cursor and Claude Code to follow through deployment and validation.

Deployment

Backend Model format / use case Cookbook Agent Skill
HF Transformers BF16 / FP16 local Python inference, GPU + CPU transformers.md SKILL.md
vLLM BF16 / FP16 OpenAI server vllm.md SKILL.md
SGLang BF16 / FP16 OpenAI server, recommended for tool calling sglang.md SKILL.md
llama.cpp GGUF local inference, CPU/GPU llama_cpp.md SKILL.md
Ollama GGUF local on-device runtime ollama.md SKILL.md
LM Studio GGUF Mac desktop app and OpenAI server lmstudio.md SKILL.md
MLX MLX / 4bit local inference on Apple Silicon mlx.md SKILL.md
vLLM Ascend BF16 / FP16 OpenAI server vllm_ascend.md SKILL.md
LiteRT-LM .litertlm on-device runtime: desktop / server, CPU + GPU litert.md SKILL.md

Fine-tuning

Framework Use case Cookbook Agent Skill
TRL + PEFT LoRA / SFT fine-tuning trl.md SKILL.md
LLaMA-Factory Fine-tuning llamafactory.md SKILL.md
ms-swift Fine-tuning ms_swift.md SKILL.md
unsloth Fine-tuning unsloth.md SKILL.md

Other Supported Frameworks

In addition to the deployment and fine-tuning frameworks listed above, MiniCPM5-15B-A2.5B is also supported by FlagOS for multi-chip deployment, including BF16 releases for T-Head, NVIDIA, Huawei Ascend, Hygon, Kunlunxin, MetaX, Moore Threads, and Iluvatar, plus a W4A8 release for ARM CPUs.

FlagOS Overview

FlagOS is a fully open-source system software stack designed to unify the model–system–chip layers and foster an open, collaborative ecosystem. It enables a “develop once, run anywhere” workflow across diverse AI accelerators, unlocking hardware performance, eliminating fragmentation among vendor-specific software stacks, and substantially lowering the cost of porting and maintaining AI workloads. The mission of FlagOS is to enable open AI computation and lower the barrier to AI usage and innovation worldwide.

Official website: flagos.io · Developer documentation: docs.flagos.io

FlagOS multi-chip support and usage
FlagOS Multi-Chip Support and Downloads

FlagRelease provides tools for model migration, adaptation, evaluation, and release across AI chip architectures. Select the version for your target hardware from the repositories below.

Chip / Platform Precision MiniCPM5-15B-A2.5B
T-Head BF16 ModelScope / Hugging Face
NVIDIA BF16 ModelScope / Hugging Face
Huawei Ascend BF16 ModelScope / Hugging Face
Hygon BF16 ModelScope / Hugging Face
Kunlunxin BF16 ModelScope / Hugging Face
MetaX BF16 ModelScope / Hugging Face
Moore Threads BF16 ModelScope / Hugging Face
Iluvatar BF16 ModelScope / Hugging Face
ARM CPU W4A8 ModelScope / Hugging Face

The ARM W4A8 release has its own deployment procedure. Refer to its model card for supported devices, operating systems, and inference commands.

FlagOS Installation and Usage

Prepare the drivers and runtime required by your platform's model card, and download the corresponding model files. The example below downloads the T-Head BF16 version:

python -m pip install --upgrade huggingface_hub
hf download FlagRelease/MiniCPM5-15B-A2.5B-BF16-zhenwu-FlagOS \
  --local-dir ./models/MiniCPM5-15B-A2.5B-BF16-zhenwu-FlagOS

For another platform, use its repository from the table above. Model files are also available through ModelScope.

Option 1: Use a FlagRelease Image

If the selected model card provides a container image:

  1. Pull the image specified for your platform.
  2. Start the container with the required device mappings and model directory mounts.
  3. Run the inference example or start the service using the model card's commands and hardware settings.

Option 2: Install from Source

For source deployment, use the inference framework and component revisions specified by the selected model card. FlagOS provides installation guides for its inference plugins:

The following installation sequence is for T-Head with vLLM-plugin-FL. Prepare a compatible PyTorch build and the required build tools, then set MINICPM5_VLLM_REF, MINICPM5_PLUGIN_REF, and MINICPM5_GEMS_REF to the tags or commit IDs specified in the T-Head model card.

: "${MINICPM5_VLLM_REF:?Set the vLLM revision required by the model card}"
: "${MINICPM5_PLUGIN_REF:?Set the vLLM-plugin-FL revision required by the model card}"
: "${MINICPM5_GEMS_REF:?Set the FlagGems revision required by the model card}"

# 1. Install vLLM for the T-Head backend.
git clone https://github.com/vllm-project/vllm.git
cd vllm
git checkout "$MINICPM5_VLLM_REF"
VLLM_TARGET_DEVICE=empty python -m pip install -v --no-build-isolation --no-deps .
cd ..

# 2. Install vLLM-plugin-FL.
git clone https://github.com/flagos-ai/vllm-plugin-FL.git
cd vllm-plugin-FL
git checkout "$MINICPM5_PLUGIN_REF"
python -m pip install --no-build-isolation -e .
cd ..

# 3. Install FlagGems.
git clone https://github.com/flagos-ai/FlagGems.git
cd FlagGems
git checkout "$MINICPM5_GEMS_REF"
python -m pip install --no-build-isolation -e .
cd ..

Install the FlagTree compiler and FlagCX communication library as required by your platform. Apply any model-specific patches and environment settings before running inference.

Run Inference

The following text-generation example uses the downloaded BF16 model files in a configured T-Head vLLM-plugin-FL environment with MiniCPM5-15B-A2.5B support. Save it as inference.py. Set tensor_parallel_size and other runtime parameters in the LLM call as required by your hardware and model card.

from vllm import LLM, SamplingParams


if __name__ == "__main__":
    prompts = ["Explain why the sky appears blue."]
    sampling_params = SamplingParams(max_tokens=512, temperature=0.0)

    llm = LLM(
        model="./models/MiniCPM5-15B-A2.5B-BF16-zhenwu-FlagOS",
        trust_remote_code=True,
    )
    outputs = llm.generate(prompts, sampling_params)
    for output in outputs:
        print(f"Prompt: {output.prompt!r}")
        print(f"Generated: {output.outputs[0].text!r}")
VLLM_PLUGINS=fl python inference.py

🚀 MiniCPM5-2B

MiniCPM5-2B is the second checkpoint in the MiniCPM5 series. It is designed for local assistants, coding agents, tool-use workflows, and reasoning scenarios where a compact model is preferred.

Click to expand: highlights, introduction, evaluation, inference setup

Highlights

We are releasing MiniCPM5-2B, the second model in the MiniCPM5 series, following MiniCPM5-1B. It is a dense 2B Transformer that scales up the same training recipe, built for on-device, local deployment, and resource-constrained scenarios, reaching 2B-class open-source SOTA.

🏆 2B-class open-source SOTA: compared with strong open-source models of similar size, MiniCPM5-2B achieves SOTA performance within this comparison set. It remains competitive with 4B-class models overall, while showing its advantages over models of comparable size in coding, mathematics, long-context understanding, tool use, and agentic tasks.

MiniCPM5-2B capability comparison by domain

📂 Open High-Quality Data: Alongside the model, we are releasing the high-quality training datasets behind it as part of the UltraData family: UltraX, a high-quality web pre-training dataset; UltraData-Code, featuring L0–L3 tiered code data management to drive a significant leap in coding capabilities; UltraData-SFT-Agent-2609, comprising 500K agent training samples to enhance comprehensive on-device agent capabilities; and UltraData-RL-2609, with 80K+ high-quality RL training samples covering mathematics, code, general knowledge, and long-context reasoning.

Introduction

MiniCPM5-2B is the second checkpoint in the MiniCPM5 series, scaling the MiniCPM5-1B recipe up to 2B parameters for users who can afford a larger footprint in exchange for stronger capability. It is designed for local assistants, coding agents, tool-use workflows, and reasoning scenarios where a compact model is preferred. The model keeps a small deployment footprint while providing native long-context support.

Architecture Standard LlamaForCausalLM
Parameters 2,516,756,480 (non-embedding: 1,981,982,720)
Layers 42
Attention Heads (GQA) 16 Q / 2 KV
Context Length 131,072

Evaluation Results

We compare MiniCPM5-2B with strong open-source models in the same size class, including LFM2.5-2.6B, Qwen3.5-2B, and Gemma-4-E2B-it, while also listing larger models such as Qwen3.5-4B, granite-4.2-3B, Nemotron-3-Nano-4B, Gemma-4-E4B-it, and LFM2.5-8B-A1B for reference.

Within this comparison set, MiniCPM5-2B reaches 2B-class open-source SOTA with an average score of 53.9, and also exceeds all of the larger models included here (the highest is 51.1). Its advantages are most visible in code reasoning, math reasoning, long-context understanding, tool use, and multiple agentic tasks.

MiniCPM5-2B public leaderboard

Training Recipe

The training of MiniCPM5-2B is a full-stack practice of UltraData Tiered Data Management, covering three stages: base training, mid-training, and post-training.

During base training, the model goes through stable training and decay training to build core language capability and training stability. It then enters mid-training to further strengthen target capabilities and adapt to the target data distribution. The training corpus is released alongside the model as Ultra-FineWeb, Ultra-FineWeb-L3, UltraX, UltraData-Code and UltraData-Math.

During post-training, we proceed in three steps: SFT, RL, and OPD. We first use 400B tokens of deep-thinking SFT to establish deep-thinking and general chat abilities; the SFT data is released as UltraData-SFT-2605 and Agent SFT data as UltraData-SFT-Agent-2609. We then train specialized RL teachers for math, code, agentic tasks, writing, and related domains(with the corresponding data also open-sourced as UltraData-RL-2609), and use On-Policy Distillation (OPD) to distill these teachers back into one release model.

MiniCPM5-2B Training Recipe

What does RL + OPD bring?

RL + OPD is a key part of MiniCPM5-2B post-training. During the RL stage, we adopted the critic-based algorithm described in JustRL II, substantially improving training stability and achieving significant gains across multiple domains. On the benchmarks listed below, RL + OPD improves reasoning and general capabilities by an average of ↑10.96 points, and agentic capabilities by ↑6.96 points.

OPD merges the capabilities of 16 expert models produced by RL training, including 5 agentic expert models. At each response position, we compute the full-vocabulary reverse KL divergence between student and teacher logits as the advantage estimate, replacing the original verification-based advantage. OPD directly reuses the prompts used to train each RL teacher as distillation data, so no additional corpus construction is required.

MiniCPM5-2B RL + OPD Gains

Quickstart

We recommend using the following sets of sampling parameters for generation: temperature=1.0, top_p=0.95, min_p=0.0.

If you encounter repetitive outputs, try: temperature=1.0, top_p=0.95, min_p=0.0, repetition_penalty=1.05.

Please note that the support for sampling parameters varies according to inference frameworks.

vLLM

pip install "vllm>=0.21"
vllm serve openbmb/MiniCPM5-2B --port 8000
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openbmb/MiniCPM5-2B",
    "messages": [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}],
    "max_tokens": 128,
    "temperature": 1.0, "top_p": 0.95
  }'

SGLang

pip install "sglang[srt]>=0.5.16"
python -m sglang.launch_server --model-path openbmb/MiniCPM5-2B --port 30000
curl http://localhost:30000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openbmb/MiniCPM5-2B",
    "messages": [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}],
    "max_tokens": 128,
    "temperature": 1.0, "top_p": 0.95
  }'

Speculative decoding (DSpark): we also release MiniCPM5-2B-DSpark, a DSpark draft model trained for MiniCPM5-2B. Enable it in SGLang to accelerate decoding while keeping the target model's outputs unchanged:

python -m sglang.launch_server \
  --model-path openbmb/MiniCPM5-2B \
  --trust-remote-code \
  --speculative-algorithm DSPARK \
  --speculative-draft-model-path openbmb/MiniCPM5-2B-DSpark \
  --speculative-dspark-block-size 7 \
  --port 30000

Llama.cpp

llama-server -m MiniCPM5-2B-F16.gguf -a MiniCPM5-2B --port 8080 -ngl 99 -c 8192 --jinja

-c 8192 sets the context length. You can adjust this value as needed.

curl http://localhost:8080/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "MiniCPM5-2B",
        "messages": [{"role": "user", "content": "1+1=?"}],
        "temperature": 1.0, "top_p": 0.95, "min_p": 0.0, "max_tokens": 256
    }'

In llama.cpp, the default min_p=0.05 can lead to repetitive output: it filters out tokens whose probability is below 5% of the highest-probability token, potentially discarding the exact tokens needed to break out of a repetition loop. To prevent this, we set min_p=0.0.

Transformers

pip install -U "transformers>=5.6" accelerate torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "openbmb/MiniCPM5-2B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype="auto",
    device_map="auto",
)
messages = [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}]
inputs = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    enable_thinking=True,
    return_dict=True,
    return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

Tool Calling

For tool / function calling, SGLang is the recommended backend. MiniCPM5-2B emits XML-style tool calls and SGLang's built-in minicpm5 parser converts them to OpenAI-compatible tool_calls natively:

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

GitHub Cookbooks and Agent Skills

MiniCPM5-2B uses the standard LlamaForCausalLM architecture, so mainstream inference engines can load it directly: no custom kernels, no model-code fork. For step-by-step deployment and fine-tuning instructions, use the GitHub cookbooks below. Agent Skills are linked as GitHub resources for users working with Cursor / Claude Code style coding agents.

Deployment

Backend Model format / use case Cookbook Agent Skill
Transformers BF16 / FP16 local Python inference, GPU + CPU transformers.md minicpm5-deploy-transformers
vLLM BF16 / FP16 OpenAI server vllm.md minicpm5-deploy-vllm
SGLang BF16 / FP16 OpenAI server, recommended for tool calling sglang.md minicpm5-deploy-sglang
llama.cpp GGUF local inference, CPU/GPU llama_cpp.md minicpm5-deploy-llama-cpp
Ollama GGUF local on-device runtime ollama.md minicpm5-deploy-ollama
LM Studio GGUF Mac desktop app and OpenAI server lmstudio.md minicpm5-deploy-lmstudio
MLX MLX / 4bit local inference on Apple Silicon mlx.md minicpm5-deploy-mlx
ArcLight GGUF local on-device, CPU, Desktop & Server arclight.md minicpm5-deploy-arclight
LiteRT-LM .litertlm on-device runtime: Android / iOS / desktop / IoT, CPU + GPU litert.md minicpm5-deploy-litert
vLLM Ascend BF16 / FP16 OpenAI server vllm_ascend.md minicpm5-deploy-vllm-ascend

Fine-tuning

Framework Use case Cookbook Agent Skill
TRL + PEFT LoRA / SFT fine-tuning trl.md minicpm5-finetune-trl
LLaMA-Factory Fine-tuning llamafactory.md minicpm5-finetune-llamafactory
ms-swift Fine-tuning ms_swift.md minicpm5-finetune-ms-swift
unsloth Fine-tuning unsloth.md minicpm5-finetune-unsloth

Other Supported Frameworks

In addition to the deployment and fine-tuning frameworks listed above, MiniCPM5-2B is also supported by FlagOS for multi-chip deployment.

FlagOS Overview

To enable large-scale deployment across different AI chips, Beijing Zhiyuan Research Institute, together with numerous research institutions, chip manufacturers, system vendors, and algorithm and software organizations both domestically and internationally, jointly initiated and established the FlagOS Open Source Community.

The FlagOS community is dedicated to building a unified, open-source system software stack for various AI chips, encompassing core open-source projects such as a large-scale operator library, a unified AI compiler, parallel training and inference frameworks, and a unified communication library. It aims to create an open technology ecosystem connecting the “model-system-chip” layers. By enabling “develop once, deploy across chips”, FlagOS unlocks the computational potential of hardware, breaks down the ecosystem silos between different chip software stacks, and effectively reduces migration costs for developers.The FlagOS community fosters an AI hardware and software ecosystem, overcomes single-vendor closed-source monopolies, promotes widespread deployment of AI hardware technologies, and is committed to rooted in China while embracing global collaboration.

Official website express: https://flagos.io

FlagOS: Supporting Multiple AI Chips

Thanks to FlagOS’s unified multi-chip AI system software stack, MiniCPM5-2B was adapted to 9 different AI chips in an extremely short time. Currently, the multi-chip version of MiniCPM5-2B has been released on FlagRelease, FlagOS’s platform for automatic migration, adaptation, and deployment of large models across multi-architecture AI chips. Details are as follows:

Vendor ModelScope Huggingface
Nvidia MiniCPM5-2B-nvidia-FlagOS MiniCPM5-2B-nvidia-FlagOS
Hygon MiniCPM5-2B-hygon-FlagOS MiniCPM5-2B-hygon-FlagOS
Metax MiniCPM5-2B-metax-FlagOS MiniCPM5-2B-metax-FlagOS
Iluvatar MiniCPM5-2B-iluvatar-FlagOS < 10BC8 a href="https://huggingface.co/FlagRelease/MiniCPM5-2B-iluvatar-FlagOS" rel="nofollow">MiniCPM5-2B-iluvatar-FlagOS
Zhenwu MiniCPM5-2B-zhenwu-FlagOS MiniCPM5-2B-zhenwu-FlagOS
Mthreads MiniCPM5-2B-mthreads-FlagOS MiniCPM5-2B-mthreads-FlagOS
Kunlunxin MiniCPM5-2B-kunlunxin-FlagOS MiniCPM5-2B-kunlunxin-FlagOS
Ascend MiniCPM5-2B-ascend-FlagOS MiniCPM5-2B-ascend-FlagOS
ARM-v9 MiniCPM5-2B-Armv9-FlagOS MiniCPM5-2B-Armv9-FlagOS
FlagOS Usage
FlagOS Performance Acceleration on Nvidia

From FlagRelease (Recommendation)

FlagRelease is a platform developed by the FlagOS team for automatic migration, adaptation, and deployment of large models across multi-architecture AI chips. The multi-chip version of MiniCPM5-2B has already been released on FlagRelease. All necessary software packages are pre-installed on the platform, so users do not need to install anything.

FlagRelease Quick Start

Vendor ModelScope Huggingface
Nvidia MiniCPM5-2B-nvidia-FlagOS MiniCPM5-2B-nvidia-FlagOS
Hygon MiniCPM5-2B-hygon-FlagOS MiniCPM5-2B-hygon-FlagOS
Metax MiniCPM5-2B-metax-FlagOS MiniCPM5-2B-metax-FlagOS
Iluvatar MiniCPM5-2B-iluvatar-FlagOS MiniCPM5-2B-iluvatar-FlagOS
Zhenwu MiniCPM5-2B-zhenwu-FlagOS MiniCPM5-2B-zhenwu-FlagOS
Mthreads MiniCPM5-2B-mthreads-FlagOS MiniCPM5-2B-mthreads-FlagOS
Kunlunxin MiniCPM5-2B-kunlunxin-FlagOS MiniCPM5-2B-kunlunxin-FlagOS
Ascend MiniCPM5-2B-ascend-FlagOS MiniCPM5-2B-ascend-FlagOS
ARM-v9 MiniCPM5-2B-Armv9-FlagOS MiniCPM5-2B-Armv9-FlagOS

From Scratch

  • Dependencies: Python 3.12, GLIBC 2.39, GLIBCXX 3.4.33, CXXABI 1.3.15

Installing the FlagOS Operator Library

Official Repository: https://github.com/flagos-ai/FlagGems

pip install flag-gems==4.2.1rc0
pip install triton==3.5.1

Activating Acceleration

You can enable flagGems acceleration by adding the import of flagGems in the source code of vllm where inference is performed.

import flag_gems
flag_gems.enable(record=True,  path="/root/gems.txt")
vllm serve ${model_path} \
--trust-remote-code \
--dtype bfloat16 \
--enforce-eager \
--port ${Port} \
--served-model-name ${model_name} \
--gpu-memory-utilization 0.85
Using FlagOS Unified Multi-Chip Backend Plugin

vllm-plugin-FL is a plugin built for the vLLM inference/service framework. Developed on top of FlagOS’s unified multi-chip backend, it is designed to extend vLLM’s capabilities and performance across a variety of hardware environments.

Using vllm-plugin-FL

Vendor From Scratch From FlagRelease
Nvidia vllm-plugin-FL/MiniCPM5-2B MiniCPM5-2B-ModelScope MiniCPM5-2B-nvidia-FlagOS

🚀 MiniCPM5-1B

MiniCPM5-1B is the first model in the MiniCPM5 series. It is a dense 1B Transformer built for on-device, local deployment, and resource-constrained scenarios, reaching 1B-class open-source SOTA.

Click to expand: highlights, introduction, evaluation, inference setup

Highlights

🏆 1B-class open-source SOTA: compared with strong open-source models in the same size class, MiniCPM5-1B reaches SOTA within this comparison set. Its advantage is most visible in agentic tool use, code generation, and difficult reasoning.

MiniCPM5-1B capability comparison by domain

🧠 Hybrid Reasoning: built-in <think> chat template, switch via enable_thinking. The same checkpoint serves as both a fast assistant and a deliberate reasoner.

🛠️ Deployment / Fine-tuning Resources: the MiniCPM GitHub repo provides single-page cookbooks and Agent Skills for major inference backends and fine-tuning frameworks.

🐱 Desktop Pet: a local-LLM desktop pet driven by MiniCPM5-1B.

Introduction

MiniCPM5-1B is the first checkpoint in the MiniCPM5 series. It is designed for local assistants, coding agents, tool-use workflows, and reasoning scenarios where a compact model is preferred. The model keeps a small deployment footprint while providing native long-context support and both Think / No Think chat modes through the same checkpoint.

Evaluation Results

We compare MiniCPM5-1B with strong open-source models in the same size class, including LFM2.5-1.2B-Thinking, Qwen3-0.6B/think and Qwen3.5-0.8B/think. These are capable baselines; within this comparison set, MiniCPM5-1B reaches 1B-class open-source SOTA, with its advantage most visible in tool use, code generation, and difficult reasoning. This makes it a practical choice for local coding agents, tool assistants, and reasoning assistants.

MiniCPM-5 1B Public Leaderboard

Training Recipe

The training of MiniCPM5-1B is a full-stack practice of UltraData Tiered Data Management, covering three stages: base training, mid-training, and post-training.

During base training, the model goes through stable training and decay training to build core language capability and training stability. It then enters mid-training to further strengthen target capabilities and adapt to the target data distribution. The training corpus is released alongside the model as Ultra-FineWeb, Ultra-FineWeb-L3, and UltraData-Math.

During post-training, we proceed in three steps: SFT, RL, and OPD. We first use 200B tokens of deep-thinking SFT and 200B tokens of hybrid-thinking SFT to establish deep-thinking, hybrid-thinking, and general chat abilities; the SFT data is released as UltraData-SFT-2605. We then train specialized RL teachers for math, code, closed-book QA, writing, and related domains, and use On-Policy Distillation (OPD) to distill these teachers back into one release model.

MiniCPM5-1B Training Recipe

What does RL + OPD bring?

RL + OPD is a key part of MiniCPM5-1B post-training. On math, code and instruction-following tasks, RL + OPD raises the average score by ↑16 points while cutting the share of responses that hit the max-tokens budget by ↓29 percentage points. The figures below show the two-stage Reasoning RL pipeline, score gains, and the drop in overlong responses.

RL combines complementary training signals for reasoning, closed-book QA, writing, instruction following, long-context understanding, and general dialogue. Reasoning RL is based on DAPO-Math-17k (inspired by JustRL's minimalist recipe) and uses a two-stage length schedule to reduce overlong responses while improving reasoning accuracy. We also use TriviaQA, NQ-Open, LongWriter-Zero-RLData, synthesized verifiable RLVR data, and pair-wise RLHF signals to improve reliability, instruction following, and user experience.

MiniCPM5-1B RL Two-stage Pipeline

OPD builds on Thinking Machines Lab's On-Policy Distillation and incorporates implementation improvements from Rethinking On-Policy Distillation. In the RL framework, we use reverse KL divergence as the advantage estimate, replacing the original verification-based advantage. At each response position, we take top-k logits from both the student and teacher models, compute reverse KL on the union of the two token sets, and balance the accuracy of the RKL signal with training efficiency. OPD reuses the in-domain prompts used to train each RL teacher as distillation data, so no additional data curation is required.

MiniCPM5-1B RL + OPD Gains

MiniCPM5-1B RL + OPD Overlong Response Rate Drop

Quickstart

For the three most common inference paths, you can start a service or run local inference as follows:

vLLM (OpenAI-compatible server, NVIDIA GPU):

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

Test request:

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openbmb/MiniCPM5-1B",
    "messages": [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}],
    "max_tokens": 128,
    "temperature": 0.7
  }'

SGLang (OpenAI-compatible server, NVIDIA GPU):

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

Test request:

curl http://localhost:30000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openbmb/MiniCPM5-1B",
    "messages": [{"role": "user", "content": "Who are you? Please briefly introduce yourself."}],
    "max_tokens": 128,
    "temperature": 0.7
  }'

Transformers (local Python inference, CPU or GPU):

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

Local inference test:

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": "Who are you? Please briefly introduce yourself."}]
inputs = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    enable_thinking=False,
    return_dict=True,
    return_tensors="pt",
).to(model.device)

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

Recommended chat template sampling:

Mode Recommended params Enable
Think temperature=0.9, top_p=0.95 enable_thinking=True
No Think temperature=0.7, top_p=0.95 enable_thinking=False

For other backends (llama.cpp / Ollama / LM Studio / MLX), see the cookbooks table below.

With tool calling

For tool / function calling, SGLang is the recommended backend — MiniCPM5-1B emits XML-style tool calls and SGLang's built-in minicpm5 parser converts them to OpenAI-compatible tool_calls natively:

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

Deployment and Fine-tuning Cookbooks and Agent Skills

MiniCPM5-1B uses the standard LlamaForCausalLM architecture, so mainstream inference engines can load it directly: no custom kernels, no model-code fork. To help developers reproduce deployment and fine-tuning workflows, we provide single-page cookbooks paired with Cursor Agent Skills: the cookbooks are for manual execution, while Agent Skills let Cursor / Claude Code agents choose the route based on the target backend, hardware, and data path.

The two top-level skills cover deployment and fine-tuning:

Top-level skill What it does Routes to
minicpm5-deploy Inference router transformers · vllm · sglang · llama-cpp · ollama · lmstudio · mlx · litert
minicpm5-finetune Fine tuning router trl · llamafactory · ms-swift · unsloth · xtuner

In Cursor / Claude Code, you can call them like this: the agent reads the top-level skill, selects the matching sub-skill and cookbook based on the target backend, hardware, and data path, then runs the command and reports back.

@minicpm5-deploy   serve openbmb/MiniCPM5-1B with vLLM on port 8000
@minicpm5-finetune use unsloth + LoRA on /data/my_chat.jsonl, write to ./out

The tables below list the cookbook and sub-skill for each inference backend and fine-tuning framework. Quantized models are not listed as standalone backends; they are described under the inference backend that can load each format.

Inference Deployment (8 backends)

Backend Model format / use case Cookbook Paired Agent Skill
Transformers BF16 / FP16 local Python inference, GPU + CPU docs/deployment/transformers.md minicpm5-deploy-transformers
SGLang BF16 / FP16 OpenAI server, recommended for tool calling docs/deployment/sglang.md minicpm5-deploy-sglang
llama.cpp GGUF local inference, CPU/GPU docs/deployment/llama_cpp.md minicpm5-deploy-llama-cpp
Ollama GGUF local on-device runtime docs/deployment/ollama.md minicpm5-deploy-ollama
LM Studio GGUF Mac desktop app and OpenAI server docs/deployment/lmstudio.md minicpm5-deploy-lmstudio
MLX MLX / 4bit local inference on Apple Silicon docs/deployment/mlx.md minicpm5-deploy-mlx
LiteRT-LM .litertlm on-device runtime: Android / iOS / desktop / IoT, CPU + GPU docs/deployment/litert.md minicpm5-deploy-litert
ArcLight GGUF local on-device, CPU, Desktop & Server docs/deployment/arclight.md minicpm5-deploy-arclight

Fine tuning (5 frameworks)

Framework Cookbook Paired Agent Skill
TRL + PEFT docs/finetune/trl.md minicpm5-finetune-trl
LLaMA-Factory docs/finetune/llamafactory.md minicpm5-finetune-llamafactory
ms-swift docs/finetune/ms_swift.md minicpm5-finetune-ms-swift
unsloth docs/finetune/unsloth.md minicpm5-finetune-unsloth
xtuner docs/finetune/xtuner.md minicpm5-finetune-xtuner

Other Supported Frameworks

In addition to the deployment and fine-tuning frameworks listed above, MiniCPM5-1B is also supported by FlagOS for multi-chip deployment.

Desktop Pet

We also ship OpenBMB/MiniCPM-Desk-Pet, a desktop pet driven locally by MiniCPM5-1B. It uses a thin llama.cpp llama-server sidecar to load the GGUF model and serves an OpenAI-compatible local endpoint to an Electron pet UI.

MiniCPM Desk Pet video demo

The pet supports Apple Silicon / NVIDIA GPU / CPU paths, can work with coding agents such as Cursor, Claude Code, and Codex, and supports LoRA persona switching.

  • User install: grab Clawd-on-Desk-*-arm64.dmg from Releases, then follow the onboarding flow for environment checks, model download, and sidecar startup.
  • Developer run: git clone git@github.com:OpenBMB/MiniCPM-Desk-Pet.git && ./go.sh — see MiniCPM-Desk-Pet/README.md for the full setup.

The pet UI layer is forked from @rullerzhou-afk/clawd-on-desk (AGPL-3.0). On top of the upstream pet runtime, animation packs, and multi-agent integrations, we add the local MiniCPM5-1B sidecar, onboarding flow, and LoRA persona switching. Full attribution in NOTICE.md.

🧪 MiniCPM-SALA

First large-scale Sparse + Linear Attention hybrid for million-token context (2026-02). HuggingFace · ModelScope

Click to expand: highlights, evaluation, inference setup

Highlights

MiniCPM-SALA (Sparse Attention and Linear Attention) is the first large-scale hybrid model effectively integrating sparse and linear attention for million-token context modeling

✅ Hybrid Architecture: combines 25% Sparse Attention (InfLLM-v2) for long-context modeling with 75% Linear Attention (Lightning Attention) for global efficiency.

✅ Inference Efficiency: achieves 3.5× inference speed and lower KV-cache overhead compared with dense baselines.

✅ Million-Token Context: uses HyPE (Hybrid Positional Embedding) to scale to 1M+ tokens while maintaining length generalization.

✅ HALO Adaptation: uses Hybrid Attention via Layer Optimization (HALO), a distillation recipe that transfers dense attention capabilities to the hybrid architecture and mitigates the degradation often seen in pure linear models.

Introduction

MiniCPM-SALA is an efficient hybrid model in which 25% of the layers adopt InfLLM-V2 and the remaining 75% utilize Lightning Attention. This architecture enables inference of one million tokens on consumer GPUs such as the NVIDIA RTX 5090.

  • SALA Hybrid Attention Mechanism

    • Integrates 25% InfLLM-V2 and 75% Lightning Attention, effectively leveraging the granular focus of sparse attention for local details and the high efficiency of linear attention for broad context.
  • Transformer-to-Hybrid Continue Training

    • Circumvents the inefficiencies of cold-start training by performing an architectural transformation on the pre-trained weights, thereby reducing the total training budget to approximately 25% relative to training a comparable model from scratch.
  • HyPE (Hybrid Positional Encoding)

    • Balances short-context and long-context performance, maintaining general capabilities (e.g., knowledge, mathematics, and coding) close to full-attention models such as Qwen3-8B while scoring higher on multiple long-context benchmarks.
  • Efficient Inference on Long Sequences

    • Achieves up to 3.5x the inference speed of Qwen3-8B at a sequence length of 256K tokens on A6000D, supports inference at context lengths of up to 1M tokens on both NVIDIA A6000D and 5090 GPUs, whereas Qwen3-8B fails at this length due to out-of-memory (OOM) errors.

Evaluation Results

Efficiency Evaluation

We benchmarked MiniCPM-SALA (9B) against Qwen3-8B on NVIDIA A6000D and RTX 5090 GPUs to evaluate inference speed and memory efficiency. MiniCPM-SALA achieves up to a 2.5x speedup in time-to-first-token (TTFT) and reduces the memory pressure of full-attention architectures at ultra-long lengths. In this setup, Qwen3-8B runs into OOM errors at extended lengths, while MiniCPM-SALA can process 1M-token contexts on a single consumer-grade RTX 5090.

inference_speed_a6000d

inference_speed_5090

Long-Context Evaluation

MiniCPM-SALA scores higher than the tested open-source LLMs of similar scale on most long-context benchmarks. It achieves the highest scores in the RULER and NoLiMa tests at all context lengths up to 128K, with an overall average score of 38.97.

long_text_evaluation

Ultra-long Context Evaluation

MiniCPM-SALA shows effective length extrapolation, maintaining a score of 81.6 at a 2048K context length despite being trained on up to 520K tokens. The model does this without auxiliary techniques like YaRN, likely due to its NoPE configuration in sparse attention layers.

ultra_long_text_evaluation

Standard Evaluation

MiniCPM-SALA achieves an average score of 76.53 across standard benchmarks, outperforming comparable models such as Qwen3-8B and Falcon-H1R-7B. The architecture maintains robust performance in Knowledge, Code, and Math.

benchmark

Inference

Recommended inference setting: Temperature=0.9.

HuggingFace

Our model is readily compatible with 🤗 Hugging Face transformers. You can perform inference with our model as follows:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_path = "openbmb/MiniCPM-SALA"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, device_map="auto")
model.eval()

prompts = ["My name is", "The capital of China is"]
with torch.no_grad():
    inputs = tokenizer(prompts, return_tensors="pt").to(model.device)
    outputs = model.generate(**inputs)
output_texts = tokenizer.batch_decode(outputs)
print(output_texts)

SGLang

Requirements
  • CUDA 12.x or higher
  • gcc / g++ compiler
  • uv package manager (script will check)
Installation
# Clone repository
git clone -b minicpm_sala https://github.com/OpenBMB/sglang.git
cd sglang

# One-click installation (creates venv and compiles all dependencies)
bash install_minicpm_sala.sh

# Or specify PyPI mirror
bash install_minicpm_sala.sh https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

The installation script performs the following steps:

  1. Creates sglang_minicpm_sala_env virtual environment (Python 3.12)
  2. Clones dependencies to 3rdparty/ (infllmv2) and initializes submodules (sparse_kernel)
  3. Installs MiniCPM-SALA (current repo)
  4. Compiles and installs infllmv2_cuda_impl
  5. Compiles and installs sparse_kernel
  6. Installs tilelang & flash-linear-attention
Usage
# Activate environment
source sglang_minicpm_sala_env/bin/activate

# Launch Inference Server (Replace MODEL_PATH with actual path)
MODEL_PATH=/path/to/your/MiniCPM-SALA

python3 -m sglang.launch_server \
    --model ${MODEL_PATH} \
    --trust-remote-code \
    --disable-radix-cache \
    --attention-backend minicpm_flashinfer \
    --chunked-prefill-size 8192 \
    --max-running-requests 32 \
    --skip-server-warmup \
    --port 31111 \
    --dense-as-sparse
Parameter Description
--trust-remote-code Allow custom code in model
--disable-radix-cache Disable RadixAttention prefix cache
--attention-backend minicpm_flashinfer Use MiniCPM FlashInfer backend
--chunked-prefill-size 8192 Chunked prefill size
--max-running-requests 32 Max concurrent requests
--skip-server-warmup Skip server warmup
--port 31111 Server port
--dense-as-sparse Use dense-as-sparse mode
Manual Installation

If the script doesn't work for you, follow these steps:

# 0. Ensure uv is installed
pip install uv

# 1. Create venv
uv venv --python 3.12 sglang_minicpm_sala_env
source sglang_minicpm_sala_env/bin/activate

# 2. Install SGLang
uv pip install --upgrade pip setuptools wheel
uv pip install -e ./python[all]

# 3. Compile CUDA Extensions
# (Ensure dependencies are cloned to 3rdparty/)
cd 3rdparty/infllmv2_cuda_impl && python setup.py install && cd ../..
cd 3rdparty/sparse_kernel && python setup.py install && cd ../..

# 4. Install extra deps
uv pip install tilelang flash-linear-attention
Q&A

Q: CUDA extension compilation failed?

  • Ensure CUDA 12+ is installed (nvcc --version).
  • Ensure gcc / g++ are available.
  • If CXX is set to clang++ -pthread, manually export CXX=g++.

⚡ MiniCPM4 and MiniCPM4.1 Series

8B-scale trainable sparse attention with hybrid reasoning (2025-09 / 2025-06). MiniCPM4.1-8B · MiniCPM4-8B · ModelScope

Click to expand: highlights, evaluation, inference (HF / vLLM / SGLang / CPM.cu / llama.cpp / Ollama)

Highlights

MiniCPM 4.1-8B is the first open-source reasoning LLM with trainable sparse attention:

✅ Strong Reasoning Capability: Surpasses similar-sized models on 15 tasks!

✅ Fast Generation: 3x decoding speedup for reasoning

✅ Efficient Architecture: Trainable sparse attention, frequency-ranked speculative decoding

Introduction

MiniCPM4 and MiniCPM4.1 series are large language models designed for end-side devices, with efficiency optimizations across model architecture, training data, training algorithms, and inference systems.

  • 🏗️ Efficient Model Architecture:

    • InfLLM-V2 -- Trainable Sparse Attention Mechanism: Adopts a trainable sparse attention mechanism architecture where each token only needs to compute relevance with less than 5% of tokens in 128K long text processing, significantly reducing computational overhead for long texts (InfLLM-V2 Training Kernels)
  • 🧠 Efficient Learning Algorithms:

    • Model Wind Tunnel 2.0 -- Efficient Predictable Scaling: Introduces scaling prediction methods for performance of downstream tasks, enabling more precise model training configuration search
    • BitCPM -- Ternary Quantization: Compresses model parameter bit-width to 3 values, achieving 90% model bit-width reduction
    • Efficient Training Engineering Optimization: Adopts FP8 low-precision computing technology combined with Multi-token Prediction training strategy
  • 📚 High-Quality Training Data:

    • UltraClean -- High-quality Pre-training Data Filtering and Generation: Builds iterative data cleaning strategies based on efficient data verification, open-sourcing high-quality Chinese and English pre-training dataset UltraFinweb
    • UltraChat v2 -- High-quality Supervised Fine-tuning Data Generation: Constructs large-scale high-quality supervised fine-tuning datasets covering multiple dimensions including knowledge-intensive data, reasoning-intensive data, instruction-following data, long text understanding data, and tool calling data
  • ⚡ Efficient Inference and Deployment System:

    • CPM.cu -- Lightweight and Efficient CUDA Inference Framework: Integrates sparse attention, model quantization, and speculative sampling to achieve efficient prefilling and decoding (Inference Kernels and Framework)
    • ArkInfer -- Cross-platform Deployment System: Supports efficient deployment across multiple backend environments, providing flexible cross-platform adaptation capabilities

Evaluation Results

Efficiency Evaluation

On two typical end-side chips, Jetson AGX Orin and RTX 4090, MiniCPM4 and MiniCPM4.1 show faster processing speed than similar-size models in long-text processing tasks. As text length increases, the speed gains become more pronounced. On Jetson AGX Orin, compared with Qwen3-8B, MiniCPM4 and MiniCPM4.1 achieve approximately 7x decoding speed improvement.

benchmark

MiniCPM4.1 achieves 3x decoding speed improvement in reasoning.

benchmark

Comprehensive Evaluation

MiniCPM4 launches end-side versions with 8B and 0.5B parameter scales, both showing competitive performance in their respective categories.

benchmark

MiniCPM4.1 launches an 8B end-side version with competitive performance in deep reasoning mode.

benchmark

Long Text Evaluation

MiniCPM4 is pre-trained on 32K long texts and achieves length extension through YaRN. In the 128K needle-in-a-haystack task, MiniCPM4 maintains stable performance. MiniCPM4.1 is pre-trained on 64K long texts and also uses YaRN for length extension, with stable performance on the 128K needle-in-a-haystack task.

long-niah

Inference

MiniCPM 4.1 can be used with the following frameworks: Huggingface Transformers, SGLang, vLLM, and CPM.cu. For inference efficiency, CPM.cu is a good first option.

MiniCPM4/MiniCPM4.1 supports both dense attention inference and sparse attention inference modes, where vLLM and SGLang currently only support dense inference mode. If you want to use sparse inference mode, please use Huggingface Transformers and CPM.cu.

  • Dense attention inference: vLLM, SGLang, Huggingface Transformers
  • Sparse attention inference: Huggingface Transformers, CPM.cu

Hybrid Reasoning Mode

MiniCPM4.1 supports hybrid reasoning mode, which can be used in both deep reasoning mode and non-reasoning mode. To enable hybrid reasoning mode. User can set enable_thinking=True in tokenizer.apply_chat_template to enable hybrid reasoning mode, and set enable_thinking=False to enable non-reasoning mode. Similarly, user can directly add /no_think at the end of the query to enable non-reasoning mode. If not add any special token or add /think at the end of the query, the model will enable reasoning mode.

# Enable reasoning mode
prompt_text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=True
)
# Enable non-reasoning mode
prompt_text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=False
)

HuggingFace

  • Inference with Dense Attention
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
torch.manual_seed(0)

path = 'openbmb/MiniCPM4.1-8B'
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained(path)
model = AutoModelForCausalLM.from_pretrained(path, torch_dtype=torch.bfloat16, device_map=device, trust_remote_code=True)

# User can directly use the chat interface
# responds, history = model.chat(tokenizer, "Write an article about Artificial Intelligence.", temperature=0.7, top_p=0.7)
# print(responds)

# User can also use the generate interface
messages = [
    {"role": "user", "content": "Write an article about Artificial Intelligence."},
]
prompt_text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
)
model_inputs = tokenizer([prompt_text], return_tensors="pt").to(device)

model_outputs = model.generate(
    **model_inputs,
    max_new_tokens=32768,
    top_p=0.95,
    temperature=0.6
)
output_token_ids = [
    model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs['input_ids']))
]

responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
print(responses)
  • Inference with Sparse Attention This model supports InfLLM v2, a sparse attention mechanism designed for efficient long-sequence inference. It requires the infllmv2_cuda_impl library.

You can install it by running the following command:

git clone -b feature_infer https://github.com/OpenBMB/infllmv2_cuda_impl.git
cd infllmv2_cuda_impl
git submodule update --init --recursive
pip install -e . # or python setup.py install

To enable InfLLM v2, you need to add the sparse_config field in config.json:

{
    ...,
    "sparse_config": {
        "kernel_size": 32,
        "kernel_stride": 16,
        "init_blocks": 1,
        "block_size": 64,
        "window_size": 2048,
        "topk": 64,
        "use_nope": false,
        "dense_len": 8192
    }
}

These parameters control the behavior of InfLLM v2:

  • kernel_size (default: 32): The size of semantic kernels.
  • kernel_stride (default: 16): The stride between adjacent kernels.
  • init_blocks (default: 1): The number of initial blocks that every query token attends to. This ensures attention to the beginning of the sequence.
  • block_size (default: 64): The block size for key-value blocks.
  • window_size (default: 2048): The size of the local sliding window.
  • topk (default: 64): The specifies that each token computes attention with only the top-k most relevant key-value blocks.
  • use_nope (default: false): Whether to use the NOPE technique in block selection for improved performance.
  • dense_len (default: 8192): Since Sparse Attention offers limited benefits for short sequences, the model can use standard (dense) attention for shorter texts. The model will use dense attention for sequences with a token length below dense_len and switch to sparse attention for sequences exceeding this length. Set this to -1 to always use sparse attention regardless of sequence length.
  • Long Context Extension MiniCPM4.1 natively supports context lengths of up to 65,536(64k) tokens. For conversations where the total length (including both input and output) significantly exceeds this limit, we recommend using RoPE scaling techniques for effective handling of long texts. By modifying the LongRoPE factor, the model can stably handle context lengths of up to 131,072 tokens.

You can apply the LongRoPE factor modification by modifying the model files. Specifically, in the config.json file, adjust the rope_scaling fields.

{
    ...,
    "rope_scaling": {
        "rope_type": "longrope",
        "long_factor": [0.9982316082870437, 1.033048153422584, 1.0749920956484724, 1.1255096879436193, 1.1863348602111476, 1.259543828902579, 1.3476188888731149, 1.4535223827776373, 1.5807816745852985, 1.7335856049489526, 1.9168922912975785, 2.1365471404135326, 2.3994084200118646, 2.713475511863602, 3.0880118452194134, 3.533650295140154, 4.062463396503134, 4.687974098908333, 5.425075306704039, 6.289818967956352, 7.29902962722721, 8.6357018163639, 10.210822723989212, 12.053807765671676, 14.193944598909404, 16.65780676784363, 19.463620727694074, 22.628311203524586, 26.150106147261315, 30.02526691405111, 34.23183327975347, 38.73811934094828, 43.502489489729555, 48.47627117965394, 53.61139491762471, 58.857366522037935, 64.16798299215064, 69.51359464319125, 74.86555458220285, 80.21497790341579, 85.55322183307433, 90.89611806932027, 96.26245306514224, 101.68269304046481, 107.18619510219668, 112.82253283014026, 118.63764063163615, 119.88866203644656, 120.9462882391725, 121.837565139014, 122.58663780572562, 123.2147719894291, 123.74049454862576, 124.17980424685767, 124.54641761955492, 124.85202548028222, 125.10654406389756, 125.31835105170659, 125.49450117164764, 125.64091910903052, 125.76256945356558, 125.86360463815589, 125.94749252260765, 126.01712561287873],
        "short_factor": [0.9982316082870437, 1.033048153422584, 1.0749920956484724, 1.1255096879436193, 1.1863348602111476, 1.259543828902579, 1.3476188888731149, 1.4535223827776373, 1.5807816745852985, 1.7335856049489526, 1.9168922912975785, 2.1365471404135326, 2.3994084200118646, 2.713475511863602, 3.0880118452194134, 3.533650295140154, 4.062463396503134, 4.687974098908333, 5.425075306704039, 6.289818967956352, 7.29902962722721, 8.6357018163639, 10.210822723989212, 12.053807765671676, 14.193944598909404, 16.65780676784363, 19.463620727694074, 22.628311203524586, 26.150106147261315, 30.02526691405111, 34.23183327975347, 38.73811934094828, 43.502489489729555, 48.47627117965394, 53.61139491762471, 58.857366522037935, 64.16798299215064, 69.51359464319125, 74.86555458220285, 80.21497790341579, 85.55322183307433, 90.89611806932027, 96.26245306514224, 101.68269304046481, 107.18619510219668, 112.82253283014026, 118.63764063163615, 119.88866203644656, 120.9462882391725, 121.837565139014, 122.58663780572562, 123.2147719894291, 123.74049454862576, 124.17980424685767, 124.54641761955492, 124.85202548028222, 125.10654406389756, 125.31835105170659, 125.49450117164764, 125.64091910903052, 125.76256945356558, 125.86360463815589, 125.94749252260765, 126.01712561287873],
        "original_max_position_embeddings": 65536
    }
}

vLLM

Speculative Decoding

For accelerated inference with speculative decoding using vLLM, follow these steps:

1. Download MiniCPM4.1 Draft Model

First, download the MiniCPM4.1 draft model:

cd /your_path
git clone https://huggingface.co/openbmb/MiniCPM4.1-8B-Eagle3
2. Install EAGLE3-Compatible vLLM

The EAGLE3 vLLM PR has been submitted. For now, use our repository for installation:

git clone https://github.com/LDLINGLINGLING/vllm.git
cd vllm
pip install -e .
3. Launch vLLM Server with Speculative Decoding

Start the vLLM inference server with speculative decoding enabled. Make sure to update the model path in the speculative-config to point to your downloaded MiniCPM4_1-8B-Eagle3-bf16 folder:

VLLM_USE_V1=1 \
vllm serve openbmb/MiniCPM4.1-8B \
--seed 42 \
--trust-remote-code \
--speculative-config '{
  "model": "your/path/MiniCPM4_1-8B-Eagle3-bf16",
  "num_speculative_tokens": 3,
  "method": "eagle3",
  "draft_tensor_parallel_size": 1
}'
4. Client Usage Example

The client usage remains the same for both standard and speculative decoding:

import openai

client = openai.Client(base_url="http://localhost:8000/v1", api_key="EMPTY")

response = client.chat.completions.create(
    model="openbmb/MiniCPM4.1-8B",
    messages=[
        {"role": "user", "content": "Write an article about Artificial Intelligence."},
    ],
    temperature=0.6,
    max_tokens=32768,
    extra_body=dict(add_special_tokens=True),  # Ensures special tokens are added for chat template

)

print(response.choices[0].message.content)
vLLM Configuration Parameters
  • VLLM_USE_V1=1: Enables vLLM v1 API
  • --speculative-config: JSON configuration for speculative decoding
    • model: Path to the draft model for speculation
    • num_speculative_tokens: Number of speculative tokens (default: 3)
    • method: Speculative decoding method (eagle3)
    • draft_tensor_parallel_size: Tensor parallel size for draft model (default: 1)
  • --seed: Random seed for reproducibility
  • --trust-remote-code: Allow execution of remote code for custom models
Standard Inference (Without Speculative Decoding)

For now, you need to install the latest version of vLLM.

pip install -U vllm \
    --pre \
    --extra-index-url https://wheels.vllm.ai/nightly

Then you can inference MiniCPM4.1-8B with vLLM:

from transformers import AutoTokenizer
from vllm import LLM, SamplingParams

model_name = "openbmb/MiniCPM4.1-8B"
prompt = [{"role": "user", "content": "Write an article about Artificial Intelligence."}]

tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
input_text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)

llm = LLM(
    model=model_name,
    trust_remote_code=True,
    max_num_batched_tokens=65536,
    dtype="bfloat16",
    gpu_memory_utilization=0.8,
)
sampling_params = SamplingParams(top_p=0.95, temperature=0.6, max_tokens=32768)

outputs = llm.generate(prompts=input_text, sampling_params=sampling_params)

print(outputs[0].outputs[0].text)

Also, you can start the inference server by running the following command:

Note: In vLLM's chat API, add_special_tokens is False by default. This means important special tokens—such as the beginning-of-sequence (BOS) token—will not be added automatically. To ensure the input prompt is correctly formatted for the model, you should explicitly set extra_body={"add_special_tokens": True}.

vllm serve openbmb/MiniCPM4.1-8B --trust-remote-code

Then you can use the chat interface by running the following code:

import openai

client = openai.Client(base_url="http://localhost:8000/v1", api_key="EMPTY")

response = client.chat.completions.create(
    model="openbmb/MiniCPM4.1-8B",
    messages=[
        {"role": "user", "content": "Write an article about Artificial Intelligence."},
    ],
    temperature=0.6,
    max_tokens=32768,
    extra_body=dict(add_special_tokens=True),  # Ensures special tokens are added for chat template
)

print(response.choices[0].message.content)

SGLang

Speculative Decoding

For accelerated inference with speculative decoding, follow these steps:

1. Download MiniCPM4.1 Draft Model

First, download the MiniCPM4.1 draft model:

cd /your_path
git clone https://huggingface.co/openbmb/MiniCPM4.1-8B-Eagle3
2. Install EAGLE3-Compatible SGLang

The EAGLE3 adaptation PR has been submitted. For now, use our repository for installation:

git clone https://github.com/LDLINGLINGLING/sglang.git
cd sglang
pip install -e .
3. Launch SGLang Server with Speculative Decoding

Start the SGLang server with speculative decoding enabled:

python -m sglang.launch_server \
  --model-path "openbmb/MiniCPM4.1-8B" \
  --host "127.0.0.1" \
  --port 30002 \
  --mem-fraction-static 0.9 \
  --speculative-algorithm EAGLE3 \
  --speculative-draft-model-path "your/path/MiniCPM4_1-8B-Eagle3-bf16" \
  --speculative-num-steps 3 \
  --speculative-eagle-topk 1 \
  --speculative-num-draft-tokens 32 \
  --temperature 0.7
4. Client Usage

The client usage remains the same for both standard and speculative decoding:

import openai

client = openai.Client(base_url=f"http://localhost:30002/v1", api_key="None")

response = client.chat.completions.create(
    model="openbmb/MiniCPM4.1-8B",
    messages=[
        {"role": "user", "content": "Write an article about Artificial Intelligence."},
    ],
    temperature=0.6,
    max_tokens=32768,
)

print(response.choices[0].message.content)

Note: Make sure to update the port number in the client code to match the server port (30002 in the speculative decoding example).

Configuration Parameters
  • --speculative-algorithm EAGLE3: Enables EAGLE3 speculative decoding
  • --speculative-draft-model-path: Path to the draft model for speculation
  • --speculative-num-steps: Number of speculative steps (default: 3)
  • --speculative-eagle-topk: Top-k parameter for EAGLE (default: 1)
  • --speculative-num-draft-tokens: Number of draft tokens (default: 32)
  • --mem-fraction-static: Memory fraction for static allocation (default: 0.9)
Standard Inference (Without Speculative Decoding)

For now, you need to install our forked version of SGLang.

git clone -b openbmb https://github.com/OpenBMB/sglang.git
cd sglang

pip install --upgrade pip
pip install -e "python[all]"

You can start the inference server by running the following command:

python -m sglang.launch_server --model openbmb/MiniCPM4.1-8B --trust-remote-code --port 30000 --chat-template chatml

Then you can use the chat interface by running the following command:

import openai

client = openai.Client(base_url=f"http://localhost:30000/v1", api_key="None")

response = client.chat.completions.create(
    model="openbmb/MiniCPM4.1-8B",
    messages=[
        {"role": "user", "content": "Write an article about Artificial Intelligence."},
    ],
    temperature=0.6,
    max_tokens=32768,
)

print(response.choices[0].message.content)

CPM.cu

We recommend using CPM.cu for the inference of MiniCPM4 and MiniCPM4.1. CPM.cu is a CUDA inference framework developed by OpenBMB, which integrates efficient sparse, speculative sampling, and quantization techniques, fully leveraging the efficiency advantages of MiniCPM4 and MiniCPM4.1.

You can install CPM.cu by running the following command:

git clone https://github.com/OpenBMB/CPM.cu.git --recursive
cd CPM.cu
python3 setup.py install

You can run the following command to test the speed of the model.

python3 tests/long_prompt_gen.py # generate prompt.txt
python3 tests/test_generate.py --prompt-file prompt.txt

You can run the following command to infer with EAGLE3 speculative decoding algorithm.

python3 -m cpmcu.cli \
    --model-path $BASE_MODEL_PATH \
    --draft-model-path $EAGLE3_DRAFT_MODEL_PATH \
    --prompt-text "Tell me about Tsinghua University" \
    --use-eagle3 true

For more details about CPM.cu, please refer to the repo of CPM.cu.

llama.cpp and Ollama

We also support inference with llama.cpp and Ollama.

llama.cpp

You can download the GGUF format of MiniCPM4.1-8B model from huggingface and run it with llama.cpp for efficient CPU or GPU inference.

# case 1: main-cli
./build/bin/llama-cli -m MiniCPM4.1-8B-Q4_K_M.gguf -p "Write an article about Artificial Intelligence." -n 1500

# case 2: server
## launch server
./build/bin/llama-server -m MiniCPM4.1-8B-Q4_K_M.gguf --host 127.0.0.1 --port 8080 -c 4096 -fa on &

## send request
curl -X POST http://127.0.0.1:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [{"role": "user", "content": "Write an article about Artificial Intelligence."}],
    "max_tokens": 1500
  }'
Ollama

Please refer to model hub for model download. After installing ollama package, you can use MiniCPM4.1 with following commands:

ollama run openbmb/minicpm4.1

Quantization (BitCPM4) and MiniCPM4 applications (Survey / MCP / Intel AIPC Client): see docs/README-legacy.md.

📄 LICENSE

Model LICENSE

  • This repository and MiniCPM models are released under the Apache-2.0 License.

Statement

  • As a language model, MiniCPM generates content by learning from a vast amount of text.
  • However, it does not possess the ability to comprehend or express personal opinions or value judgments.
  • Any content generated by MiniCPM does not represent the viewpoints or positions of the model developers.
  • Therefore, when using content generated by MiniCPM, users should take full responsibility for evaluating and verifying it on their own.

🏛 Institutions

This project is developed by the following institutions:

📚 Citation

  • Please cite our paper: MiniCPM4 if you find our work valuable.
@article{minicpm4,
  title={Minicpm4: Ultra-efficient llms on end devices},
  author={MiniCPM, Team},
  journal={arXiv preprint arXiv:2506.07900},
  year={2025}
}

About

MiniCPM5: SOTA on-device LLMs, small yet powerful.

Resources

Stars

12.0k stars

Watchers

90 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0