minicpm5-deploy-transformers
What it does
This skill guides your AI through running MiniCPM5 with the Hugging Face Transformers library in one Python script. It is for people who want a quick test without setting up a server.
When to use it
- ✓When you want a quick Python script that generates text from MiniCPM5.
- ✓When you have a single GPU and want to run the model in bfloat16.
- ✓When you have no GPU and need to run the model on the CPU.
Skill link
https://github.com/OpenBMB/MiniCPM/blob/main/skills/minicpm5-deploy-transformers/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Write me a short Python script that runs MiniCPM5 and answers one question, with no server needed.”
5 new skills a week. 1 minute to read.
How it works
The skill installs the libraries, loads the model and tokenizer, builds a chat prompt, and generates an answer in one script.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Deploy MiniCPM5-1B and MiniCPM5-2B with HF Transformers
One-shot Python generation. No server. Works on a single GPU (bfloat16) or CPU only (fp32).
Required input
| Var | Example | Default |
|---|---|---|
MODEL_PATH |
openbmb/MiniCPM5-2B or local dir |
required; openbmb/MiniCPM5-1B also works |
MODE |
think or nothink (nothink is 1B-only) |
think |
Steps
1. Install (once)
pip install -U "transformers>=5.6,<6" "torch>=2.11" accelerate # latest (CUDA 13.x driver hosts)
# pip install -U "transformers==4.57.3" "torch==2.7.1" accelerate # fallback for CUDA 12.x driver hosts
2. Run
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "${MODEL_PATH}" # ← replace
tok = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.bfloat16, # CPU users: torch.float32 + device_map="cpu"
device_map="auto",
).eval()
messages = [{"role": "user", "content": "用一句话解释什么是 GQA。"}]
inputs = tok.apply_chat_template(
messages,
add_generation_prompt=True,
enable_thinking=True,
return_tensors="pt",
return_dict=True,
).to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=1024,
do_sample=True,
temperature=1.0,
top_p=0.95,
)
prompt_len = inputs["input_ids"].shape[-1]
print(tok.decode(out[0][prompt_len:], skip_special_tokens=True))
For CPU only: change torch_dtype=torch.float32, device_map="cpu". Keep enable_thinking=True and temperature=1.0 for MiniCPM5-2B; use enable_thinking=False and temperature=0.7 only for MiniCPM5-1B No-think mode.
Sampling defaults
| Mode | enable_thinking |
temperature |
top_p |
|---|---|---|---|
| MiniCPM5-2B Think | True |
1.0 | 0.95 |
| MiniCPM5-1B Think | True |
0.9 | 0.95 |
| MiniCPM5-1B No-think | False |
0.7 | 0.95 |
Validate
A coherent answer to 1+1=? (e.g. "2" or "答案是 2").
LoRA inference
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, "/path/to/adapter").eval()
Adapters from any of the minicpm5-finetune-* skills load directly with no surgery.
When NOT to use
- Need an OpenAI-compatible HTTP server →
minicpm5-deploy-vllmorminicpm5-deploy-sglang - Apple Silicon →
minicpm5-deploy-mlxis faster - CPU-only or low-VRAM laptop →
minicpm5-deploy-llama-cppwith Q4_K_M is faster
Reference
FAQ
Can it run without a GPU?
Yes. The skill says to use float32 on the CPU with the device set to cpu.
Does it support thinking mode?
Yes. The skill includes an enable_thinking setting, and says the nothink mode is for the 1B model only.
Which versions are needed?
The skill asks for transformers 5.6 or newer below version 6, and torch 2.11 or newer.
Details
Original description by the author
Run MiniCPM5-1B or MiniCPM5-2B with Hugging Face Transformers for one-shot Python generation on GPU (bfloat16) or CPU (float32). Use when the user wants a quick Python script, no server, no extra deps, or asks for "Transformers", "AutoModelForCausalLM", "model.generate" with MiniCPM5.
repo: OpenBMB/MiniCPM
Popularity
- GitHub stars
- 12k
- Ranking position
- #11536
- License
- Apache-2.0
- Updated
- 9/21/2026
Comments
- …
More skills from this repository
minicpm5-deploy-litert
12kLets your agent run MiniCPM5 models on a computer or Android phone with Google's LiteRT-LM runtime, using one model file.
minicpm5-deploy-llama-cpp
12kShows your agent how to run MiniCPM5 models with llama.cpp on a CPU or a home graphics card, using ready-made GGUF files.
minicpm5-deploy-lmstudio
12kHelps your agent run MiniCPM5 models in LM Studio, a desktop app with a chat window, and start its local OpenAI-style server.
minicpm5-deploy-mlx
12kLets your agent run MiniCPM5 models natively on Apple Silicon Macs with Apple's MLX framework, for fast local chat and text generation.
Similar skills
openclaw-update
394kHelps your agent update an existing OpenClaw Gateway, choosing the update method that fits how it was installed and keeping your session working.
diagnose-gateway
394kHelps your agent find out why your OpenClaw Gateway is failing by checking settings, channels, and ports without changing anything.
crabbox-apps
394kHelps your agent open and run an app on a temporary cloud machine, then show its view in your chat side panel.