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 README.md
Browse files
README.md
CHANGED
|
@@ -20,9 +20,9 @@ library_name: transformers
|
|
| 20 |
|
| 21 |
## Overview
|
| 22 |
|
| 23 |
-
BitCPM4-CANN-
|
| 24 |
|
| 25 |
-
> β οΈ **This model is NOT for direct inference.** For inference, use the pseudo-quantized version: [openbmb/BitCPM4-CANN-
|
| 26 |
|
| 27 |
## Continued Pre-training & Fine-tuning
|
| 28 |
|
|
@@ -30,7 +30,7 @@ The **only requirement** is that the forward pass must go through the bundled `m
|
|
| 30 |
|
| 31 |
### Option 1: DeepSpeed (Recommended)
|
| 32 |
|
| 33 |
-
We provide ready-to-use training scripts in the [example](https://huggingface.co/openbmb/BitCPM4-CANN-
|
| 34 |
|
| 35 |
- **Continued pre-training**: `example/run.sh` + `example/train.py`
|
| 36 |
- **SFT (Supervised Fine-tuning)**: `example/run_sft.sh` + `example/train_sft.py`
|
|
@@ -52,7 +52,7 @@ Any framework that supports HuggingFace model loading with custom code can be us
|
|
| 52 |
```python
|
| 53 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 54 |
|
| 55 |
-
path = 'openbmb/BitCPM4-CANN-
|
| 56 |
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
|
| 57 |
model = AutoModelForCausalLM.from_pretrained(
|
| 58 |
path,
|
|
@@ -76,13 +76,13 @@ python qat-convert.py \
|
|
| 76 |
--group_size -1
|
| 77 |
```
|
| 78 |
|
| 79 |
-
The converted model can be loaded for inference in the same way as [openbmb/BitCPM4-CANN-
|
| 80 |
|
| 81 |
## Workflow
|
| 82 |
|
| 83 |
```
|
| 84 |
βββββββββββββββββββββββββββββββββββ
|
| 85 |
-
β BitCPM4-CANN-
|
| 86 |
βββββββββββββββββ¬ββββββββββββββββββ
|
| 87 |
β
|
| 88 |
βΌ Train (DeepSpeed / LLaMA Factory / HF Trainer / ...)
|
|
@@ -92,7 +92,7 @@ The converted model can be loaded for inference in the same way as [openbmb/BitC
|
|
| 92 |
β
|
| 93 |
βΌ python qat-convert.py --quant_type ternary --group_size -1
|
| 94 |
βββββββββββββββββββββββββββββββββββ
|
| 95 |
-
β Pseudo-quantized model β β Ready for inference (same format as BitCPM4-CANN-
|
| 96 |
βββββββββββββββββββββββββββββββββββ
|
| 97 |
```
|
| 98 |
|
|
|
|
| 20 |
|
| 21 |
## Overview
|
| 22 |
|
| 23 |
+
BitCPM4-CANN-8B-unquantized is the **unquantized QAT (Quantization-Aware Training) checkpoint** of BitCPM4-CANN-8B, designed for **continued pre-training and fine-tuning**. It preserves full-precision latent weights with ternary fake quantizers (weights β {-1, 0, 1} with group-wise scaling, trained via STE) defined in `modeling.py`, enabling the model to keep learning under quantization constraints. For technical details, see our [Technical Report](https://github.com/OpenBMB/MiniCPM/blob/main/docs/BitCPM_CANN.pdf).
|
| 24 |
|
| 25 |
+
> β οΈ **This model is NOT for direct inference.** For inference, use the pseudo-quantized version: [openbmb/BitCPM4-CANN-8B](https://huggingface.co/openbmb/BitCPM4-CANN-8B).
|
| 26 |
|
| 27 |
## Continued Pre-training & Fine-tuning
|
| 28 |
|
|
|
|
| 30 |
|
| 31 |
### Option 1: DeepSpeed (Recommended)
|
| 32 |
|
| 33 |
+
We provide ready-to-use training scripts in the [example](https://huggingface.co/openbmb/BitCPM4-CANN-8B-unquantized/tree/main/example) directory (using the 1B model as an example):
|
| 34 |
|
| 35 |
- **Continued pre-training**: `example/run.sh` + `example/train.py`
|
| 36 |
- **SFT (Supervised Fine-tuning)**: `example/run_sft.sh` + `example/train_sft.py`
|
|
|
|
| 52 |
```python
|
| 53 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 54 |
|
| 55 |
+
path = 'openbmb/BitCPM4-CANN-8B-unquantized'
|
| 56 |
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
|
| 57 |
model = AutoModelForCausalLM.from_pretrained(
|
| 58 |
path,
|
|
|
|
| 76 |
--group_size -1
|
| 77 |
```
|
| 78 |
|
| 79 |
+
The converted model can be loaded for inference in the same way as [openbmb/BitCPM4-CANN-8B](https://huggingface.co/openbmb/BitCPM4-CANN-8B)βno special quantization libraries required.
|
| 80 |
|
| 81 |
## Workflow
|
| 82 |
|
| 83 |
```
|
| 84 |
βββββββββββββββββββββββββββββββββββ
|
| 85 |
+
β BitCPM4-CANN-8B-unquantized β β This model (QAT checkpoint + fake quantizer in modeling.py)
|
| 86 |
βββββββββββββββββ¬ββββββββββββββββββ
|
| 87 |
β
|
| 88 |
βΌ Train (DeepSpeed / LLaMA Factory / HF Trainer / ...)
|
|
|
|
| 92 |
β
|
| 93 |
βΌ python qat-convert.py --quant_type ternary --group_size -1
|
| 94 |
βββββββββββββββββββββββββββββββββββ
|
| 95 |
+
β Pseudo-quantized model β β Ready for inference (same format as BitCPM4-CANN-8B)
|
| 96 |
βββββββββββββββββββββββββββββββββββ
|
| 97 |
```
|
| 98 |
|