Instructions to use baichuan-inc/Baichuan-13B-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use baichuan-inc/Baichuan-13B-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="baichuan-inc/Baichuan-13B-Chat", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-13B-Chat", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use baichuan-inc/Baichuan-13B-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "baichuan-inc/Baichuan-13B-Chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "baichuan-inc/Baichuan-13B-Chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/baichuan-inc/Baichuan-13B-Chat
- SGLang
How to use baichuan-inc/Baichuan-13B-Chat 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 "baichuan-inc/Baichuan-13B-Chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "baichuan-inc/Baichuan-13B-Chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "baichuan-inc/Baichuan-13B-Chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "baichuan-inc/Baichuan-13B-Chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use baichuan-inc/Baichuan-13B-Chat with Docker Model Runner:
docker model run hf.co/baichuan-inc/Baichuan-13B-Chat
modify: update 13B chat model
Browse files
generation_config.json
CHANGED
|
@@ -10,5 +10,6 @@
|
|
| 10 |
"top_p": 0.85,
|
| 11 |
"repetition_penalty": 1.1,
|
| 12 |
"do_sample": true,
|
| 13 |
-
"transformers_version": "4.29.2"
|
|
|
|
| 14 |
}
|
|
|
|
| 10 |
"top_p": 0.85,
|
| 11 |
"repetition_penalty": 1.1,
|
| 12 |
"do_sample": true,
|
| 13 |
+
"transformers_version": "4.29.2",
|
| 14 |
+
"no_add_eos": true
|
| 15 |
}
|
modeling_baichuan.py
CHANGED
|
@@ -572,9 +572,7 @@ class BaichuanForCausalLM(BaichuanPreTrainedModel):
|
|
| 572 |
elif message['role'] == 'assistant':
|
| 573 |
round_input = [
|
| 574 |
self.generation_config.assistant_token_id
|
| 575 |
-
] + content_tokens +
|
| 576 |
-
self.generation_config.eos_token_id
|
| 577 |
-
] + round_input
|
| 578 |
else:
|
| 579 |
raise ValueError(f"message role not supported yet: {message['role']}")
|
| 580 |
total_input = total_input[-max_input_tokens:] # truncate left
|
|
|
|
| 572 |
elif message['role'] == 'assistant':
|
| 573 |
round_input = [
|
| 574 |
self.generation_config.assistant_token_id
|
| 575 |
+
] + content_tokens + round_input
|
|
|
|
|
|
|
| 576 |
else:
|
| 577 |
raise ValueError(f"message role not supported yet: {message['role']}")
|
| 578 |
total_input = total_input[-max_input_tokens:] # truncate left
|
pytorch_model-00001-of-00003.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:493368dd0c14f9e93a9359dcdbbe1640a70c5691851d502867e46df5e3e72e50
|
| 3 |
+
size 9972279780
|
pytorch_model-00002-of-00003.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:83b12d88f4aa459f377dd714866fa2b81c99e88fefec727286ea302515ef4aed
|
| 3 |
+
size 9947419824
|
pytorch_model-00003-of-00003.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:788ef65efe2ce412605cc81a056db2784235cec23cfccd1d9d3bed64b3e4d3be
|
| 3 |
+
size 6610199329
|