Instructions to use openbmb/BitCPM-CANN-8B-unquantized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/BitCPM-CANN-8B-unquantized with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/BitCPM-CANN-8B-unquantized", 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/BitCPM-CANN-8B-unquantized", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use openbmb/BitCPM-CANN-8B-unquantized with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/BitCPM-CANN-8B-unquantized" # 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/BitCPM-CANN-8B-unquantized", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openbmb/BitCPM-CANN-8B-unquantized
- SGLang
How to use openbmb/BitCPM-CANN-8B-unquantized 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/BitCPM-CANN-8B-unquantized" \ --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/BitCPM-CANN-8B-unquantized", "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/BitCPM-CANN-8B-unquantized" \ --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/BitCPM-CANN-8B-unquantized", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use openbmb/BitCPM-CANN-8B-unquantized with Docker Model Runner:
docker model run hf.co/openbmb/BitCPM-CANN-8B-unquantized
Update modeling_minicpm.py: hardcode bias=False in MLP LinearQuantizer
Browse files- modeling_minicpm.py +3 -3
modeling_minicpm.py
CHANGED
|
@@ -863,9 +863,9 @@ class MiniCPMMLP(nn.Module):
|
|
| 863 |
self.config = config
|
| 864 |
self.hidden_size = config.hidden_size
|
| 865 |
self.intermediate_size = config.intermediate_size
|
| 866 |
-
self.gate_proj = LinearQuantizer(self.hidden_size, self.intermediate_size, bias=
|
| 867 |
-
self.up_proj = LinearQuantizer(self.hidden_size, self.intermediate_size, bias=
|
| 868 |
-
self.down_proj = LinearQuantizer(self.intermediate_size, self.hidden_size, bias=
|
| 869 |
# self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 870 |
# self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 871 |
# self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
|
|
|
| 863 |
self.config = config
|
| 864 |
self.hidden_size = config.hidden_size
|
| 865 |
self.intermediate_size = config.intermediate_size
|
| 866 |
+
self.gate_proj = LinearQuantizer(self.hidden_size, self.intermediate_size, bias=False, quant_type="ternary", bit=4, group_size=-1)
|
| 867 |
+
self.up_proj = LinearQuantizer(self.hidden_size, self.intermediate_size, bias=False, quant_type="ternary", bit=4, group_size=-1)
|
| 868 |
+
self.down_proj = LinearQuantizer(self.intermediate_size, self.hidden_size, bias=False, quant_type="ternary", bit=4, group_size=-1)
|
| 869 |
# self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 870 |
# self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 871 |
# self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|