---
title: MiniCPM5-15B-A2.5B-LiteRT
canonical_url: "https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-LiteRT"
md_url: "https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-LiteRT.md"
repository: OpenBMB/MiniCPM5-15B-A2.5B-LiteRT
last_updated: 2026-12-03
license: apache-2.0
pipeline_tag: text-generation
tasks:
  - text-generation
base_model_relation: finetune
language:
  - en
  - zh
downloads: 5
stars: 0
tags:
  - minicpm
  - minicpm5
  - moe
  - text-generation
  - long-context
  - tool-calling
  - on-device
  - edge-ai
---

# MiniCPM5-15B-A2.5B-LiteRT

> MiniCPM5-15B-A2.5B-LiteRT - OpenBMB 在 ModelScope 开源的模型。MiniCPM Tech Report | MiniCPM Wiki(Chinese) | GitHub Repo | UltraData | Online Demo

OpenBMB/MiniCPM5-15B-A2.5B-LiteRT 是 ModelScope 魔搭社区上的text-generation模型，采用 apache-2.0 许可。

- **Repository**: OpenBMB/MiniCPM5-15B-A2.5B-LiteRT
- **License**: apache-2.0
- **Tasks**: text-generation
- **Tags**: minicpm, minicpm5, moe, text-generation, long-context, tool-calling, on-device, edge-ai
- **Downloads**: 5
- **Stars**: 0
- **Last updated**: 2026-12-03

Source: https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-LiteRT

---

<div align="center">
<img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM/main/assets/minicpm_logo.png" width="500em" />
</div>

<p align="center">
<a href="https://arxiv.org/pdf/2506.07900" target="_blank">MiniCPM Tech Report</a> |
<a href="https://modelbest.feishu.cn/wiki/UtWxwcERfiRIpIkBOjuc3h9tn1D" target="_blank">MiniCPM Wiki(Chinese)</a> |
<a href="https://github.com/OpenBMB/MiniCPM" target="_blank">GitHub Repo</a> |
<a href="https://openbmb.cn/ultradata/" target="_blank">UltraData</a> |
<a href="https://huggingface.co/spaces/openbmb/MiniCPM5-15B-A2.5B-Demo" target="_blank">Online Demo</a>
</p>

<p align="center">
English |
<a href="https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-LiteRT/blob/main/README-cn.md" target="_blank">中文</a>
</p>

## ✨ 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](https://raw.githubusercontent.com/OpenBMB/MiniCPM/main/assets/minicpm5/minicpm5-15b-a2.5b/public_leaderboard_radar_en.png)

## 🎬 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.

<p align="center">
<a href="https://youtu.be/wLtfCsiK6BQ"><img src="https://img.youtube.com/vi/wLtfCsiK6BQ/maxresdefault.jpg" width="720"></a>
</p>

## Model List

Use this list to choose the model format that matches your runtime:

**MiniCPM5-15B-A2.5B**

