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)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM3-4B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,9 +2,10 @@
|
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- zh
|
| 5 |
-
- en
|
| 6 |
pipeline_tag: text-generation
|
| 7 |
library_name: transformers
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
<div align="center">
|
| 10 |
<img src="https://github.com/OpenBMB/MiniCPM/blob/main/assets/minicpm_logo.png?raw=true" width="500em" ></img>
|
|
@@ -52,7 +53,7 @@ model_outputs = model.generate(
|
|
| 52 |
output_token_ids = [
|
| 53 |
model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs))
|
| 54 |
]
|
| 55 |
-
|
| 56 |
responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
|
| 57 |
print(responses)
|
| 58 |
```
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- zh
|
|
|
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
library_name: transformers
|
| 7 |
+
tags:
|
| 8 |
+
- medical
|
| 9 |
---
|
| 10 |
<div align="center">
|
| 11 |
<img src="https://github.com/OpenBMB/MiniCPM/blob/main/assets/minicpm_logo.png?raw=true" width="500em" ></img>
|
|
|
|
| 53 |
output_token_ids = [
|
| 54 |
model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs))
|
| 55 |
]
|
| 56 |
+
这种
|
| 57 |
responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
|
| 58 |
print(responses)
|
| 59 |
```
|