Text Generation
Transformers
Safetensors
English
Chinese
qwen3
minicpm
minicpm5
llama
long-context
tool-calling
on-device
edge-ai
custom_code
text-generation-inference
Instructions to use openbmb/MiniCPM5-2B-DSpark with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM5-2B-DSpark with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/MiniCPM5-2B-DSpark", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM5-2B-DSpark", trust_remote_code=True) model = AutoModel.from_pretrained("openbmb/MiniCPM5-2B-DSpark", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openbmb/MiniCPM5-2B-DSpark with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/MiniCPM5-2B-DSpark" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM5-2B-DSpark", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/openbmb/MiniCPM5-2B-DSpark
- SGLang
How to use openbmb/MiniCPM5-2B-DSpark with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "openbmb/MiniCPM5-2B-DSpark" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM5-2B-DSpark", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "openbmb/MiniCPM5-2B-DSpark" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM5-2B-DSpark", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use openbmb/MiniCPM5-2B-DSpark with Docker Model Runner:
docker model run hf.co/openbmb/MiniCPM5-2B-DSpark
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- zh
|
| 6 |
+
library_name: transformers
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
tags:
|
| 9 |
+
- minicpm
|
| 10 |
+
- minicpm5
|
| 11 |
+
- llama
|
| 12 |
+
- text-generation
|
| 13 |
+
- long-context
|
| 14 |
+
- tool-calling
|
| 15 |
+
- on-device
|
| 16 |
+
- edge-ai
|
| 17 |
+
datasets:
|
| 18 |
+
- openbmb/Ultra-FineWeb
|
| 19 |
+
- openbmb/UltraX-Preview
|
| 20 |
+
- openbmb/Ultra-FineWeb-L3
|
| 21 |
+
- openbmb/UltraData-Math
|
| 22 |
+
- openbmb/UltraData-Code
|
| 23 |
+
- openbmb/UltraData-SFT-2605
|
| 24 |
+
- openbmb/UltraData-SFT-Agent-2609
|
| 25 |
+
- openbmb/UltraData-RL-2609
|
| 26 |
+
---
|
| 27 |
+
<div align="center">
|
| 28 |
+
<img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM/main/assets/minicpm_logo.png" width="500em" />
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
<p align="center">
|
| 32 |
+
<a href="https://arxiv.org/pdf/2506.07900" target="_blank">MiniCPM Tech Report</a> |
|
| 33 |
+
<a href="https://modelbest.feishu.cn/wiki/UtWxwcERfiRIpIkBOjuc3h9tn1D" target="_blank">MiniCPM Wiki(Chinese)</a> |
|
| 34 |
+
<a href="https://github.com/OpenBMB/MiniCPM" target="_blank">GitHub Repo</a> |
|
| 35 |
+
<a href="https://ultradata.openbmb.cn/" target="_blank">UltraData</a> |
|
| 36 |
+
<a href="https://huggingface.co/spaces/openbmb/MiniCPM5-2B-Demo" target="_blank">Online Demo</a>
|
| 37 |
+
</p>
|
| 38 |
+
|
| 39 |
+
<p align="center">
|
| 40 |
+
English |
|
| 41 |
+
<a href="https://huggingface.co/openbmb/MiniCPM5-2B/blob/main/README-cn.md" target="_blank">中文</a>
|
| 42 |
+
</p>
|
| 43 |
+
|
| 44 |
+
# MiniCPM5-2B-DSpark
|
| 45 |
+
|
| 46 |
+
`MiniCPM5-2B-DSpark` is a [DSpark](https://arxiv.org/abs/2607.05147)
|
| 47 |
+
draft checkpoint trained for exact pairing with [MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B) and its
|
| 48 |
+
tokenizer.
|
| 49 |
+
|
| 50 |
+
## Model Specification
|
| 51 |
+
|
| 52 |
+
| Property | Value |
|
| 53 |
+
|---|---|
|
| 54 |
+
| Target model | [MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B) |
|
| 55 |
+
| Draft layers | 5 |
|
| 56 |
+
| Draft parameters | 323,776,001 |
|
| 57 |
+
| Draft tokens per forward pass | 7 |
|
| 58 |
+
| Target hidden-state layers | `[1, 10, 20, 30, 39]` |
|
| 59 |
+
| Checkpoint precision | BF16 |
|
| 60 |
+
|
| 61 |
+
## Training Recipe
|
| 62 |
+
|
| 63 |
+
Training responses were generated by [MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B) from a mixture of
|
| 64 |
+
general-domain, mathematics, and code prompts.
|
| 65 |
+
|
| 66 |
+
| Setting | Value |
|
| 67 |
+
|---|---|
|
| 68 |
+
| Training sequences | 1,959,525 |
|
| 69 |
+
| Training tokens | 7,054,154,509 |
|
| 70 |
+
| Epochs | 6 |
|
| 71 |
+
| Maximum sequence length | 12,288 |
|
| 72 |
+
| Optimizer | AdamW |
|
| 73 |
+
| Objective | CE + L1 + confidence loss |
|
| 74 |
+
|
| 75 |
+
## Evaluation
|
| 76 |
+
|
| 77 |
+
Acceptance length is defined as the total number of completion tokens divided
|
| 78 |
+
by the total number of speculative verification steps. Evaluation uses natural
|
| 79 |
+
EOS termination and `max_new_tokens=4096`.
|
| 80 |
+
|
| 81 |
+
| Domain | `T=0` | `T=1.0` |
|
| 82 |
+
|---|---:|---:|
|
| 83 |
+
| Math | 6.0496 | 4.6050 |
|
| 84 |
+
| Code | 6.1106 | 4.4381 |
|
| 85 |
+
| General | 4.1585 | 3.0997 |
|
| 86 |
+
| Aggregate | **5.5174** | **4.0514** |
|
| 87 |
+
|
| 88 |
+
## Usage with SGLang
|
| 89 |
+
|
| 90 |
+
```bash
|
| 91 |
+
python -m sglang.launch_server \
|
| 92 |
+
--model-path <target-model-path> \
|
| 93 |
+
--trust-remote-code \
|
| 94 |
+
--speculative-algorithm DSPARK \
|
| 95 |
+
--speculative-draft-model-path <draft-model-path> \
|
| 96 |
+
--speculative-dspark-block-size 7
|
| 97 |
+
```
|