Instructions to use openbmb/MiniCPM-MoE-8x2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM-MoE-8x2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/MiniCPM-MoE-8x2B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM-MoE-8x2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openbmb/MiniCPM-MoE-8x2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/MiniCPM-MoE-8x2B" # 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/MiniCPM-MoE-8x2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openbmb/MiniCPM-MoE-8x2B
- SGLang
How to use openbmb/MiniCPM-MoE-8x2B 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/MiniCPM-MoE-8x2B" \ --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/MiniCPM-MoE-8x2B", "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/MiniCPM-MoE-8x2B" \ --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/MiniCPM-MoE-8x2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use openbmb/MiniCPM-MoE-8x2B with Docker Model Runner:
docker model run hf.co/openbmb/MiniCPM-MoE-8x2B
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Introduction
|
| 2 |
+
|
| 3 |
+
The MiniCPM-MoE-8x2B is a decoder-only transformer-based generative language model.
|
| 4 |
+
|
| 5 |
+
The MiniCPM-MoE-8x2B adopt a Mixture-of-Experts(MoE) architecture, which has 8 experts per layer and activates 2 of 8 experts for each token.
|
| 6 |
+
|
| 7 |
+
# Usage
|
| 8 |
+
This is a model version after instruction tuning but without other rlhf methods. Chat template is automatically applied.
|
| 9 |
+
``` python
|
| 10 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 11 |
+
import torch
|
| 12 |
+
torch.manual_seed(0)
|
| 13 |
+
|
| 14 |
+
path = 'openbmb/MiniCPM-MoE-8x2B'
|
| 15 |
+
tokenizer = AutoTokenizer.from_pretrained(path)
|
| 16 |
+
model = AutoModelForCausalLM.from_pretrained(path, torch_dtype=torch.bfloat16, device_map='cuda', trust_remote_code=True)
|
| 17 |
+
|
| 18 |
+
responds, history = model.chat(tokenizer, "山东省最高的山是哪座山, 它比黄山高还是矮?差距多少?", temperature=0.8, top_p=0.8)
|
| 19 |
+
print(responds)
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
# Note
|
| 23 |
+
1. You can alse inference with [vLLM](https://github.com/vllm-project/vllm), which will be compatible with this repo and has a much higher inference throughput.
|
| 24 |
+
2. The precision of model weights in this repo is bfloat16. Manual convertion is needed for other kinds of dtype.
|
| 25 |
+
|
| 26 |
+
# Statement
|
| 27 |
+
1. As a language model, MiniCPM-MoE-8x2B generates content by learning from a vast amount of text.
|
| 28 |
+
2. However, it does not possess the ability to comprehend or express personal opinions or value judgments.
|
| 29 |
+
3. Any content generated by MiniCPM-MoE-8x2B does not represent the viewpoints or positions of the model developers.
|
| 30 |
+
4. Therefore, when using content generated by MiniCPM-MoE-8x2B, users should take full responsibility for evaluating and verifying it on their own.
|
| 31 |
+
|