- **[MiniCPM5-15B-A2.5B](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B) · BF16 final release (post-trained with RL + OPD)
- **[MiniCPM5-15B-A2.5B-SFT](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-SFT)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-SFT) · BF16 SFT-only checkpoint (before RL / OPD)
- **[MiniCPM5-15B-A2.5B-Midtrain](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-Midtrain)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-Midtrain) · BF16 mid-training checkpoint (before SFT)
- **[MiniCPM5-15B-A2.5B-Base](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-Base)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-Base) · BF16 base checkpoint (pre-training only)
- **[MiniCPM5-15B-A2.5B-GGUF](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-GGUF)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-GGUF) · GGUF for llama.cpp / Ollama / LM Studio
- **[MiniCPM5-15B-A2.5B-Q3_gud-LCO-GGUF](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-Q3_gud-LCO-GGUF)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-Q3_gud-LCO-GGUF) · Q3_gud quantized GGUF version for [llama.cpp-omni](https://github.com/tc-mb/llama.cpp-omni)
- **[MiniCPM5-15B-A2.5B-Q4_K_M-LCO-GGUF](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-Q4_K_M-LCO-GGUF)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-Q4_K_M-LCO-GGUF) · Q4_K_M quantized GGUF version for [llama.cpp-omni](https://github.com/tc-mb/llama.cpp-omni)
- **[MiniCPM5-15B-A2.5B-MLX](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-MLX)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-MLX) · MLX 4-bit for MLX-VLM on Apple Silicon
- **[MiniCPM5-15B-A2.5B-GPTQ](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-GPTQ)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-GPTQ) · GPTQ / 4bit quantized model
- **[MiniCPM5-15B-A2.5B-DSpark](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-DSpark)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-DSpark) · DSpark draft model for inference acceleration
- **[MiniCPM5-15B-A2.5B-DSpark-GGUF](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-DSpark-GGUF)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-DSpark-GGUF) · GGUF version of the DSpark draft model
- **[MiniCPM5-15B-A2.5B-LiteRT](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-LiteRT)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-15B-A2.5B-LiteRT) · the LiteRT-LM version of MiniCPM5-15B-A2.5B **👈 you are here**

**Other models in the MiniCPM5 series:**

<details>
<summary>MiniCPM5-2B</summary>

