Instructions to use openbmb/MiniCPM5-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM5-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/MiniCPM5-2B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM5-2B") model = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM5-2B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openbmb/MiniCPM5-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/MiniCPM5-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM5-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openbmb/MiniCPM5-2B
- SGLang
How to use openbmb/MiniCPM5-2B 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" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM5-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM5-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use openbmb/MiniCPM5-2B with Docker Model Runner:
docker model run hf.co/openbmb/MiniCPM5-2B
Remove the dead `<tool_sep>` branch from chat_template.jinja (fixes OpenBMB/MiniCPM#379)
Remove the dead <tool_sep> branch from chat_template.jinja (fixes OpenBMB/MiniCPM#379)
What
Two changes, nothing else:
- Delete the
<tool_sep>handling block inside the assistant branch (former lines 54β117). It splitcontenton<tool_sep>and tried to interleave the tool-call XML between the text segments by accumulatingprocessed_contentinsideforloops. - Change the trailing tool-call block guard from
{%- if message.tool_calls and not has_tool_sep %}to{%- if message.tool_calls %}.
Diff: 66 lines removed, 1 line changed. Parameter rendering, reasoning handling, tool-response handling and the generation prompt are untouched.
Why
The branch never worked. Jinja2 does not propagate {% set %} assignments made inside a for loop to the enclosing scope, so processed_content kept its initial value content_parts[0] β everything after the first <tool_sep> was silently dropped (see #379 for the minimal reproducer). has_tool_sep was never defined anywhere, so the trailing guard was always true and the tool-call XML was emitted by the fallback block regardless.
The branch is unreachable in normal serving. <tool_sep> is not a special token in the tokenizer, the SGLang minicpm5_detector neither produces nor consumes it, and the model does not emit it (0/10 samples across prompts designed to elicit "text, then tool call, then text"). Only a hand-crafted assistant message containing the literal string <tool_sep> reaches this code, and in that case it loses data.
Removing it is therefore a pure cleanup with one observable effect: an assistant content that happens to contain <tool_sep> is now preserved verbatim instead of being truncated.