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
Commit ·
e3e1498
1
Parent(s): e580bc8
[Fix] compatibility with higher transformers version
Browse files- tokenization_baichuan.py +5 -5
tokenization_baichuan.py
CHANGED
|
@@ -52,6 +52,11 @@ class BaichuanTokenizer(PreTrainedTokenizer):
|
|
| 52 |
eos_token = AddedToken(eos_token, lstrip=False, rstrip=False) if isinstance(eos_token, str) else eos_token
|
| 53 |
unk_token = AddedToken(unk_token, lstrip=False, rstrip=False) if isinstance(unk_token, str) else unk_token
|
| 54 |
pad_token = AddedToken(pad_token, lstrip=False, rstrip=False) if isinstance(pad_token, str) else pad_token
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
super().__init__(
|
| 56 |
bos_token=bos_token,
|
| 57 |
eos_token=eos_token,
|
|
@@ -63,11 +68,6 @@ class BaichuanTokenizer(PreTrainedTokenizer):
|
|
| 63 |
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
| 64 |
**kwargs,
|
| 65 |
)
|
| 66 |
-
self.vocab_file = vocab_file
|
| 67 |
-
self.add_bos_token = add_bos_token
|
| 68 |
-
self.add_eos_token = add_eos_token
|
| 69 |
-
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 70 |
-
self.sp_model.Load(vocab_file)
|
| 71 |
|
| 72 |
def __getstate__(self):
|
| 73 |
state = self.__dict__.copy()
|
|
|
|
| 52 |
eos_token = AddedToken(eos_token, lstrip=False, rstrip=False) if isinstance(eos_token, str) else eos_token
|
| 53 |
unk_token = AddedToken(unk_token, lstrip=False, rstrip=False) if isinstance(unk_token, str) else unk_token
|
| 54 |
pad_token = AddedToken(pad_token, lstrip=False, rstrip=False) if isinstance(pad_token, str) else pad_token
|
| 55 |
+
self.vocab_file = vocab_file
|
| 56 |
+
self.add_bos_token = add_bos_token
|
| 57 |
+
self.add_eos_token = add_eos_token
|
| 58 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 59 |
+
self.sp_model.Load(vocab_file)
|
| 60 |
super().__init__(
|
| 61 |
bos_token=bos_token,
|
| 62 |
eos_token=eos_token,
|
|
|
|
| 68 |
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
| 69 |
**kwargs,
|
| 70 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
def __getstate__(self):
|
| 73 |
state = self.__dict__.copy()
|