- **[MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B) · BF16 final release (post-trained with RL + OPD)
- **[MiniCPM5-2B-SFT](https://huggingface.co/openbmb/MiniCPM5-2B-SFT)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B-SFT) · BF16 SFT-only checkpoint (before RL / OPD)
- **[MiniCPM5-2B-Midtrain](https://huggingface.co/openbmb/MiniCPM5-2B-Midtrain)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B-Midtrain) · BF16 mid-training checkpoint (before SFT)
- **[MiniCPM5-2B-Base](https://huggingface.co/openbmb/MiniCPM5-2B-Base)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B-Base) · BF16 base checkpoint (pre-training only)
- **[MiniCPM5-2B-GGUF](https://huggingface.co/openbmb/MiniCPM5-2B-GGUF)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B-GGUF) · GGUF for llama.cpp / Ollama / LM Studio
- **[MiniCPM5-2B-MLX](https://huggingface.co/openbmb/MiniCPM5-2B-MLX)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B-MLX) · MLX / 4bit for Apple Silicon
- **[MiniCPM5-2B-GPTQ](https://huggingface.co/openbmb/MiniCPM5-2B-GPTQ)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B-GPTQ) · GPTQ / 4bit quantized model
- **[MiniCPM5-2B-DSpark](https://huggingface.co/openbmb/MiniCPM5-2B-DSpark)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B-DSpark) · DSpark draft model for inference acceleration
- **[MiniCPM5-2B-DSpark-GGUF](https://huggingface.co/openbmb/MiniCPM5-2B-DSpark-GGUF)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-2B-DSpark-GGUF) · GGUF version of DSpark draft model
- **[MiniCPM5-2B-LiteRT](https://huggingface.co/litert-community/MiniCPM5-2B)** · [ModelScope](https://www.modelscope.cn/models/litert-community/MiniCPM5-2B) · the LiteRT-LM version of MiniCPM5-2B

</details>

<details>
<summary>MiniCPM5-1B</summary>

- **[MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-1B) · BF16 final release (post-trained with RL + OPD)
- **[MiniCPM5-1B-SFT](https://huggingface.co/openbmb/MiniCPM5-1B-SFT)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-1B-SFT) · BF16 SFT-only checkpoint (before RL / OPD)
- **[MiniCPM5-1B-Base](https://huggingface.co/openbmb/MiniCPM5-1B-Base)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-1B-Base) · BF16 base checkpoint (pre-training only)
- **[MiniCPM5-1B-GGUF](https://huggingface.co/openbmb/MiniCPM5-1B-GGUF)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-1B-GGUF) · GGUF for llama.cpp / Ollama / LM Studio
- **[MiniCPM5-1B-MLX](https://huggingface.co/openbmb/MiniCPM5-1B-MLX)** · [ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-1B-MLX) · MLX / 4bit for Apple Silicon

</details>

## Model Information

MiniCPM5-15B-A2.5B has the following features:

- **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

## 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.

## 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](https://raw.githubusercontent.com/OpenBMB/MiniCPM/main/assets/minicpm5/minicpm5-15b-a2.5b/public_leaderboard_en.png)

See [`eval/imo-harness`](https://github.com/OpenBMB/MiniCPM/blob/main/eval/imo-harness/README.md) 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](https://arxiv.org/pdf/2602.09003)**, 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](https://huggingface.co/datasets/openbmb/Ultra-FineWeb), [Ultra-FineWeb-L3](https://huggingface.co/datasets/openbmb/Ultra-FineWeb-L3), [UltraX](https://huggingface.co/datasets/openbmb/UltraX-Preview), [UltraData-Code](https://huggingface.co/datasets/openbmb/UltraData-Code) and [UltraData-Math](https://huggingface.co/datasets/openbmb/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](https://huggingface.co/datasets/openbmb/UltraData-SFT-2605) and [UltraData-SFT-Agent-2609](https://huggingface.co/datasets/openbmb/UltraData-SFT-Agent-2609).

![MiniCPM5-15B-A2.5B Training Recipe](https://raw.githubusercontent.com/OpenBMB/MiniCPM/main/assets/minicpm5/minicpm5-15b-a2.5b/training_recipe.jpg)

### 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](https://panhaoxuan.notion.site/justrl-ii-scaling-small-llms-to-128k-reasoning-with-a-critic) 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](https://raw.githubusercontent.com/OpenBMB/MiniCPM/main/assets/minicpm5/minicpm5-15b-a2.5b/rl_opd_gain.png)

## Quickstart

> [!Tip]
> 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.

### LiteRT-LM

This repository hosts three pre-converted bundles. They require [`litert-lm`](https://github.com/google-ai-edge/LiteRT-LM) 0.20.0 or newer:

```bash
uv tool install litert-lm

# the first run downloads the 8.28 GB mixed bundle (the recommended file)
litert-lm run --from-huggingface-repo=openbmb/MiniCPM5-15B-A2.5B-LiteRT \
    MiniCPM5-15B-A2.5B_mixed.litertlm --backend gpu --prompt "What is the capital of France?"
```

Drop `--backend gpu` to run on the CPU, and pass `--thinking false` for direct answers. The CLI is greedy by default; `--temperature` and `--top-p` only take effect together with a `--top-k` above 1.

| File | Quantization | Size | Use when |
| --- | --- | --- | --- |
| `MiniCPM5-15B-A2.5B_mixed.litertlm` | int8 non-expert linears, int4 weight-only experts | 8.28 GB | default choice; runs on 16 GB machines |
| `MiniCPM5-15B-A2.5B_int8.litertlm` | int8 weights and activations, int8 experts | 15.08 GB | quality first; use on ≥32 GB machines |
| `MiniCPM5-15B-A2.5B_int4.litertlm` | int4 non-expert linears, int4 weight-only experts | 7.58 GB | size and speed over quality |

All three embed the checkpoint's chat template and default to a 4096-token context (`--max-num-tokens` to raise it; the checkpoint supports up to 524,288 positions).

For the OpenAI-compatible server, memory requirements, accuracy and speed matrices, and platform pitfalls, see the [LiteRT-LM deployment guide](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/litert.md). For vLLM, SGLang, llama.cpp or Transformers, use the [original model](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B).

## Conversion Recipe

These bundles are converted from the checkpoint in three stages — patch modeling, export fp32, quantize and pack. Each stage below says what changed and why.

**Why not the stock path.** MiniCPM5-2B/1B are dense and convert with the official `models/minicpm5` `litert-torch export_hf` command. This model is a 15 B sparse MoE: of its 28 layers, layer 0 is dense, and layers 1–27 each hold 160 routed experts with top-16 routing plus one shared expert. A dense-routed export expands every expert into its own ops — 25,881 `FULLY_CONNECTED` ops across the prefill and decode graphs and ~15 GB of weights read per token. The bundles therefore keep the sparse form: 27 `moe` custom ops carry all experts, and XNNPACK (CPU) and WebGPU (Metal / Vulkan) can execute them directly.

**Toolchain.** Python 3.12, PyTorch 2.14.1, Transformers 5.23.0, litert-converter 0.5.0, ai-edge-litert 2.3.0, litert-lm-builder 0.19.2, litert-lm 0.20.0. Two MoE-specific requirements were ahead of their stable wheels at build time: **litert-torch** with commit `c00d5ff` — the `activation="silu"` support of the `moe_experts` lowering (stable 0.10.0 predates it) — and **litert-quantizer** (the LiteRT quantizer, renamed from `ai-edge-quantizer`) with its MoE path: the 7→10-input `moe` rewrite and the multi-axis `quantized_dimensions` of Step 3 (stable 0.11.0 predates it; the build used a LiteRT checkout at `3484e9d7`). No manual build is needed: `pip install litert-torch-nightly litert-quantizer-nightly` covers both — the nightlies are cut from main as `0.11.0.dev*` / `0.12.0.dev*` — and stable releases at or beyond those versions will include them.

**Step 1 — model copy and modeling changes.** Copy `modeling_minicpm.py` from the checkpoint and patch it:

- **Routing.** The original picks top-k weights with `torch.gather`, but `gather` compiles to `GATHER_ND` plus `SELECT_V2`, which the GPU delegates reject — and LiteRT-LM refuses a partially delegated graph, so engine creation fails. Replace it with a one-hot sum, `(onehot * scores.unsqueeze(1)).sum(dim=2)`, which produces only `EQUAL/MUL/SUM` and keeps the graph intact.
- **Expert layout.** Stack the 160 experts' `gate/up/down` weights in the OHWI order the `moe` op expects, and drop the original `ModuleList`, so the extra memory is at most one layer's worth. `per_expert_scale` must be `[1,1,1,160]`: the WebGPU kernel indexes by that shape.
- **Expert computation.** Call `litert_torch.moe_experts(..., num_experts=160, num_active_experts=16, activation="silu")`.

**Step 2 — fp32 export.** Export with `litert_torch` under `LITERT_MOE_SPARSE=1`; the key setting is `quantization_recipe='none'`: keep everything in fp32 and leave all quantization to the next step, otherwise the quantizer mangles the custom op's scales. `cache_length=4096` and `prefill_logits=False` shape the output. Peak memory is about 137 GiB, and the result is a 55 GiB fp32 graph. Prefill holds 26 `moe` ops and decode 27: prefill computes no logits (`prefill_logits=False`), so the final layer's MoE is dead code and is eliminated.

**Step 3 — quantize and pack.** Quantize with `litert_quantizer` (nightly wheel or LiteRT checkout — see Toolchain; stable wheels lack the MoE path). The stock `dynamic_wi8_afp32` recipe quantizes weights along a single axis, and the `moe` op then fails to load with "missing BlockwiseQuantization details". So register a multi-axis, channelwise recipe for it (quantizing along both the expert and output-channel dimensions):

```python
rp.add_dynamic_config(regex='.*', operation_name=ALL_SUPPORTED, num_bits=base_bits)
rp.add_quantization_config(
    regex='.*', operation_name=TFLOperationName.CUSTOM_OP,
    op_config=qtyping.OpQuantizationConfig(
        weight_tensor_config=qtyping.TensorQuantizationConfig(
            num_bits=expert_bits, symmetric=True,
            granularity=qtyping.QuantGranularity.CHANNELWISE,
            quantized_dimensions=[0, 1]),
        compute_precision=qtyping.ComputePrecision.INTEGER,
        explicit_dequantize=False))
```

- `(expert_bits, base_bits)` has three settings: int8 `(8,8)`, mixed `(4,8)`, int4 `(4,4)`. In the `moe` op the int4 is weight-only — the kernel dequantizes and computes in fp32; the int4 file's other linears are int4-dynamic.
- MSE/Hadamard/GPTQ do not support `CUSTOM:moe`, so all three files use min-max scales.
- Pack with `litert_lm_builder`: write the pbtext, tokenizer and the prefill/decode and embedder sections into the `.litertlm`; the metadata is the official proto with `min_runtime_version` set to `"0.20.0"`.

**Artifacts and verification.**

| File | Quantization | Size |
| --- | --- | ---: |
| `MiniCPM5-15B-A2.5B_mixed.litertlm` | int8 rest, int4 experts | 8.28 GB |
| `MiniCPM5-15B-A2.5B_int8.litertlm` | int8 everywhere | 15.08 GB |
| `MiniCPM5-15B-A2.5B_int4.litertlm` | int4 everywhere | 7.58 GB |

Against a float32 HF reference (mean NLL 1.414), NLL over 6 Chinese/English prompts is 1.35–1.60 for int8, 1.47–1.63 for mixed and 4.27–4.85 for int4, depending on the platform.

## 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.

```python
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**](https://github.com/farion1231/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](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/tool_usage.md).

## API Platform

MiniCPM5-15B-A2.5B is also available on the [MiniCPM Open Platform for On-Device Open-Source Models](https://platform.modelbest.cn/). 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](https://platform.modelbest.cn/console/docs) for API key application and full usage details.

For questions, issues, or feedback, please reach us on [Discord](https://discord.gg/3cGQn9b3YM) or our [Feishu group](https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=559o65ab-9086-442a-96c9-cf382e80b22d).

## Running on iOS

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

1. Install [MiniCPM-V-Apps](https://testflight.apple.com/join/yNKyFZwW) 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`](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B-Q3_gud-LCO-GGUF).
See [MiniCPM-V-Apps repository](https://github.com/OpenBMB/MiniCPM-V-Apps) for the app and source code. For detailed installation instructions and frequently asked questions, see [run MiniCPM5-15B-A2.5B on iOS](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/minicpm5_on_ios.md).

## 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](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/transformers.md) | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-transformers/SKILL.md) |
| vLLM            | BF16 / FP16 OpenAI server                                               | [vllm.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/vllm.md)                 | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-vllm/SKILL.md)         |
| SGLang          | BF16 / FP16 OpenAI server, recommended for tool calling                 | [sglang.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/sglang.md)             | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-sglang/SKILL.md)       |
| llama.cpp       | GGUF local inference, CPU/GPU                                           | [llama_cpp.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/llama_cpp.md)       | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-llama-cpp/SKILL.md)    |
| Ollama          | GGUF local on-device runtime                                            | [ollama.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/ollama.md)             | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-ollama/SKILL.md)       |
| LM Studio       | GGUF desktop app and OpenAI server                                  | [lmstudio.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/lmstudio.md)         | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-lmstudio/SKILL.md)     |
| MLX-VLM             | MLX affine 4-bit inference on Apple Silicon                             | [mlx.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/mlx.md)                   | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-mlx/SKILL.md)          |
| vLLM Ascend     | BF16 / FP16 OpenAI server                                               | [vllm_ascend.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/vllm_ascend.md)   | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-vllm-ascend/SKILL.md)  |
| LiteRT-LM       | `.litertlm` on-device runtime: desktop / server, CPU + GPU  | [litert.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/deployment/minicpm5-15b-a2.5b/litert.md)             | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-deploy-litert/SKILL.md)       |

### Fine-tuning

| Framework     | Use case               | Cookbook                                                                                                         | Agent Skill                                                                                                       |
| ------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| TRL + PEFT    | LoRA / SFT fine-tuning | [trl.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/finetune/minicpm5-15b-a2.5b/trl.md)                   | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-finetune-trl/SKILL.md)          |
| LLaMA-Factory | Fine-tuning            | [llamafactory.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/finetune/minicpm5-15b-a2.5b/llamafactory.md) | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-finetune-llamafactory/SKILL.md) |
| ms-swift      | Fine-tuning            | [ms_swift.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/finetune/minicpm5-15b-a2.5b/ms_swift.md)         | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-finetune-ms-swift/SKILL.md)     |
| unsloth       | Fine-tuning            | [unsloth.md](https://github.com/OpenBMB/MiniCPM/blob/main/docs/finetune/minicpm5-15b-a2.5b/unsloth.md)           | [SKILL.md](https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-15b-a2p5b-finetune-unsloth/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](https://flagos.io/) · Developer documentation: [docs.flagos.io](https://docs.flagos.io/en/latest/)

<details>
<summary>FlagOS multi-chip support and usage</summary>

#### 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](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-BF16-zhenwu-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-BF16-zhenwu-FlagOS)       |
| NVIDIA          | BF16      | [ModelScope](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-BF16-nvidia-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-BF16-nvidia-FlagOS)       |
| Huawei Ascend   | BF16      | [ModelScope](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-BF16-ascend-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-BF16-ascend-FlagOS)       |
| Hygon           | BF16      | [ModelScope](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-BF16-hygon-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-BF16-hygon-FlagOS)         |
| Kunlunxin       | BF16      | [ModelScope](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-BF16-kunlunxin-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-BF16-kunlunxin-FlagOS) |
| MetaX           | BF16      | [ModelScope](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-BF16-metax-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-BF16-metax-FlagOS)         |
| Moore Threads   | BF16      | [ModelScope](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-BF16-mthreads-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-BF16-mthreads-FlagOS)   |
| Iluvatar        | BF16      | [ModelScope](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-BF16-iluvatar-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-BF16-iluvatar-FlagOS)   |
| ARM CPU         | W4A8      | [ModelScope](https://modelscope.cn/models/FlagRelease/MiniCPM5-15B-A2.5B-W4A8-arm-FlagOS) / [Hugging Face](https://huggingface.co/FlagRelease/MiniCPM5-15B-A2.5B-W4A8-arm-FlagOS)             |

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**:

```bash
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:

- **vLLM-plugin-FL**: [GitHub](https://github.com/flagos-ai/vllm-plugin-FL/blob/main/README.md)
- **SGLang-plugin-FL**: [GitHub](https://github.com/flagos-ai/sglang-plugin-FL/blob/main/README.md)

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.

```bash
: "${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](https://github.com/flagos-ai/FlagTree) and [FlagCX communication library](https://github.com/flagos-ai/FlagCX) 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.

```python
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}")
```

```bash
VLLM_PLUGINS=fl python inference.py
```

</details>

## Limitations and Disclaimer

This model has no autonomous intent or legal personhood; its outputs are text generated from statistical patterns and may be inaccurate, biased, or offensive, and may be manipulated by carefully crafted prompts ("jailbreaks") into producing unintended content. Its responses on sensitive topics such as politics, health, finance, and law are not reviewed by experts and should not be treated as professional advice.

This model is provided "**AS IS**", without warranty of any kind, express or implied, and the developers are not liable for any damages arising from its use. Users must employ the model only for lawful, compliant, and ethical purposes, configure their own safeguards, and label AI-generated content where required; deliberate jailbreaking, injection attacks, or inducing harmful output is prohibited, and any such testing is at the user's own risk.

## License

This repository and MiniCPM model weights are released under the [Apache-2.0](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE) License.

## Citation

Please cite our paper if you find our work valuable:

```bibtex
@article{minicpm4,
  title={Minicpm4: Ultra-efficient llms on end devices},
  author={MiniCPM, Team},
  journal={arXiv preprint arXiv:2506.07900},
  year={2025}
}
```
