[2025.09.05]
MiniCPM4.1
series are released! This series is a hybrid reasoning model, which can be used in both deep reasoning mode and non-reasoning mode. 🔥🔥🔥
[2025.06.06]
MiniCPM4
series are released! This model achieves ultimate efficiency improvements while maintaining optimal performance at the same scale! It can achieve over 5x generation acceleration on typical end-side chips! You can find technical report
here
.🔥🔥🔥
MiniCPM4 and MiniCPM4.1 Series
MiniCPM4 and MiniCPM4.1 series are highly efficient large language models (LLMs) designed explicitly for end-side devices, which achieves this efficiency through systematic innovation in four key dimensions: model architecture, training data, training algorithms, and inference systems.
MiniCPM4.1-8B
: The latest version of MiniCPM4, with 8B parameters, support fusion thinking. (
<-- you are here
)
BitCPM4-0.5B
: Extreme ternary quantization of MiniCPM4-0.5B, achieving 90% bit width reduction
BitCPM4-1B
: Extreme ternary quantization of MiniCPM3-1B, achieving 90% bit width reduction
MiniCPM4-Survey
: Generates trustworthy, long-form survey papers from user queries
MiniCPM4-MCP
: Integrates MCP tools to autonomously satisfy user requirements
Introduction
MiniCPM4 and MiniCPM4.1 are extremely efficient edge-side large model that has undergone efficient optimization across four dimensions: model architecture, learning algorithms, training data, and inference systems, achieving ultimate efficiency improvements.
🏗️
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
🧠
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 -- Ultimate Ternary Quantization: Compresses model parameter bit-width to 3 values, achieving 90% extreme 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 System:
CPM.cu -- Lightweight and Efficient CUDA Inference Framework: Integrates sparse attention, model quantization, and speculative sampling to achieve efficient prefilling and decoding
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
MiniCPM4.1 natively supports context lengths of up to 65,536(64k) tokens. To reproduce the long-text acceleration effect in the paper, we recommend using the LongRoPE factors that have been validated. Change the
rope_scaling
field in the
config.json
file as the following to enable LongRoPE.
After modification, you can run the following command to reproduce the long-context acceleration effect (the script will automatically download the model weights from HuggingFace)
python3 tests/test_generate.py
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 "Write an article about Artificial Intelligence." \
--use-eagle3 true
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.
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 inrange(len(model_inputs['input_ids']))
]
responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
print(responses)
MiniCPM4.1-8B 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:
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.
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. We have validated the model's performance on context lengths of up to 131,072 tokens by modifying the LongRoPE factor.
You can apply the LongRoPE factor modification by modifying the model files. Specifically, in the
config.json
file, adjust the
rope_scaling
fields.
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:
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
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)
Evaluation Results
On two typical end-side chips, Jetson AGX Orin and RTX 4090, MiniCPM4 demonstrates significantly faster processing speed compared to similar-size models in long text processing tasks. As text length increases, MiniCPM4's efficiency advantage becomes more pronounced. On the Jetson AGX Orin platform, compared to Qwen3-8B, MiniCPM4 achieves approximately 7x decoding speed improvement.
MiniCPM4.1 achieves 3x decoding speed improvement in reasoning.
Comprehensive Evaluation
MiniCPM4.1 launches end-side versions with 8B parameter scale, both achieving best-in-class performance in their respective categories.
Long Text Evaluation
MiniCPM4 is pre-trained on 32K long texts and achieves length extension through YaRN technology. In the 128K long text needle-in-a-haystack task, MiniCPM4 demonstrates outstanding performance.
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.
LICENSE
This repository and MiniCPM models are released under the
Apache-2.0
License.
Citation
Please cite our
paper
if you find our work valuable.
@article{minicpm4,
title={{MiniCPM4}: Ultra-Efficient LLMs on End Devices},
author={MiniCPM Team},
year={2025}
}
Runs of openbmb MiniCPM4.1-8B on huggingface.co
25.5K
Total runs
0
24-hour runs
435
3-day runs
970
7-day runs
411
30-day runs
More Information About MiniCPM4.1-8B huggingface.co Model
MiniCPM4.1-8B huggingface.co is an AI model on huggingface.co that provides MiniCPM4.1-8B's model effect (), which can be used instantly with this openbmb MiniCPM4.1-8B model. huggingface.co supports a free trial of the MiniCPM4.1-8B model, and also provides paid use of the MiniCPM4.1-8B. Support call MiniCPM4.1-8B model through api, including Node.js, Python, http.
MiniCPM4.1-8B huggingface.co is an online trial and call api platform, which integrates MiniCPM4.1-8B's modeling effects, including api services, and provides a free online trial of MiniCPM4.1-8B, you can try MiniCPM4.1-8B online for free by clicking the link below.
openbmb MiniCPM4.1-8B online free url in huggingface.co:
MiniCPM4.1-8B is an open source model from GitHub that offers a free installation service, and any user can find MiniCPM4.1-8B on GitHub to install. At the same time, huggingface.co provides the effect of MiniCPM4.1-8B install, users can directly use MiniCPM4.1-8B installed effect in huggingface.co for debugging and trial. It also supports api for free installation.