Instructions to use openbmb/MiniCPM3-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM3-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/MiniCPM3-4B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM3-4B", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM3-4B", trust_remote_code=True, 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openbmb/MiniCPM3-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/MiniCPM3-4B" # 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/MiniCPM3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openbmb/MiniCPM3-4B
- SGLang
How to use openbmb/MiniCPM3-4B 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/MiniCPM3-4B" \ --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/MiniCPM3-4B", "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/MiniCPM3-4B" \ --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/MiniCPM3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use openbmb/MiniCPM3-4B with Docker Model Runner:
docker model run hf.co/openbmb/MiniCPM3-4B
Commit History
-
Adding `safetensors` variant of this model
Verified signatureThis is an automated PR created with https://huggingface.co/spaces/safetensors/convert This new file is equivalent to `pytorch_model.bin` but safe in the sense that no arbitrary code can be put into it. These files also happen to load much faster than their pytorch counterpart: https://colab.research.google.com/github/huggingface/notebooks/blob/main/safetensors_doc/en/speed.ipynb The widgets on your model page will run using this model even if this is not merged making sure the file actually works. If you find any issues: please report here: https://huggingface.co/spaces/safetensors/convert/discussions Feel free to ignore this PR.7bbf111 -
fix: set add_bos_token=true
FrankC0st1ef3e7d16
-
remove minicpm tokenizer (#29)
Verified signature- remove minicpm tokenizer (536445ffcc9e4c7e4bf21ccc6e0118baae01671e)e8a65f6 -
Fix function calling parameter string quoting (#24)
Verified signature- Fix function calling parameter string quoting (36f106cd9cce5d795ec3438698c1b975c38520fe) - remove extraneous newline (d3dc4097294ea679975fad67c3f2dd3d42b0673f) - Fully support objects as array items (68ac49eb75065bbb4e64fd677866997dd826ac49) Co-authored-by: Sigbjørn Skjæret <CISCai@users.noreply.huggingface.co>bfe2f6c
-
Add full tool calling support to chat template (#20)
Verified signature- Add full tool calling support to chat template (aa415fb1a18b65d11f5c9220a59143f420cdb992) - Added support for default arguments (7e9c9d4d11fafd6fd503480cb45031db57622633) - Added support for argument pattern (39cf8dd5833fcd2189dc9a42ebb78f6506c5bb00) - Fixed missing condition for system <|im_end|> (3bcbd7b859414688f9750ee974afe2f1aa9caa56) - Fixed boolean default arguments (c97ecd6366f507a5cb37e351be728bb7c16c93c0) - Implemented nested types++ (0258b841feb46342d0fef36ce8da29faaf088083) - Remove 'Args:' if there are none (3d4716e49b063a604411cb0a6ed122e0a069a173) Co-authored-by: Sigbjørn Skjæret <CISCai@users.noreply.huggingface.co>c3c3550
-
Update tokenization_minicpm.py
Verified signature7f8e63d
-
Update tokenization_minicpm.py
Verified signaturea9d3817 -
Update tokenization_minicpm.py
Verified signature508a16b
-
Add `model_type` to config (#17)
Verified signature- Add `model_type` to config (5b3a3755c38b0b34f7fc515496abfded12f24103) Co-authored-by: Daniel Huang <pi314ever-intel@users.noreply.huggingface.co>6fcf8b4
-
add library tag (#8)
Verified signature- add library tag (6b05abdbcbd30d105b5a069715c391760fd66804) Co-authored-by: Daniel van Strien <davanstrien@users.noreply.huggingface.co>75f9f10
-
Update README.md
Verified signature8d724f7
-
Update tokenization_minicpm.py
Verified signaturef5d31d8 -
Update README.md
Verified signaturee618f3a -
fix loss in modeling_minicpm.py
FrankC0st1efc345c8 -
update bfcl and livecodebench version
FrankC0st1e65d6b09 -
Update README.md
Verified signature52fc630 -
Update README.md
Verified signaturea18cc45 -
Update README.md
Verified signature84b4815 -
Update README.md
Verified signaturef03dca5 -
Update README.md
Verified signatured7cca6a -
update readme
FrankC0st1e65aff61 -
add vllm inference example
FrankC0st1e49e4794 -
update readme
FrankC0st1e6c769fa -
fix: empty system prompt
FrankC0st1e43b498b
-
fix bug in .py
FrankC0st1ea4f2dcb -
change name to minicpm3
FrankC0st1e8fa0de6
-
fix name_or_path in config.json
FrankC0st1e91a5e0a -
initial commit
yanhui4a38946 -
initial commit
Verified signature760549e