Instructions to use mlx-community/MiniCPM5-2B-OptiQ-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/MiniCPM5-2B-OptiQ-4bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/MiniCPM5-2B-OptiQ-4bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use mlx-community/MiniCPM5-2B-OptiQ-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/MiniCPM5-2B-OptiQ-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/MiniCPM5-2B-OptiQ-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use mlx-community/MiniCPM5-2B-OptiQ-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/MiniCPM5-2B-OptiQ-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/MiniCPM5-2B-OptiQ-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/MiniCPM5-2B-OptiQ-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use mlx-community/MiniCPM5-2B-OptiQ-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/MiniCPM5-2B-OptiQ-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default mlx-community/MiniCPM5-2B-OptiQ-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mlx-community/MiniCPM5-2B-OptiQ-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/MiniCPM5-2B-OptiQ-4bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "mlx-community/MiniCPM5-2B-OptiQ-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
MiniCPM5-2B-OptiQ-4bit
Built with mlx-optiq, the MLX-native toolkit to quantize, prune, fine-tune, and serve LLMs locally on Apple Silicon, no PyTorch and no cloud. Try the Lab · All OptiQ quants · Docs
Mixed-precision MLX quantization of openbmb/MiniCPM5-2B, OpenBMB's 2B-class Llama-architecture model with hybrid reasoning, tool calling and a 128k context. Apache-2.0 from the base model.
- Base: openbmb/MiniCPM5-2B (42 layers, Llama architecture, hybrid reasoning, 128k context)
- Quantization: OptiQ sensitivity-aware mixed precision (4-bit + 8-bit)
- Disk size: 1,837 MB
- Calibration: the bundled
optiq.jsonlmix (40 samples across prose, reasoning, code, agent loops, tool-calling, instructions)
The OptiQ optimizer measured every linear layer against the bf16 model and kept 112 of 295 at 8-bit (the ones whose output moved most under 4-bit: output projections, the last blocks, lm_head) and 183 at 4-bit. The full per-layer assignment is in optiq/metadata.json next to the safetensors.
Capability Score
Six benchmarks, one number, the same recipe as every mlx-optiq quant (non-thinking mode, for cross-family comparability).
| Benchmark | Score |
|---|---|
| MMLU (5-shot, 1000) | 59.8% |
| GSM8K (1000, 3-shot CoT) | 82.1% |
| IFEval (full set, strict) | 86.7% |
| BFCL V3 (simple AST, 200 calls) | 82.5% |
| HumanEval (164, pass@1) | 81.1% |
| HashHop (long-context retrieval) | 24.0% |
| Capability Score | 69.36 |
For scale: this 1.8 GB file scores level with the 2.8 GB Qwen3.5-4B-OptiQ-4bit (68.76), ahead on instruction following, GSM8K and HumanEval, behind on MMLU and tool-call format.
Loading
from mlx_lm import load, generate
model, tok = load("mlx-community/MiniCPM5-2B-OptiQ-4bit")
prompt = tok.apply_chat_template(
[{"role": "user", "content": "Summarize the plot of The Iliad in three sentences."}],
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
print(generate(model, tok, prompt=prompt, max_tokens=300))
Hybrid reasoning: think or no-think
The chat template takes an enable_thinking flag. On, the model emits a <think>...</think> block before answering, which helps on math, planning and multi-step code. The scores above are with thinking off.
| Mode | temperature | top_p | Use when |
|---|---|---|---|
| No-think (default) | 0.7 | 0.95 | Fast assistant, rewriting, conversational |
| Think | 0.9 | 0.95 | Math, code, multi-hop reasoning |
optiq serve forwards chat_template_kwargs verbatim, and also accepts the model name with a :think / :no-think suffix:
optiq serve --model mlx-community/MiniCPM5-2B-OptiQ-4bit --port 8000
curl -s http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"mlx-community/MiniCPM5-2B-OptiQ-4bit:think",
"messages":[{"role":"user","content":"What is 17 * 23?"}]}'
Tool calling
MiniCPM5 uses its own <function name="..."><param name="..."> call format. optiq serve parses it into OpenAI tool_calls, so agents that speak the OpenAI or Anthropic protocol (OptiQ Code, Claude Code via the Anthropic endpoint, OpenCode, Codex) work unchanged.
KV cache
kv_config.json in this repo is a per-layer mixed-precision KV-cache plan from optiq kv-cache. Pass it to optiq serve --kv-config for a smaller cache at long context without the quality loss of uniform 4-bit KV.
Fine-tuning
Small enough to LoRA-train on a 24 GB Mac at max_seq_length=2048. The sensitivity-aware LoRA overlay reads optiq/metadata.json and gives 8-bit layers twice the adapter rank of 4-bit layers at the same parameter budget.
optiq lora train mlx-community/MiniCPM5-2B-OptiQ-4bit \
--data ./my_training_data \
--preset default \
--max-seq-length 2048
Reproducibility
optiq convert openbmb/MiniCPM5-2B --target-bpw 5.0 --candidate-bits 4,8 --reference bf16
Deterministic given the same calibration mix.
Quantize your own
pip install mlx-optiq
optiq convert <hf-model-id> --target-bpw 5.0 --candidate-bits 4,8
optiq lab # local workbench: chat, compare, quantize, fine-tune
License + provenance
Apache-2.0, inherited from openbmb/MiniCPM5-2B. Quantized with mlx-optiq.
- Downloads last month
- 502
4-bit
Model tree for mlx-community/MiniCPM5-2B-OptiQ-4bit
Base model
openbmb/MiniCPM5-2B